Skip to content

Conversation

@fracek
Copy link
Contributor

@fracek fracek commented Dec 6, 2025

This PR adds the field. It's marked optional so that it works on older streams.

@coderabbitai
Copy link

coderabbitai bot commented Dec 6, 2025

📝 Walkthrough

Walkthrough

Adds an optional L2 gas price field to Starknet block headers: a new l2_gas_price protobuf field and corresponding TypeScript l2GasPrice property plus serialization/deserialization support in generated proto code.

Changes

Cohort / File(s) Change Summary
Changelog Metadata
change/@apibara-starknet-79e122c4-6fa1-458b-bef9-d5a2038f8670.json
Adds a prerelease entry documenting a patch-level dependent change for @apibara/starknet about the L2 gas price header property.
Protobuf Definition
packages/starknet/proto/data.proto
Adds l2_gas_price : ResourcePrice (field 11) to BlockHeader. Minor EOF newline adjustment.
TypeScript Block Interface
packages/starknet/src/block.ts
Adds optional l2GasPrice property (OptionalCodec(ResourcePrice)) to the BlockHeader codec with updated JSDoc.
Generated Proto Code
packages/starknet/src/proto/data.ts
Adds l2GasPrice?: ResourcePrice to BlockHeader; updates createBaseBlockHeader initialization, encode/decode paths (field 11 / tag 90), fromJSON/toJSON, and fromPartial to handle the new field.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify proto field number (11) aligns with encode/decode tag (90) in generated code.
  • Ensure ResourcePrice (de)serialization mirrors existing patterns and optional initialization is correct.

Suggested reviewers

  • jaipaljadeja

Poem

🐇 I nibble bytes and sniff the chain,
New gas price hops into the frame.
Field eleven tucked so neat,
Headers hum with extra beat.
⛽🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding an l2 gas price field to the starknet header across proto, TypeScript codec, and proto-generated files.
Description check ✅ Passed The description explains the purpose of the change (adding the field and marking it optional) and the rationale (backward compatibility with older streams).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/starknet/src/block.ts (1)

173-199: Codec wiring is correct; consider clarifying the l2GasPrice JSDoc

l2GasPrice: OptionalCodec(ResourcePrice) is consistent with how L1 gas prices are modeled and correctly keeps the field optional. The JSDoc line @prop l2GasPrice Calldata gas price. looks copy‑pasted from l1GasPrice; consider rephrasing it (e.g., “L2 gas price”) so it’s clear this is for L2, not L1 calldata.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3bddfbe and dcefb7d.

📒 Files selected for processing (4)
  • change/@apibara-starknet-79e122c4-6fa1-458b-bef9-d5a2038f8670.json (1 hunks)
  • packages/starknet/proto/data.proto (2 hunks)
  • packages/starknet/src/block.ts (2 hunks)
  • packages/starknet/src/proto/data.ts (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (3)
packages/starknet/proto/data.proto (1)

31-55: L2 gas price field is correctly added to BlockHeader

l2_gas_price uses an unused field number (11), matches the existing ResourcePrice type used for L1 gas fields, and keeps the message backward compatible. No issues here.

change/@apibara-starknet-79e122c4-6fa1-458b-bef9-d5a2038f8670.json (1)

1-7: Prerelease metadata matches the change

Change file correctly describes a patch-level update for @apibara/starknet with an accurate comment. Looks good.

packages/starknet/src/proto/data.ts (1)

310-355: BlockHeader.l2GasPrice is consistently wired through interface, defaults, encode/decode, and JSON helpers

The new l2GasPrice field is:

  • Optional at the type level (ResourcePrice | undefined),
  • Initialized to undefined in createBaseBlockHeader,
  • Encoded/decoded with field number 11 (tag 90) using ResourcePrice,
  • Properly handled in fromJSON, toJSON, and fromPartial.

This mirrors the existing L1 gas price fields and preserves binary and JSON compatibility. No issues found.

Also applies to: 1083-1320

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/starknet/src/block.ts (1)

173-186: Documenting l2GasPrice looks consistent; consider clarifying units

The new @prop l2GasPrice L2 gas price. entry is consistent with the field name and placement. If you want to be extra explicit, you could mirror ResourcePrice’s doc and mention that the value is expressed in fri/wei, but that’s optional.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dcefb7d and c555fbc.

📒 Files selected for processing (4)
  • change/@apibara-starknet-79e122c4-6fa1-458b-bef9-d5a2038f8670.json (1 hunks)
  • packages/starknet/proto/data.proto (2 hunks)
  • packages/starknet/src/block.ts (2 hunks)
  • packages/starknet/src/proto/data.ts (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/starknet/src/proto/data.ts
  • packages/starknet/proto/data.proto
  • change/@apibara-starknet-79e122c4-6fa1-458b-bef9-d5a2038f8670.json
🧰 Additional context used
🧬 Code graph analysis (1)
packages/starknet/src/block.ts (1)
packages/starknet/src/proto/data.ts (2)
  • ResourcePrice (618-625)
  • ResourcePrice (4730-4802)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (1)
packages/starknet/src/block.ts (1)

187-199: l2GasPrice codec wiring is correct and backward‑compatible

Adding l2GasPrice: OptionalCodec(ResourcePrice) to BlockHeader matches the new proto field and keeps older blocks decodable (field simply undefined when absent). This looks correct and in line with how other optional header fields are modeled.

@fracek fracek merged commit 8e322db into apibara:main Dec 6, 2025
2 checks passed
@fracek fracek deleted the update-starknet branch December 6, 2025 16:15
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.

1 participant