Skip to content

Conversation

aaronbuchwald
Copy link
Collaborator

@aaronbuchwald aaronbuchwald commented Feb 7, 2025

This PR adds Canoto serialization support for the block.Context type, so that downstream consumers that want to serialize it with Canoto can do so easily.

@aaronbuchwald aaronbuchwald force-pushed the block-context-canoto branch from ecf54bc to 5e50cf2 Compare March 3, 2025 20:50
Co-authored-by: Razvan <36448915+rrazvan1@users.noreply.github.com>
Signed-off-by: aaronbuchwald <aaron.buchwald56@gmail.com>
// Because PreForkBlocks and PostForkOptions do not verify their execution
// against the P-chain's state, this context is undefined for those blocks.
PChainHeight uint64
PChainHeight uint64 `canoto:"fint64,1" json:"pChainHeight"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be a fint64 - I think this should just be an int. (The PChainHeight is not going to be > 2^56 for a long time). Even if this was fint32 I think int is more efficient for the foreseeable future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a go:generate at the top of this file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we run go generate during CI to ensure the generated files are up-to-date?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied the syntax from the mock generation to regex what go generate commands to run. I think ideally, we'd have one CI job for proto, mocks, and canoto, but don't think it makes sense to make such a change in this PR.

Comment on lines +158 to +167
check_canotogen:
name: Up-to-date canoto
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- shell: bash
run: go generate -run "github.com/StephenButtolph/canoto/canoto" ./...
- shell: bash
run: .github/workflows/check-clean-branch.sh
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied from directly above

@StephenButtolph StephenButtolph changed the title Block context canoto Add canoto serialization support to the block context Mar 7, 2025
@StephenButtolph StephenButtolph added this pull request to the merge queue Mar 7, 2025
Merged via the queue into master with commit 4f3f5e7 Mar 7, 2025
23 checks passed
@StephenButtolph StephenButtolph deleted the block-context-canoto branch March 7, 2025 15:25
cam-schultz pushed a commit that referenced this pull request Mar 24, 2025
Signed-off-by: aaronbuchwald <aaron.buchwald56@gmail.com>
Co-authored-by: Razvan <36448915+rrazvan1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants