tests: changes needed to pass tests, drop before merging

pull/30511/head
Marius van der Wijden 2 months ago
parent 1d5144465f
commit 3e56fde23b
  1. 26
      cmd/evm/internal/t8ntool/transition.go
  2. 7
      tests/state_test_util.go

@ -196,6 +196,9 @@ func Transition(ctx *cli.Context) error {
if err := applyCancunChecks(&prestate.Env, chainConfig); err != nil {
return err
}
if err := applyEOFChecks(&prestate, chainConfig); err != nil {
return err
}
// Run the test and aggregate the result
s, result, body, err := prestate.Apply(vmConfig, chainConfig, txIt, ctx.Int64(RewardFlag.Name), getTracer)
if err != nil {
@ -285,6 +288,29 @@ func applyCancunChecks(env *stEnv, chainConfig *params.ChainConfig) error {
return nil
}
func applyEOFChecks(prestate *Prestate, chainConfig *params.ChainConfig) error {
// Sanity check pre-allocated EOF code to not panic in state transition.
if chainConfig.IsShanghai(big.NewInt(int64(prestate.Env.Number)), prestate.Env.Timestamp) {
for addr, acc := range prestate.Pre {
if vm.HasEOFByte(acc.Code) {
var (
c vm.Container
err error
)
err = c.UnmarshalBinary(acc.Code, false)
if err == nil {
jt := vm.NewPragueEOFInstructionSetForTesting()
err = c.ValidateCode(&jt, false)
}
if err != nil {
return NewError(ErrorConfig, fmt.Errorf("code at %s considered invalid: %v", addr, err))
}
}
}
}
return nil
}
type Alloc map[common.Address]types.Account
func (g Alloc) OnRoot(common.Hash) {}

@ -298,6 +298,13 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
if tracer := vmconfig.Tracer; tracer != nil && tracer.OnTxStart != nil {
tracer.OnTxStart(evm.GetVMContext(), nil, msg.From)
}
if config.IsPrague(new(big.Int), 0) {
for i := int(block.Number().Uint64() - 1); i >= 0; i-- {
core.ProcessParentBlockHash(vmTestBlockHash(uint64(i)), evm, st.StateDB)
}
}
// Execute the message.
snapshot := st.StateDB.Snapshot()
gaspool := new(core.GasPool)

Loading…
Cancel
Save