Skip to content

Commit a875cc8

Browse files
feat(core): changes based on the latest block.extradata format (#295)
1 parent 124fde7 commit a875cc8

File tree

3 files changed

+26
-40
lines changed

3 files changed

+26
-40
lines changed

core/state_processor.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
172172
// CHANGE(taiko): decode the basefeeSharingPctg config from the extradata, and
173173
// add it to the Message, if its an ontake block.
174174
if config.IsOntake(header.Number) {
175-
basefeeSharingPctg, _ := DecodeOntakeExtraData(header.Extra)
176-
msg.BasefeeSharingPctg = basefeeSharingPctg
175+
msg.BasefeeSharingPctg = DecodeOntakeExtraData(header.Extra)
177176
}
178177
// Create a new context to be used in the EVM environment
179178
blockContext := NewEVMBlockContext(header, bc, author)

core/state_transition.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -538,21 +538,8 @@ func (st *StateTransition) getTreasuryAddress() common.Address {
538538
)
539539
}
540540

541-
// DecodeOntakeExtraData decodes an ontake block's extradata,
542-
// returns basefeeSharingPctg and blockGasTargetMillion configurations.
543-
func DecodeOntakeExtraData(extradata []byte) (uint8, uint8) {
544-
// Convert []byte to *big.Int
545-
extra := new(big.Int).SetBytes(extradata)
546-
547-
// Define the masks.
548-
blockGasTargetMillionMask := big.NewInt(0xFF) // 8 bits mask for _blockGasTargetMillion
549-
basefeeSharingPctgMask := big.NewInt(0xFF) // 8 bits mask for _basefeeSharingPctg
550-
551-
// Extract _blockGasTargetMillion.
552-
blockGasTargetMillion := new(big.Int).And(extra, blockGasTargetMillionMask).Uint64()
553-
554-
// Shift right by 8 bits to get the _basefeeSharingPctg part.
555-
basefeeSharingPctg := new(big.Int).Rsh(extra, 8).And(basefeeSharingPctgMask, basefeeSharingPctgMask).Uint64()
556-
557-
return uint8(basefeeSharingPctg), uint8(blockGasTargetMillion)
541+
// DecodeOntakeExtraData decodes an ontake block's extradata, returns basefeeSharingPctg configurations,
542+
// the corresponding enocding function in protocol is `LibProposing._encodeGasConfigs`.
543+
func DecodeOntakeExtraData(extradata []byte) uint8 {
544+
return uint8(new(big.Int).SetBytes(extradata).Uint64())
558545
}

0 commit comments

Comments
 (0)