Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of Sonic's per-block base-fee adjustment #297

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

HerbertJordan
Copy link
Collaborator

@HerbertJordan HerbertJordan commented Nov 11, 2024

This PR integrates Sonic's base-fee adjustment algorithm into the Sonic client. After this PR, base-fees are updated with each block and no longer determined at the epoch boundary.

To integrate this feature, two additional values need to be stored in blocks:

  • the nano-second part of the block time, using 4 bytes
  • the block duration, defined as the duration in nanoseconds between the a block's predecessor and the block itself (8 bytes)

Both values are required for the computation of base-fee prices. Since fields can not be arbitrarily added to blocks, a pre-existing, previously unused 32-byte "extra-data" fields was used. The two new values are stored in big endian format in the first 12 bytes of this value.

Besides these changes, this PR also fixes the handling of the GasLimit field in blocks, which previously was filled with math.MaxUint64 but presented to RPC clients as the 6-byte value 0xffffffffffff presumably in order to avoid parsing or overflow errors for client code using signed 64-bit integers. With this change, an actual value -- the rules.Blocks.MaxBlockGas of the network configuration rules -- is used as the Gas limit per block.

@HerbertJordan HerbertJordan changed the title Herbert/per block gas pricing integration Integration of Sonic's per-block base-fee adjustment Nov 11, 2024
@HerbertJordan HerbertJordan force-pushed the herbert/per_block_gas_pricing_algorithm branch 2 times, most recently from dcde650 to 67e6008 Compare November 13, 2024 08:16
Base automatically changed from herbert/per_block_gas_pricing_algorithm to develop November 13, 2024 08:31
@HerbertJordan HerbertJordan force-pushed the herbert/per_block_gas_pricing_integration branch 4 times, most recently from 3bb52ec to 277268e Compare November 15, 2024 11:57
@HerbertJordan HerbertJordan force-pushed the herbert/per_block_gas_pricing_integration branch from 277268e to 52e3300 Compare November 15, 2024 12:01
@HerbertJordan HerbertJordan marked this pull request as ready for review November 15, 2024 12:09
gossip/apply_genesis.go Show resolved Hide resolved
gossip/c_block_callbacks.go Show resolved Hide resolved
Copy link
Collaborator

@thaarok thaarok left a comment

Choose a reason for hiding this comment

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

Seems ok to me 👍

gossip/c_block_callbacks.go Show resolved Hide resolved
@HerbertJordan HerbertJordan merged commit ff1782d into develop Nov 15, 2024
2 checks passed
@HerbertJordan HerbertJordan deleted the herbert/per_block_gas_pricing_integration branch November 15, 2024 13:32
Copy link
Collaborator

@jenikd jenikd left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for these changes. Having correct value for GasLimit is great.

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.

4 participants