You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The standard library should include some support for timestamps. Although difficult and dangerous in decentralised environments a large segment of contracts use them extensively in relatively safe ways. In Flint we would want the safe way to be the only way.
Using the block timestamp is dangerous as it has been shown that it can be manipulated by a miner. However this, through game theory principles, is limited in scope.
Two suggested methods for including time dependence in a safe way are:
Restricted to fixed timescales
Due to the reverse incentive for other miners to mine on top of a block clearly in the future. 12 Minutes has been approximated as a safe dift boundary.
Block numbers and average block time can be used to estimate time, but this is not future proof as block times may change (such as the changes expected during Casper).
Namely a new block is mined approximately every 12s therefore we can include a standard library function like below:
if Time.roughlyExceeds("2018-07-01", "19:00") {
}
struct Time {
functions roughlyExceeds(date: Date, time: Time) {
epocTime = epoc(date, time) // Number of seconds from first block creation
expectedBlockNumber = epoc / 12
return blockNumber() > expectedBlockNumber
}
}
The text was updated successfully, but these errors were encountered:
The standard library should include some support for timestamps. Although difficult and dangerous in decentralised environments a large segment of contracts use them extensively in relatively safe ways. In Flint we would want the safe way to be the only way.
Using the block timestamp is dangerous as it has been shown that it can be manipulated by a miner. However this, through game theory principles, is limited in scope.
Two suggested methods for including time dependence in a safe way are:
Restricted to fixed timescales
Due to the reverse incentive for other miners to mine on top of a block clearly in the future. 12 Minutes has been approximated as a safe dift boundary.
Block based timestamp
Block numbers and average block time can be used to estimate time, but this is not future proof as block times may change (such as the changes expected during Casper).
Namely a new block is mined approximately every 12s therefore we can include a standard library function like below:
The text was updated successfully, but these errors were encountered: