-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CIP-21 Governable "lookbackWindow" parameter #1136
Conversation
30237db
to
3b341ce
Compare
8ea43f1
to
657191b
Compare
657191b
to
adfa925
Compare
3fcaef2
to
cc1f94b
Compare
consensus/istanbul/uptime/config.go
Outdated
value, err := getLookbackWindow() | ||
if err != nil { | ||
value = MinSafeLookbackWindow | ||
if !isDonut { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually prefer to flip the then/else to have if isDonut {
instead, except when there is a reason not to. Having the shorter block first is nice, but not necessarily worth it.
consensus/istanbul/uptime/config.go
Outdated
if !isDonut { | ||
return defaultLookbackWindow | ||
} | ||
var returnValue uint64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why returnValue
rather than value
? Also, we could put in the signature (value uint64)
} | ||
return 0, err | ||
} | ||
return lookbackWindow.Uint64(), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will have the side effect of truncating any 256-bit value to a go uint64?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically I'm double-checking that an invalid contract state won't cause a panic or something here
These flags are actually ignored lated in the code; and generate confussion. Hence, this commit deprecrated them and clearle states that they are ignored.
Governable lookback window
* Move logic to uptime model, for cohesiveness * Move istanbul config processing to istanbul module * Verify lookbackWindow is within safe boundaries * Verify EpochSize is at least MinEpochSize Nits & clean ups
# Conflicts: # consensus/istanbul/backend/engine.go
This commits also changes the behaviour pre-hardfork, but it it considered safe.
b1e37d4
to
375f565
Compare
Implementation of CIP-21 smart contract changes. celo-blockchain related PR: celo-org/celo-blockchain#1136 Adds the uptimeLookbackWindow to the BlockchainParameters contract. This is only ever used on the celo-blockchain client to determine the size of the uptime lookback window which is used to compute the validator uptimeScore An important invariant, is that UptimeLookbackWindow must remain constant during an epoch. Thus, changes to the parameter only take effect on the next epoch. There's an exception to this rule during migration/deployment of this change; there uptimeLookbackWindow should be initialized to chain's current value for the parameter which is part of the ChainConfig on the genesis block. To initialize the value: On a new testnet: As part of the migrations, BlockchainParamets.initialize() will do the initialization On an existing testnet: After upgrading the contract, first call to setLookbackWindow() will the value for the current epoch. Since BlockchainParameters won't be reinitialized when this change is deployed, a patch was made to the getUptimteLookbackWindow() contract to return 12 (mainnet, baklava & alfajores value for lookbackWindow) in the case of the value not being initalized. This patch can be removed in the future, since it's only necessary until setLoobackWindow() is called and first epoch since deployment has passed Co-authored-by: Mariano Cortesi <[email protected]>
Description
Modifies celo-blockchain to obtain
lookbackWindow
parameter from theBlockchainParameters
smart contract. It assumes the smart contract will return the same value during an epoch.lookbackWindow
is used on 3 places:Blockchain
we obtain theloobackWindow
asses the "upness" of each validator on that blockOther changes
Tested
Added unit tests.
Related issues
Backwards compatibility
Hardfork Change. Part of
Donut
Hardfork