mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-31 00:53:46 +00:00
feat(core): changes based on the latest block.extradata format (#295)
This commit is contained in:
parent
124fde7e02
commit
a875cc83b9
3 changed files with 26 additions and 40 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue