mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-14 16:03:45 +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
|
// CHANGE(taiko): decode the basefeeSharingPctg config from the extradata, and
|
||||||
// add it to the Message, if its an ontake block.
|
// add it to the Message, if its an ontake block.
|
||||||
if config.IsOntake(header.Number) {
|
if config.IsOntake(header.Number) {
|
||||||
basefeeSharingPctg, _ := DecodeOntakeExtraData(header.Extra)
|
msg.BasefeeSharingPctg = DecodeOntakeExtraData(header.Extra)
|
||||||
msg.BasefeeSharingPctg = basefeeSharingPctg
|
|
||||||
}
|
}
|
||||||
// Create a new context to be used in the EVM environment
|
// Create a new context to be used in the EVM environment
|
||||||
blockContext := NewEVMBlockContext(header, bc, author)
|
blockContext := NewEVMBlockContext(header, bc, author)
|
||||||
|
|
|
||||||
|
|
@ -538,21 +538,8 @@ func (st *StateTransition) getTreasuryAddress() common.Address {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeOntakeExtraData decodes an ontake block's extradata,
|
// DecodeOntakeExtraData decodes an ontake block's extradata, returns basefeeSharingPctg configurations,
|
||||||
// returns basefeeSharingPctg and blockGasTargetMillion configurations.
|
// the corresponding enocding function in protocol is `LibProposing._encodeGasConfigs`.
|
||||||
func DecodeOntakeExtraData(extradata []byte) (uint8, uint8) {
|
func DecodeOntakeExtraData(extradata []byte) uint8 {
|
||||||
// Convert []byte to *big.Int
|
return uint8(new(big.Int).SetBytes(extradata).Uint64())
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue