Skip to content

feat(gnoland): add block_height and chain_id to GnoTxMetadata#5390

Closed
moul wants to merge 3 commits into
masterfrom
moul/extend-tx-metadata
Closed

feat(gnoland): add block_height and chain_id to GnoTxMetadata#5390
moul wants to merge 3 commits into
masterfrom
moul/extend-tx-metadata

Conversation

@moul
Copy link
Copy Markdown
Member

@moul moul commented Mar 30, 2026

Summary

  • Extends GnoTxMetadata with BlockHeight (int64) and ChainID (string) fields, both with omitempty for backward compatibility
  • Updates genesis replay ContextFn in loadAppState to also apply block height from metadata during genesis tx execution
  • Adds TestInitChainer_MetadataBlockHeight test verifying block height is correctly set during genesis replay

Context

Part of the chain upgrade (gnoland1 → gnoland-1) tx export/import pipeline. These fields allow preserving the original block height and chain ID when exporting transactions for genesis assembly.

Companion PR: gnolang/tx-archive — backup populates these new fields, plus new genesis-assemble command.

Related PRs: #5334, #5368, #5376, #5377

Test plan

  • TestInitChainer_MetadataBlockHeight passes — deploys a realm capturing runtime.ChainHeight() at genesis, verifies captured height matches metadata
  • Existing TestInitChainer_MetadataTxs still passes
  • Verify omitempty — old JSONL files without new fields still deserialize correctly

AI-assisted: code generated with Claude Code

Extend GnoTxMetadata with BlockHeight and ChainID fields to support
chain upgrade tx export/import. The genesis replay ContextFn now also
applies block height from metadata during genesis tx execution.

These fields use omitempty so existing JSONL files remain compatible.
@Gno2D2
Copy link
Copy Markdown
Collaborator

Gno2D2 commented Mar 30, 2026

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

No automated checks match this pull request.

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

Tests serialization/deserialization of TxWithMetadata with all metadata
fields (Timestamp, BlockHeight, ChainID) through JSONL and genesis replay.
Also verifies backward compatibility with old format lacking new fields.
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@moul moul marked this pull request as ready for review March 30, 2026 14:23
@moul moul requested review from aeddi, ajnavarro and jaekwon March 30, 2026 14:24
Timestamp int64 `json:"timestamp"`
Timestamp int64 `json:"timestamp"`
BlockHeight int64 `json:"block_height,omitempty"`
ChainID string `json:"chain_id,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you planning to use the ChainID field in a future PR? As it stands, it looks like dead code.

I see it’s being populated on the tx-archive side, but I don’t really get the goal there either (looks like it's never read). Maybe your intent is to specify where a TX comes from in each jsonl line? If that's the goal, I’m wondering if just defining it at the file level would be enough, so we don't unnecessarily duplicate the same data on every line of the jsonl.

Either way, it’d be good to add a comment explaining why this field is there.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The goal is to ensure the exported value is complete for validating signatures and replaying under similar conditions. We aim to use it as soon as it makes sense, but we want to make it available now to ensure completeness.

Comment thread gno.land/pkg/gnoland/app.go
@moul moul marked this pull request as draft April 1, 2026 18:36
moul added a commit that referenced this pull request Apr 9, 2026
- Revert premature doc references to gnoland-1 chain ID in gas-fees.md
  and explore-with-gnoweb.md (hardfork hasn't happened yet)
- Remove premature "Note" callout from gnoland-networks.md
- Update migrate-from-gnoland1.sh: reflect Scenario A decision (genesis
  tx-replay with InitialHeight), document blockers (#5411, #5390,
  Jae's InitialHeight tm2 work), reference issue #5374 for tracking
- Update gnoland-1/README.md: reflect correct PR merge status, document
  Scenario A approach, list migration blockers explicitly
@moul
Copy link
Copy Markdown
Member Author

moul commented Apr 9, 2026

Closing this PR as it is superseded by #5411. The BlockHeight and ChainID fields added here are now part of GnoTxMetadata in #5411, which is the main hardfork framework PR. The hardfork genesis tool (misc/hardfork) reads these fields directly when assembling the genesis.

@moul moul closed this Apr 9, 2026
@github-project-automation github-project-automation Bot moved this from 📥 Inbox to ✅ Done in 😎 Manfred's Board Apr 9, 2026
@moul moul mentioned this pull request Apr 9, 2026
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 ⛰️ gno.land Issues or PRs gno.land package related

Projects

Status: ✅ Done
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants