-
Notifications
You must be signed in to change notification settings - Fork 471
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
algod: Allow timestamp offsets in dev mode #5296
Conversation
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've read a portion of the PR and am planning to read more. The approach looks solid. I left some questions and a few nit's regarding comments and documentation.
@@ -482,7 +482,7 @@ func (node *AlgorandFullNode) writeDevmodeBlock() (err error) { | |||
|
|||
// Set block timestamp based on offset, if set. | |||
// Make sure block timestamp is not greater than MaxInt64. | |||
if node.timestampOffset != nil && prev.TimeStamp+*node.timestampOffset < math.MaxInt64 { | |||
if node.timestampOffset != nil && *node.timestampOffset < math.MaxInt64-prev.TimeStamp { |
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 think it can be <= here.
Summary
This PR allows users to change timestamps in block headers in dev mode. Users can use the
v2/devmode/blocks/offset
algod endpoint to set a timestamp delta between blocks. There is also a small dev-mode-only change that sets the block seed in the header to the block hash (previously, the seed was not populated in dev mode).When we are not in dev mode, the handlers return a
404
error by checking the genesis config. Optionally, we can consider adding another handler-level config likeEnableDeveloperAPI
to ensure that the node can accept dev-mode related APIs.Closes #3192 #4423
Test Plan
Added dev mode handler tests and tested on sandbox using dev mode and non dev mode.
Tested that timestamp/seed related TEAL opcodes work properly in dev mode (TEAL script here):
Currently can curl offset endpoint to set timestamp offsets in dev mode: