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

feat(core): changes based on the latest block.extradata format #295

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
// CHANGE(taiko): decode the basefeeSharingPctg config from the extradata, and
// add it to the Message, if its an ontake block.
if config.IsOntake(header.Number) {
basefeeSharingPctg, _ := DecodeOntakeExtraData(header.Extra)
msg.BasefeeSharingPctg = basefeeSharingPctg
msg.BasefeeSharingPctg = DecodeOntakeExtraData(header.Extra)
}
// Create a new context to be used in the EVM environment
blockContext := NewEVMBlockContext(header, bc, author)
Expand Down
21 changes: 4 additions & 17 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,21 +538,8 @@ func (st *StateTransition) getTreasuryAddress() common.Address {
)
}

// DecodeOntakeExtraData decodes an ontake block's extradata,
// returns basefeeSharingPctg and blockGasTargetMillion configurations.
func DecodeOntakeExtraData(extradata []byte) (uint8, uint8) {
// Convert []byte to *big.Int
extra := new(big.Int).SetBytes(extradata)

// Define the masks.
blockGasTargetMillionMask := big.NewInt(0xFF) // 8 bits mask for _blockGasTargetMillion
basefeeSharingPctgMask := big.NewInt(0xFF) // 8 bits mask for _basefeeSharingPctg

// Extract _blockGasTargetMillion.
blockGasTargetMillion := new(big.Int).And(extra, blockGasTargetMillionMask).Uint64()

// Shift right by 8 bits to get the _basefeeSharingPctg part.
basefeeSharingPctg := new(big.Int).Rsh(extra, 8).And(basefeeSharingPctgMask, basefeeSharingPctgMask).Uint64()

return uint8(basefeeSharingPctg), uint8(blockGasTargetMillion)
// DecodeOntakeExtraData decodes an ontake block's extradata, returns basefeeSharingPctg configurations,
// the corresponding enocding function in protocol is `LibProposing._encodeGasConfigs`.
func DecodeOntakeExtraData(extradata []byte) uint8 {
return uint8(new(big.Int).SetBytes(extradata).Uint64())
}
Loading
Loading