Skip to content

refactor(starknet): replace BlockStatus string with typed enum#3779

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

refactor(starknet): replace BlockStatus string with typed enum#3779
0xsamalt wants to merge 1 commit into
NethermindEth:mainfrom
0xsamalt:refactor/block-status-type

Conversation

@0xsamalt

@0xsamalt 0xsamalt commented Jul 1, 2026

Copy link
Copy Markdown
  • Introduces BlockStatus as a typed uint8 enum in starknet/block.go with constants BlockPending, BlockAcceptedOnL1, BlockAcceptedOnL2, BlockRejected, and BlockPreConfirmed
  • Adds UnmarshalText so the feeder JSON response deserialises directly into the enum and invalid status strings now return an error
  • Updates all comparison sites and test assertions to use the typed constants

@Ehsan-saradar

Copy link
Copy Markdown
Contributor

Nice one, typed status is much better than a bare string 👍

One thing I'd double-check first though: UnmarshalText now errors on any status that isn't one of the five, and since blocks are decoded straight through json.Unmarshal, an unknown status fails the whole block decode — not just that field. With the old string we accepted anything and only really cared about PENDING / PRE_CONFIRMED.

So if the feeder ever sends something not in the list (pretty sure ABORTED / REVERTED can show up on blocks), we'd fail to read that block and sync would get stuck on it.

Wdyt about mapping unknown values to a BlockUnknown instead of erroring? Keeps it harmless like before, since we only check for PENDING / PRE_CONFIRMED anyway. Or if we'd rather keep it strict, probably worth confirming the list covers everything the gateway can actually send.

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