Skip to content

refactor(starknet): change BlockIdentifier from string to typed uint64#3775

Open
0xsamalt wants to merge 1 commit into
NethermindEth:mainfrom
0xsamalt:fix/block-identifier-type
Open

refactor(starknet): change BlockIdentifier from string to typed uint64#3775
0xsamalt wants to merge 1 commit into
NethermindEth:mainfrom
0xsamalt:fix/block-identifier-type

Conversation

@0xsamalt

Copy link
Copy Markdown
  • Introduces starknet.BlockIdentifier as a named uint64 type with custom UnmarshalJSON that handles both hex string (ex: "0x...") and bare integers.
  • Changes PreConfirmedDeltaUpdate.BlockIdentifier and PreConfirmedBlock.BlockIdentifier from string to the new BlockIdentifier type.
  • Changes pending.PreConfirmed.BlockIdentifier from string to uint64 (raw, to avoid a circular import from core/pending → starknet).
  • Updates all mocks, adapters, and tests to match the new types.

@Ehsan-saradar

Copy link
Copy Markdown
Contributor

Heads up — this doesn't compile yet. A few PreConfirmedBlock* call sites still pass "" for the identifier, which no longer type-checks now that it's starknet.BlockIdentifier. Both the lint and test jobs fail on these three (everything else builds fine and the rest of the suite is green):

  • rpc/v9/transaction_test.go:473PreConfirmedBlockWithIdentifier(..., "", 0)
  • rpc/v9/transaction_test.go:1793PreConfirmedBlockByNumber(..., "", 0)
  • rpc/v10/transaction_test.go:600PreConfirmedBlockWithIdentifier(..., "", 0)

Changing the "" to 0 in those three spots does it 👍

@0xsamalt

0xsamalt commented Jul 7, 2026

Copy link
Copy Markdown
Author
  • rpc/v9/transaction_test.go:473PreConfirmedBlockWithIdentifier(..., "", 0)
  • rpc/v9/transaction_test.go:1793PreConfirmedBlockByNumber(..., "", 0)
  • rpc/v10/transaction_test.go:600PreConfirmedBlockWithIdentifier(..., "", 0)

Fixed, tests passing locally on rpc/v9 and rpc/v10

@Ehsan-saradar

Copy link
Copy Markdown
Contributor

Perfect, thanks for the quick fix — builds clean now. 👍

@RafaelGranza

Copy link
Copy Markdown
Contributor

Hey @0xsamalt, thanks for the PR!

Could you resolve the conflicts first? And could you help me understand the goal here?

It looks cosmetic to me, and it touches a very delicate spot.

Is it tied to any issue? Do you think it improves performance? If so, a benchmark would help.

@0xsamalt

Copy link
Copy Markdown
Author

Thanks @RafaelGranza!

@0xsamalt 0xsamalt force-pushed the fix/block-identifier-type branch from cf725f5 to 5cb2899 Compare July 12, 2026 13:19
@0xsamalt

Copy link
Copy Markdown
Author

Rebased onto the latest main (455b0dd) to resolve conflicts from the multi-block pre-confirmed chain work, the subscription-cache to deduper refactor, and the pending-endpoint removal that landed since this branch was opened.

Squashed down to a single commit the follow-up fix commit's changes were already folded in while resolving conflicts, so git dropped it as redundant.

Besides mechanical conflict resolution, this also:

  • Propagates the BlockIdentifier type change through code that landed on main after this PR branched (clients/feeder.Reader, starknetdata.StarknetData, sync.DataSource, sync/preconfirmed.DataSource, rpc/rpccore.PreConfirmedDeduper), which still had stray string-typed identifier params.
  • Fixes a real regression surfaced by testing during the rebase: DecodePreConfirmedUpdate was decoding block_identifier before checking changed, so a malformed identifier on a changed:false (NoChange) response broke decoding, even though NoChange is documented to ignore all other fields. Now the discriminator is checked first.

Full build, go vet, and test suite pass locally.

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.

3 participants