Skip to content

Commit

Permalink
clean : shanghai changes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xsharma committed Oct 6, 2023
1 parent 558bb54 commit 1fc6354
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 178 deletions.
1 change: 0 additions & 1 deletion cmd/evm/internal/t8ntool/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ func Transaction(ctx *cli.Context) error {
case new(big.Int).Mul(tx.GasFeeCap(), new(big.Int).SetUint64(tx.Gas())).BitLen() > 256:
r.Error = errors.New("gas * maxFeePerGas exceeds 256 bits")
}
// TODO marcello double check
// Check whether the init code size has been exceeded.
if chainConfig.IsShanghai(new(big.Int)) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
r.Error = errors.New("max initcode size exceeded")
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func Transition(ctx *cli.Context) error {
return NewError(ErrorConfig, errors.New("EIP-1559 config but missing 'currentBaseFee' in env section"))
}
}
// TODO marcello double check

if chainConfig.IsShanghai(big.NewInt(int64(prestate.Env.Number))) && prestate.Env.Withdrawals == nil {
return NewError(ErrorConfig, errors.New("Shanghai config but missing 'withdrawals' in env section"))
}
Expand Down
1 change: 0 additions & 1 deletion cmd/evm/t8n_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ func TestT8n(t *testing.T) {
output: t8nOutput{result: true},
expOut: "exp.json",
},
// TODO marcello double check
{ // Test post-merge transition
base: "./testdata/24",
input: t8nInput{
Expand Down
1 change: 0 additions & 1 deletion cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
// makeFullNode loads geth configuration and creates the Ethereum backend.
func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
stack, cfg := makeConfigNode(ctx)
// TODO marcello double check
if ctx.IsSet(utils.OverrideShanghai.Name) {
v := ctx.Int64(utils.OverrideShanghai.Name)
cfg.Eth.OverrideShanghai = new(big.Int).SetInt64(v)
Expand Down
1 change: 0 additions & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ var (
utils.NoUSBFlag,
utils.USBFlag,
utils.SmartCardDaemonPathFlag,
// TODO marcello double check
utils.OverrideShanghai,
utils.EnablePersonal,
utils.EthashCacheDirFlag,
Expand Down
3 changes: 1 addition & 2 deletions consensus/beacon/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
return err
}
// Verify existence / non-existence of withdrawalsHash.
// TODO marcello double check
shanghai := chain.Config().IsShanghai(header.Number)
if shanghai && header.WithdrawalsHash == nil {
return errors.New("missing withdrawalsHash")
Expand Down Expand Up @@ -391,7 +390,7 @@ func (beacon *Beacon) FinalizeAndAssemble(ctx context.Context, chain consensus.C
if !beacon.IsPoSHeader(header) {
return beacon.ethone.FinalizeAndAssemble(ctx, chain, header, state, txs, uncles, receipts, nil)
}
// TODO marcello double check

shanghai := chain.Config().IsShanghai(header.Number)
if shanghai {
// All blocks after Shanghai must include a withdrawals root.
Expand Down
2 changes: 1 addition & 1 deletion consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
if header.GasLimit > params.MaxGasLimit {
return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, params.MaxGasLimit)
}
// TODO marcello double check

if chain.Config().IsShanghai(header.Number) {
return fmt.Errorf("clique does not support shanghai fork")
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
if diff := new(big.Int).Sub(header.Number, parent.Number); diff.Cmp(big.NewInt(1)) != 0 {
return consensus.ErrInvalidNumber
}
// TODO marcello double check

if chain.Config().IsShanghai(header.Number) {
return fmt.Errorf("ethash does not support shanghai fork")
}
Expand Down
1 change: 0 additions & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen

applyOverrides := func(config *params.ChainConfig) {
if config != nil {
// TODO marcello double check
if overrides != nil && overrides.OverrideShanghai != nil {
config.ShanghaiBlock = overrides.OverrideShanghai
}
Expand Down
1 change: 0 additions & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,6 @@ func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, d
al.AddSlot(el.Address, key)
}
}
// TODO marcello double check
if rules.IsShanghai { // EIP-3651: warm coinbase
al.AddAddress(coinbase)
}
Expand Down
1 change: 0 additions & 1 deletion core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
}
// Fail if Shanghai not enabled and len(withdrawals) is non-zero.
withdrawals := block.Withdrawals()
// TODO marcello double check
if len(withdrawals) > 0 && !p.config.IsShanghai(block.Number()) {
return nil, nil, 0, fmt.Errorf("withdrawals before shanghai")
}
Expand Down
9 changes: 4 additions & 5 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,8 @@ func TestStateProcessorErrors(t *testing.T) {
MergeNetsplitBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true,
// TODO marcello double check
ShanghaiBlock: big.NewInt(0),
Bor: &params.BorConfig{BurntContract: map[string]string{"0": "0x000000000000000000000000000000000000dead"}},
ShanghaiBlock: big.NewInt(0),
Bor: &params.BorConfig{BurntContract: map[string]string{"0": "0x000000000000000000000000000000000000dead"}},
},
Alloc: GenesisAlloc{
common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{
Expand Down Expand Up @@ -442,10 +441,11 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
Time: parent.Time() + 10,
UncleHash: types.EmptyUncleHash,
}

if config.IsLondon(header.Number) {
header.BaseFee = misc.CalcBaseFee(config, parent.Header())
}
// TODO marcello double check

if config.IsShanghai(header.Number) {
header.WithdrawalsHash = &types.EmptyWithdrawalsHash
}
Expand All @@ -471,7 +471,6 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr

header.Root = common.BytesToHash(hasher.Sum(nil))
// Assemble and return the final block for sealing
// TODO marcello double check
if config.IsShanghai(header.Number) {
return types.NewBlockWithWithdrawals(header, txs, nil, receipts, []*types.Withdrawal{}, trie.NewStackTrie(nil))
}
Expand Down
1 change: 0 additions & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ func (st *StateTransition) TransitionDb(interruptCtx context.Context) (*Executio
}

// Check whether the init code size has been exceeded.
// TODO marcello double check
if rules.IsShanghai && contractCreation && len(msg.Data) > params.MaxInitCodeSize {
return nil, fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, len(msg.Data), params.MaxInitCodeSize)
}
Expand Down
3 changes: 1 addition & 2 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig
StateDB: statedb,
Config: config,
chainConfig: chainConfig,
// TODO marcello double check
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time),
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time),
}
evm.interpreter = NewEVMInterpreter(evm)

Expand Down
1 change: 0 additions & 1 deletion core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
var table *JumpTable

switch {
// TODO marcello double check
case evm.chainRules.IsShanghai:
table = &shanghaiInstructionSet
case evm.chainRules.IsMerge:
Expand Down
Loading

0 comments on commit 1fc6354

Please sign in to comment.