Skip to content

accept XDPoS RPC responses from both XDPoSChain and Nethermind - #52

Merged
wanwiset25 merged 2 commits into
XinFinOrg:masterfrom
ak88:fix/accept-nethermind-xdpos-responses
Oct 27, 2026
Merged

wanwiset25 merged 2 commits into
XinFinOrg:masterfrom
ak88:fix/accept-nethermind-xdpos-responses

Conversation

@ak88

@ak88 ak88 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem

docker run xinfinorg/csc:v0.3.0 full fails against a subnet whose SUBNET_URL node runs Nethermind:

getting subnet latest gap block
...
TypeError: Cannot read properties of undefined (reading 'Committed')
    at Object.data (/app/scripts/utils/xdcnet.js:45:23)
    at main (/app/scripts/FullCheckpointDeploy.js:9:28)

XDPoSChain returns PascalCase keys and JSON numbers; Nethermind returns camelCase keys and hex strings (epochBlockNumber: "0x510fd87", encodedRLP, masternodes, committed). The values are the same, only the keys differ. The deploy scripts read the PascalCase names:

  1. getGapSubnet / getEpochParentnet (cicd/util.js) read result.EpochBlockNumber. With Nethermind it is undefined, so the start subnet block becomes NaN.
  2. FullCheckpointDeploy.js then asks for XDPoS_getV2BlockByNumber("0xNaN"). The node correctly rejects that, so there is no result, and reading result.Committed throws.
  3. Even with a valid block, xdcnet.js reads Committed, EncodedRLP and Masternodes by their PascalCase names.

The relayer already handles both shapes (XDC-Relayer 4b4be45, in xdc-relayer:feature-v0.5.0). This PR does the same for the CSC deploy scripts.

Change

  • scripts/utils/rpcResultFields.js: getField (case-insensitive key lookup) and getNumberField (also parses "0x" hex), modelled on the relayer's src/service/xdpos.ts.
  • cicd/util.js: read EpochBlockNumber through getNumberField (both call sites).
  • scripts/utils/xdcnet.js: read Masternodes, Committed and EncodedRLP through getField. A failed RPC call now reaches the existing "is not committed" / "no validators" messages instead of throwing a TypeError.
  • test/RpcResultFields.js: unit test for both response shapes, a hex number, and missing fields or a failed call.

Responses from XDPoSChain are read exactly as before.

Testing

  • npx hardhat test test/RpcResultFields.js passes (3 tests), run inside xinfinorg/csc:v0.3.0.
  • End to end with the standard Subnet-Deployment generator-v3.1.0 wizard: 4 Nethermind subnet nodes (nethermindeth/nethermind:master-55f34a3) with Apothem as parentnet.
    • Deploy: full deploy with xinfinorg/csc:v0.3.0 plus these three files fails as above without the change. With it, it deploys and initialises FullCheckpoint at 0xfC803E731b970ce4098e94D32Ea91F3688831E6b on Apothem.
    • Relayer: xdc-relayer:feature-v0.5.0 then checkpoints the subnet into it with no errors.
    • Cross-check: getLatestBlocks() on the contract reports committed block #424 with the same hash the Nethermind node returns for #424.

The master copies of cicd/util.js and scripts/utils/xdcnet.js are byte-identical to those in the v0.3.0 image, so a rebuilt image only adds these changes.


🤖 AI agent (Claude Code / Opus 5.5) on behalf of @ak88

🤖 Generated with Claude Code

XDPoSChain returns PascalCase keys ("EncodedRLP") and JSON numbers, while
Nethermind returns camelCase keys ("encodedRLP") and hex strings. The deploy
scripts read EpochBlockNumber, Masternodes, Committed and EncodedRLP by their
PascalCase names, so against a Nethermind subnet the gap block came out as
NaN and FullCheckpointDeploy failed with "Cannot read properties of
undefined (reading 'Committed')". Read those fields case-insensitively and
parse numbers from either format, as the relayer does since 4b4be45.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e6a021ba-110d-41c8-9a17-8c2f0fbecf0e
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wanwiset25
wanwiset25 merged commit d44b0f1 into XinFinOrg:master Oct 27, 2026
1 check passed
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