-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add latest synced block data (#721)
* feat(db): add last synced block slot and root fields * feat(api): expose last upper synced block root and slot fields * chore: add changeset * test: uncomment env var * test(api): add tests * fix(api): validate slot, block number, and block root when updating or fetching blockchain sync state
- Loading branch information
Showing
9 changed files
with
368 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@blobscan/api": minor | ||
"@blobscan/db": minor | ||
--- | ||
|
||
Added last upper synced block root and block slot fields |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
169 changes: 169 additions & 0 deletions
169
packages/api/test/__snapshots__/blockchain-sync-state.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Blockchain sync state route > updateState > when authorized > should fail when trying to update last finalized slot to an invalid slot 1`] = ` | ||
"[ | ||
{ | ||
\\"code\\": \\"too_small\\", | ||
\\"minimum\\": 0, | ||
\\"type\\": \\"number\\", | ||
\\"inclusive\\": true, | ||
\\"exact\\": false, | ||
\\"message\\": \\"Number must be greater than or equal to 0\\", | ||
\\"path\\": [ | ||
\\"lastFinalizedBlock\\" | ||
] | ||
} | ||
]" | ||
`; | ||
|
||
exports[`Blockchain sync state route > updateState > when authorized > should fail when trying to update last finalized slot to an invalid slot 2`] = ` | ||
[ZodError: [ | ||
{ | ||
"code": "too_small", | ||
"minimum": 0, | ||
"type": "number", | ||
"inclusive": true, | ||
"exact": false, | ||
"message": "Number must be greater than or equal to 0", | ||
"path": [ | ||
"lastFinalizedBlock" | ||
] | ||
} | ||
]] | ||
`; | ||
|
||
exports[`Blockchain sync state route > updateState > when authorized > should fail when trying to update last lower synced slot to an invalid slot 1`] = ` | ||
"[ | ||
{ | ||
\\"code\\": \\"too_small\\", | ||
\\"minimum\\": 0, | ||
\\"type\\": \\"number\\", | ||
\\"inclusive\\": true, | ||
\\"exact\\": false, | ||
\\"message\\": \\"Number must be greater than or equal to 0\\", | ||
\\"path\\": [ | ||
\\"lastLowerSyncedSlot\\" | ||
] | ||
} | ||
]" | ||
`; | ||
|
||
exports[`Blockchain sync state route > updateState > when authorized > should fail when trying to update last lower synced slot to an invalid slot 2`] = ` | ||
[ZodError: [ | ||
{ | ||
"code": "too_small", | ||
"minimum": 0, | ||
"type": "number", | ||
"inclusive": true, | ||
"exact": false, | ||
"message": "Number must be greater than or equal to 0", | ||
"path": [ | ||
"lastLowerSyncedSlot" | ||
] | ||
} | ||
]] | ||
`; | ||
|
||
exports[`Blockchain sync state route > updateState > when authorized > should fail when trying to update last upper synced block root to an invalid hash 1`] = ` | ||
"[ | ||
{ | ||
\\"validation\\": \\"regex\\", | ||
\\"code\\": \\"invalid_string\\", | ||
\\"message\\": \\"Invalid hexadecimal string\\", | ||
\\"path\\": [ | ||
\\"lastUpperSyncedBlockRoot\\" | ||
] | ||
}, | ||
{ | ||
\\"code\\": \\"custom\\", | ||
\\"message\\": \\"Block hashes must be 66 characters long\\", | ||
\\"path\\": [ | ||
\\"lastUpperSyncedBlockRoot\\" | ||
] | ||
} | ||
]" | ||
`; | ||
|
||
exports[`Blockchain sync state route > updateState > when authorized > should fail when trying to update last upper synced block root to an invalid hash 2`] = ` | ||
[ZodError: [ | ||
{ | ||
"validation": "regex", | ||
"code": "invalid_string", | ||
"message": "Invalid hexadecimal string", | ||
"path": [ | ||
"lastUpperSyncedBlockRoot" | ||
] | ||
}, | ||
{ | ||
"code": "custom", | ||
"message": "Block hashes must be 66 characters long", | ||
"path": [ | ||
"lastUpperSyncedBlockRoot" | ||
] | ||
} | ||
]] | ||
`; | ||
|
||
exports[`Blockchain sync state route > updateState > when authorized > should fail when trying to update last upper synced block slot to an invalid slot 1`] = ` | ||
"[ | ||
{ | ||
\\"code\\": \\"too_small\\", | ||
\\"minimum\\": 0, | ||
\\"type\\": \\"number\\", | ||
\\"inclusive\\": true, | ||
\\"exact\\": false, | ||
\\"message\\": \\"Number must be greater than or equal to 0\\", | ||
\\"path\\": [ | ||
\\"lastUpperSyncedBlockSlot\\" | ||
] | ||
} | ||
]" | ||
`; | ||
|
||
exports[`Blockchain sync state route > updateState > when authorized > should fail when trying to update last upper synced block slot to an invalid slot 2`] = ` | ||
[ZodError: [ | ||
{ | ||
"code": "too_small", | ||
"minimum": 0, | ||
"type": "number", | ||
"inclusive": true, | ||
"exact": false, | ||
"message": "Number must be greater than or equal to 0", | ||
"path": [ | ||
"lastUpperSyncedBlockSlot" | ||
] | ||
} | ||
]] | ||
`; | ||
|
||
exports[`Blockchain sync state route > updateState > when authorized > should fail when trying to update last upper synced slot to an invalid slot 1`] = ` | ||
"[ | ||
{ | ||
\\"code\\": \\"too_small\\", | ||
\\"minimum\\": 0, | ||
\\"type\\": \\"number\\", | ||
\\"inclusive\\": true, | ||
\\"exact\\": false, | ||
\\"message\\": \\"Number must be greater than or equal to 0\\", | ||
\\"path\\": [ | ||
\\"lastUpperSyncedSlot\\" | ||
] | ||
} | ||
]" | ||
`; | ||
|
||
exports[`Blockchain sync state route > updateState > when authorized > should fail when trying to update last upper synced slot to an invalid slot 2`] = ` | ||
[ZodError: [ | ||
{ | ||
"code": "too_small", | ||
"minimum": 0, | ||
"type": "number", | ||
"inclusive": true, | ||
"exact": false, | ||
"message": "Number must be greater than or equal to 0", | ||
"path": [ | ||
"lastUpperSyncedSlot" | ||
] | ||
} | ||
]] | ||
`; |
Oops, something went wrong.