Skip to content

feat(runtime): add Op variant for claim bridge transfers#1727

Open
LGLO wants to merge 1 commit into
mainfrom
issue-1084-add-claim-kind-to-events
Open

feat(runtime): add Op variant for claim bridge transfers#1727
LGLO wants to merge 1 commit into
mainfrom
issue-1084-add-claim-kind-to-events

Conversation

@LGLO

@LGLO LGLO commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Overview

Ad Op variant for ClaimBridgeTransfer

The added Op::ClaimBridgeTransfer variant. Op is passed in only from Runtime to Node,
so updating Node before the Runtime makes it a safe change. Decode side is updated before Encode side.
The new variant is added as last to Op, so existing variants SCALE encoding doesn't change.

Claim of bridge transferred amount haven't yet happened in any durable environment yet, so future
consumers of ClaimRewards and ClaimBridgeTransfer can be sure what caused these events.
This is not true for lower testnets where old runtime will encode both kinds of claims as ClaimRewards.

TransactionAppliedStateRoot is not changed, it has only one field for amounts of both kinds of claims.

Op / Operation types, and the static runtime metadata is regenerated accordingly.

Issue: #1084

🗹 TODO before merging

  • Ready

📌 Submission Checklist

  • All commits are signed off (git commit -s) for the DCO
  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason:
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • Updated AGENTS.md if build commands, architecture, or workflows changed
  • No new todos introduced

🧪 Testing Evidence

Please describe any additional testing aside from CI:

  • Additional tests are provided (if possible)

🔱 Fork Strategy

  • Node Runtime Update
  • Node Client Update
  • Other:
  • N/A

Links

@LGLO LGLO requested a review from a team as a code owner June 19, 2026 12:16
@datadog-official

This comment has been minimized.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f5065a28f7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread ledger/src/common/types.rs Outdated
Deploy { address: Vec<u8> },
Maintain { address: Vec<u8> },
ClaimRewards { value: u128 },
ClaimRewards { value: u128, kind: ClaimKind },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Version the changed ClaimRewards runtime API ABI

When get_decoded_transaction returns a ClaimRewards operation, this added SCALE field changes the encoded Tx ABI, but pallets/midnight/src/runtime_api.rs still advertises MidnightRuntimeApi as version 5. Clients compiled against the old v5 layout, or node code querying pre-upgrade blocks through the same API version, will decode ClaimRewards { value } and then either fail or misread the following Tx fields; add a new runtime API version/changed_in compatibility path or preserve the old v5 result type for this method.

Useful? React with 👍 / 👎.

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.

AI has a good point. These ops aren't versioned like the ledger versions, which are separated by crate so they can get each relevant midnight-ledger version. Perhaps its worth versioning similarly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed it. This time I only add new Op variant. Since this is not persisted we don't need migration.
Op is only passed from Runtime to Node, so Node that is updated with this code prior to Runtime, will know how to decode it.

@LGLO LGLO force-pushed the issue-1084-add-claim-kind-to-events branch from f5065a2 to 458a1e1 Compare June 22, 2026 07:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 458a1e12e2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread pallets/midnight/src/runtime_api.rs Outdated
@@ -0,0 +1,11 @@
#runtime

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.

Technically also a sensitive node/client side change

@LGLO LGLO force-pushed the issue-1084-add-claim-kind-to-events branch from 7e36d9a to f564907 Compare June 25, 2026 09:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f56490714c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// New variants MUST be appended at the end: `Op` is SCALE-encoded across the
// `get_decoded_transaction` runtime-API boundary, so the variant indices are wire-significant.
// Appending keeps existing indices stable (an older decoder simply never sees the new index).
ClaimBridgeTransfer { value: u128 },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bump the runtime API version for ClaimBridgeTransfer

The fresh evidence in this revision is that pallets/midnight/src/runtime_api.rs still advertises MidnightRuntimeApi as version 5 while this new Op index can now be returned by get_decoded_transaction. Appending keeps new nodes able to decode old runtimes, but the reverse direction still breaks: an old node running with --filter-deploy-txs will call the upgraded runtime for a CardanoBridge claim, fail to SCALE-decode the unknown enum index, and node/src/filtering_pool.rs drops the otherwise valid transaction on that runtime API decode error. Please version this runtime API/result type or otherwise keep the v5 return path from producing the new variant for old callers.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

an old node running with --filter-deploy-txs will call the upgraded runtime for a CardanoBridge claim

We update nodes before runtime, so there is no case of old node talking to the new runtime.

@LGLO LGLO changed the title feat(runtime): add ClaimKind to Op/Operation ClaimReward variant feat(runtime): add Op variant for claim bridge transfers Jun 25, 2026
Signed-off-by: Lech Głowiak <lech.glowiak@shielded.io>
@LGLO LGLO force-pushed the issue-1084-add-claim-kind-to-events branch from 185d6ad to 0d47ad6 Compare June 26, 2026 05:05
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.

2 participants