Skip to content
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

Merged
merged 39 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6f7f7f6
Draft timestamp offset in dev mode
algochoi Apr 4, 2023
22e6432
Temp handlers for block timestamp offset
algochoi Apr 4, 2023
d45b1d1
Fix node handler function signatures
algochoi Apr 4, 2023
a0a0ae8
Regenerate routes
algochoi Apr 5, 2023
eaec94a
Dont try changing block header timestamp in pool
algochoi Apr 5, 2023
77d2f75
Try testing timestamps by changing up params
algochoi Apr 5, 2023
db8d99a
Use dev mode evaluator with validation turned off
algochoi Apr 5, 2023
bd36d99
Some fixes in outputting timestamps as seconds
algochoi Apr 6, 2023
b16188f
Refactoring state changes in block header
algochoi Apr 7, 2023
4d6eb21
Add handler related tweaks and handler tests
algochoi Apr 10, 2023
2f3aee9
Merge branch 'master' into devmode-handler
algochoi Apr 11, 2023
7e15bdd
OAPI specs fixes
algochoi Apr 11, 2023
ccf6f2f
Minor fix in new request in handler tests
algochoi Apr 11, 2023
3e1c3de
Fix comment for lint error
algochoi Apr 11, 2023
b62c212
Fix comments and format errors more clearly
algochoi Apr 11, 2023
97a2828
Change timestamp logic in dev mode
algochoi Apr 11, 2023
7fd96f7
Merge branch 'master' into devmode-handler
algochoi Apr 11, 2023
7ddce94
Simplify state in node/pool
algochoi Apr 11, 2023
d351aac
Refactor block evaluator
algochoi Apr 12, 2023
2cf6c47
Comment changes based on PR feedback
algochoi Apr 12, 2023
d870d7a
Block refactoring to use MakeBlock in MakeDevModeBlock
algochoi Apr 12, 2023
1655206
Change handler error when not in dev mode for getting offsets
algochoi Apr 12, 2023
7558422
Update daemon/algod/api/server/v2/test/handlers_test.go
algochoi Apr 13, 2023
6fd3c45
Test refactoring to remove some redundancy and explicit error message…
algochoi Apr 13, 2023
6c3f01d
Test node setting dev mode
algochoi Apr 13, 2023
af392f8
Make txPool unaware of devmode
algochoi Apr 13, 2023
962239e
Simplify txPool for dev mode
algochoi Apr 13, 2023
728a4f8
Merge branch 'master' into devmode-handler
algochoi Apr 13, 2023
0de0cb0
Create block seed even without setting offset
algochoi Apr 13, 2023
e7f482c
Add error when block timestamp is never set
algochoi Apr 14, 2023
e3d7d67
Update daemon/algod/api/server/v2/test/handlers_test.go
algochoi Apr 18, 2023
0b2d5aa
Remove unused type
algochoi Apr 18, 2023
d68378d
Merge branch 'master' into devmode-handler
algochoi Apr 18, 2023
430ff14
Check for max int bounds when converting from uint
algochoi Apr 18, 2023
7e54aa0
Merge branch 'master' into devmode-handler
algochoi Apr 19, 2023
59d20b6
Finish handling merge conflicts
algochoi Apr 19, 2023
941e13f
Fix some tests from merge
algochoi Apr 19, 2023
0dc2458
Don't allow timestamps to exceed MaxInt64
algochoi Apr 19, 2023
cf42081
Fix overflows in int64 arithmetic
algochoi Apr 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions daemon/algod/api/algod.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,89 @@
}
}
}
},
"/v2/devmode/blocks/offset": {
"get": {
"description": "Gets the current timestamp offset.",
"tags": [
algochoi marked this conversation as resolved.
Show resolved Hide resolved
"public",
"nonparticipating"
],
"produces": [
"application/json"
],
"schemes": [
"http"
],
"summary": "Returns the timestamp offset. Timestamp offsets can only be set in dev mode.",
"operationId": "GetBlockTimeStampOffset",
"responses": {
"200": {
"description": "OK",
"$ref": "#/responses/GetBlockTimeStampOffsetResponse"
},
"400": {
"description": "TimeStamp offset not set.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"default": {
"description": "Unknown Error"
}
}
}
},
"/v2/devmode/blocks/offset/{offset}": {
"post": {
"description": "Sets the timestamp offset (seconds) for blocks in dev mode. Providing an offset of 0 will unset this value and try to use the real clock for the timestamp.",
"tags": [
"public",
"nonparticipating"
],
"schemes": [
"http"
],
"summary": "Given a timestamp offset in seconds, adds the offset to every subsequent block header's timestamp.",
"operationId": "SetBlockTimeStampOffset",
"parameters": [
{
"type": "integer",
"description": "The timestamp offset for blocks in dev mode.",
"name": "offset",
"in": "path",
"required": true,
"minimum": 0
}
],
"responses": {
"200": {
"description": "OK",
"type": "object"
},
"400": {
"description": "Cannot set timestamp offset to a negative integer.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"401": {
"description": "Invalid API Token",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"500": {
"description": "Internal Error",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"default": {
"description": "Unknown Error"
}
}
}
}
},
"definitions": {
Expand Down Expand Up @@ -3695,6 +3778,21 @@
}
},
"responses": {
"GetBlockTimeStampOffsetResponse": {
"description": "Response containing the timestamp offset in seconds",
"schema": {
"type": "object",
"required": [
"offset"
],
"properties": {
"offset": {
"description": "Timestamp offset in seconds.",
"type": "integer"
}
}
}
},
"GetSyncRoundResponse": {
"description": "Response containing the ledger's minimum sync round",
"schema": {
Expand Down
128 changes: 128 additions & 0 deletions daemon/algod/api/algod.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,25 @@
},
"description": "DryrunResponse contains per-txn debug information from a dryrun."
},
"GetBlockTimeStampOffsetResponse": {
"content": {
"application/json": {
"schema": {
"properties": {
"offset": {
"description": "Timestamp offset in seconds.",
"type": "integer"
}
},
"required": [
"offset"
],
"type": "object"
}
}
},
"description": "Response containing the timestamp offset in seconds"
},
"GetSyncRoundResponse": {
"content": {
"application/json": {
Expand Down Expand Up @@ -3851,6 +3870,115 @@
]
}
},
"/v2/devmode/blocks/offset": {
"get": {
"description": "Gets the current timestamp offset.",
"operationId": "GetBlockTimeStampOffset",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"offset": {
"description": "Timestamp offset in seconds.",
"type": "integer"
}
},
"required": [
"offset"
],
"type": "object"
}
}
},
"description": "Response containing the timestamp offset in seconds"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "TimeStamp offset not set."
},
"default": {
"content": {},
"description": "Unknown Error"
}
},
"summary": "Returns the timestamp offset. Timestamp offsets can only be set in dev mode.",
"tags": [
"public",
"nonparticipating"
]
}
},
"/v2/devmode/blocks/offset/{offset}": {
"post": {
"description": "Sets the timestamp offset (seconds) for blocks in dev mode. Providing an offset of 0 will unset this value and try to use the real clock for the timestamp.",
"operationId": "SetBlockTimeStampOffset",
"parameters": [
{
"description": "The timestamp offset for blocks in dev mode.",
"in": "path",
"name": "offset",
"required": true,
"schema": {
"minimum": 0,
"type": "integer"
}
}
],
"responses": {
"200": {
"content": {},
"description": "OK"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Cannot set timestamp offset to a negative integer."
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Invalid API Token"
},
"500": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Internal Error"
},
"default": {
"content": {},
"description": "Unknown Error"
}
},
"summary": "Given a timestamp offset in seconds, adds the offset to every subsequent block header's timestamp.",
"tags": [
"public",
"nonparticipating"
]
}
},
"/v2/experimental": {
"get": {
"operationId": "ExperimentalCheck",
Expand Down
2 changes: 2 additions & 0 deletions daemon/algod/api/server/v2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ var (
errFailedRetrievingStateDelta = "failed retrieving State Delta: %v"
errFailedRetrievingNodeStatus = "failed retrieving node status"
errFailedRetrievingLatestBlockHeaderStatus = "failed retrieving latests block header"
errFailedRetrievingTimeStampOffset = "failed retrieving timestamp offset from node: %v"
errFailedSettingTimeStampOffset = "failed to set timestamp offset on the node: %v"
errFailedRetrievingSyncRound = "failed retrieving sync round from ledger"
errFailedSettingSyncRound = "failed to set sync round on the ledger"
errFailedParsingFormatOption = "failed to parse the format option"
Expand Down
Loading