core/vm/runtime: set random to enable merge-opcodes (#29799)

pull/29768/head^2
Martin HS 6 months ago committed by GitHub
parent caafa93598
commit 42471d7a3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 45
      core/vm/runtime/runtime.go
  2. 6
      core/vm/runtime/runtime_test.go

@ -57,24 +57,33 @@ type Config struct {
// sets defaults on the config // sets defaults on the config
func setDefaults(cfg *Config) { func setDefaults(cfg *Config) {
if cfg.ChainConfig == nil { if cfg.ChainConfig == nil {
var (
shanghaiTime = uint64(0)
cancunTime = uint64(0)
)
cfg.ChainConfig = &params.ChainConfig{ cfg.ChainConfig = &params.ChainConfig{
ChainID: big.NewInt(1), ChainID: big.NewInt(1),
HomesteadBlock: new(big.Int), HomesteadBlock: new(big.Int),
DAOForkBlock: new(big.Int), DAOForkBlock: new(big.Int),
DAOForkSupport: false, DAOForkSupport: false,
EIP150Block: new(big.Int), EIP150Block: new(big.Int),
EIP155Block: new(big.Int), EIP155Block: new(big.Int),
EIP158Block: new(big.Int), EIP158Block: new(big.Int),
ByzantiumBlock: new(big.Int), ByzantiumBlock: new(big.Int),
ConstantinopleBlock: new(big.Int), ConstantinopleBlock: new(big.Int),
PetersburgBlock: new(big.Int), PetersburgBlock: new(big.Int),
IstanbulBlock: new(big.Int), IstanbulBlock: new(big.Int),
MuirGlacierBlock: new(big.Int), MuirGlacierBlock: new(big.Int),
BerlinBlock: new(big.Int), BerlinBlock: new(big.Int),
LondonBlock: new(big.Int), LondonBlock: new(big.Int),
} ArrowGlacierBlock: nil,
GrayGlacierBlock: nil,
TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true,
MergeNetsplitBlock: nil,
ShanghaiTime: &shanghaiTime,
CancunTime: &cancunTime}
} }
if cfg.Difficulty == nil { if cfg.Difficulty == nil {
cfg.Difficulty = new(big.Int) cfg.Difficulty = new(big.Int)
} }
@ -101,6 +110,10 @@ func setDefaults(cfg *Config) {
if cfg.BlobBaseFee == nil { if cfg.BlobBaseFee == nil {
cfg.BlobBaseFee = big.NewInt(params.BlobTxMinBlobGasprice) cfg.BlobBaseFee = big.NewInt(params.BlobTxMinBlobGasprice)
} }
// Merge indicators
if t := cfg.ChainConfig.ShanghaiTime; cfg.ChainConfig.TerminalTotalDifficultyPassed || (t != nil && *t == 0) {
cfg.Random = &(common.Hash{})
}
} }
// Execute executes the code using the input as call data during the execution. // Execute executes the code using the input as call data during the execution.

@ -105,7 +105,7 @@ func TestExecute(t *testing.T) {
func TestCall(t *testing.T) { func TestCall(t *testing.T) {
state, _ := state.New(types.EmptyRootHash, state.NewDatabase(rawdb.NewMemoryDatabase()), nil) state, _ := state.New(types.EmptyRootHash, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
address := common.HexToAddress("0x0a") address := common.HexToAddress("0xaa")
state.SetCode(address, []byte{ state.SetCode(address, []byte{
byte(vm.PUSH1), 10, byte(vm.PUSH1), 10,
byte(vm.PUSH1), 0, byte(vm.PUSH1), 0,
@ -725,7 +725,7 @@ func TestRuntimeJSTracer(t *testing.T) {
byte(vm.CREATE), byte(vm.CREATE),
byte(vm.POP), byte(vm.POP),
}, },
results: []string{`"1,1,952855,6,12"`, `"1,1,952855,6,0"`}, results: []string{`"1,1,952853,6,12"`, `"1,1,952853,6,0"`},
}, },
{ {
// CREATE2 // CREATE2
@ -741,7 +741,7 @@ func TestRuntimeJSTracer(t *testing.T) {
byte(vm.CREATE2), byte(vm.CREATE2),
byte(vm.POP), byte(vm.POP),
}, },
results: []string{`"1,1,952846,6,13"`, `"1,1,952846,6,0"`}, results: []string{`"1,1,952844,6,13"`, `"1,1,952844,6,0"`},
}, },
{ {
// CALL // CALL

Loading…
Cancel
Save