-
Notifications
You must be signed in to change notification settings - Fork 2.6k
What prevents a misconfigured / malicious validator to create a block with bad timestamp? #5978
Comments
Block producers should build on the chain head with a timestamp they believe valid. There is extensive design work on this in https://w3f-research.readthedocs.io/en/latest/polkadot/BABE/Babe.html#-4.-clock-adjustment--relative-time-algorithm- and w3f/polkadot-spec#168 although @hndnklnc only added the temporary adjustment section https://w3f-research.readthedocs.io/en/latest/polkadot/BABE/Babe.html#temporarily-clock-adjustment recently. There was code that did not work properly, never got turned on, and got removed in #4993 dbeebe2#diff-20230c59d1bd7ffff93b396e87d05ad3 After @sorpaas refactoring #5655 any new attempt should be sharable with other consensus engines because it'll get used by both sassafras #4600 and secondary approval checks. We should expose and feed this clock back into parachains via cumulus too. |
Timestamp inhernet is checked here: https://github.com/paritytech/substrate/blob/master/frame/timestamp/src/lib.rs#L252 Additionally, BABE verifier checks the slot number here: substrate/client/consensus/babe/src/lib.rs Line 870 in 6ecbc4c
|
Yeah, as @arkpar said that it is checked and it will fail if the the timestamp is too far in the future. |
Followup question, up to 30s drift is allowed substrate/frame/timestamp/src/lib.rs Line 241 in e097348
Block producer use its local time to provide inherent data substrate/primitives/timestamp/src/lib.rs Lines 96 to 97 in e097348
Does this means the following attack is possible?
|
Is there a check that inherents have increasing timestamps somewhere? |
|
This is the only logic I can found to validate the timestamp in a block
substrate/frame/timestamp/src/lib.rs
Lines 154 to 157 in 67f354f
So what prevents a validator produce with a block with a future time?
And how does the next validator handle such case? If it is issuing block with the correct timestamp, it may be considered invalid?
The text was updated successfully, but these errors were encountered: