Skip to content

Commit

Permalink
Merge pull request ethereum#55 from MariusVanDerWijden/test-miner-fix-2
Browse files Browse the repository at this point in the history
miner: call process withdrawal requests
  • Loading branch information
lightclient authored May 15, 2024
2 parents bad02c1 + 4a910d3 commit a45a6ef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
for _, receipt := range receipts {
allLogs = append(allLogs, receipt.Logs...)
}
requests, err := core.ParseDepositLogs(allLogs)
requests, err := core.ParseDepositLogs(allLogs, chainConfig)
if err != nil {
return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not parse requests logs: %v", err))
}
Expand Down
24 changes: 12 additions & 12 deletions core/vm/instructions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func testTwoOperandOp(t *testing.T, tests []TwoOperandTestcase, opFn executionFu
expected := new(uint256.Int).SetBytes(common.Hex2Bytes(test.Expected))
stack.push(x)
stack.push(y)
opFn(&pc, evmInterpreter, &ScopeContext{nil, stack, nil})
opFn(&pc, evmInterpreter, &ScopeContext{nil, stack, nil, nil})
if len(stack.data) != 1 {
t.Errorf("Expected one item on stack after %v, got %d: ", name, len(stack.data))
}
Expand Down Expand Up @@ -232,7 +232,7 @@ func TestAddMod(t *testing.T) {
stack.push(z)
stack.push(y)
stack.push(x)
opAddmod(&pc, evmInterpreter, &ScopeContext{nil, stack, nil})
opAddmod(&pc, evmInterpreter, &ScopeContext{nil, stack, nil, nil})
actual := stack.pop()
if actual.Cmp(expected) != 0 {
t.Errorf("Testcase %d, expected %x, got %x", i, expected, actual)
Expand All @@ -259,7 +259,7 @@ func TestWriteExpectedValues(t *testing.T) {
y := new(uint256.Int).SetBytes(common.Hex2Bytes(param.y))
stack.push(x)
stack.push(y)
opFn(&pc, interpreter, &ScopeContext{nil, stack, nil})
opFn(&pc, interpreter, &ScopeContext{nil, stack, nil, nil})
actual := stack.pop()
result[i] = TwoOperandTestcase{param.x, param.y, fmt.Sprintf("%064x", actual)}
}
Expand Down Expand Up @@ -295,7 +295,7 @@ func opBenchmark(bench *testing.B, op executionFunc, args ...string) {
var (
env = NewEVM(BlockContext{}, TxContext{}, nil, params.TestChainConfig, Config{})
stack = newstack()
scope = &ScopeContext{nil, stack, nil}
scope = &ScopeContext{nil, stack, nil, nil}
evmInterpreter = NewEVMInterpreter(env)
)

Expand Down Expand Up @@ -546,13 +546,13 @@ func TestOpMstore(t *testing.T) {
v := "abcdef00000000000000abba000000000deaf000000c0de00100000000133700"
stack.push(new(uint256.Int).SetBytes(common.Hex2Bytes(v)))
stack.push(new(uint256.Int))
opMstore(&pc, evmInterpreter, &ScopeContext{mem, stack, nil})
opMstore(&pc, evmInterpreter, &ScopeContext{mem, stack, nil, nil})
if got := common.Bytes2Hex(mem.GetCopy(0, 32)); got != v {
t.Fatalf("Mstore fail, got %v, expected %v", got, v)
}
stack.push(new(uint256.Int).SetUint64(0x1))
stack.push(new(uint256.Int))
opMstore(&pc, evmInterpreter, &ScopeContext{mem, stack, nil})
opMstore(&pc, evmInterpreter, &ScopeContext{mem, stack, nil, nil})
if common.Bytes2Hex(mem.GetCopy(0, 32)) != "0000000000000000000000000000000000000000000000000000000000000001" {
t.Fatalf("Mstore failed to overwrite previous value")
}
Expand All @@ -576,7 +576,7 @@ func BenchmarkOpMstore(bench *testing.B) {
for i := 0; i < bench.N; i++ {
stack.push(value)
stack.push(memStart)
opMstore(&pc, evmInterpreter, &ScopeContext{mem, stack, nil})
opMstore(&pc, evmInterpreter, &ScopeContext{mem, stack, nil, nil})
}
}

Expand All @@ -591,7 +591,7 @@ func TestOpTstore(t *testing.T) {
to = common.Address{1}
contractRef = contractRef{caller}
contract = NewContract(contractRef, AccountRef(to), new(uint256.Int), 0)
scopeContext = ScopeContext{mem, stack, contract}
scopeContext = ScopeContext{mem, stack, contract, nil}
value = common.Hex2Bytes("abcdef00000000000000abba000000000deaf000000c0de00100000000133700")
)

Expand Down Expand Up @@ -639,7 +639,7 @@ func BenchmarkOpKeccak256(bench *testing.B) {
for i := 0; i < bench.N; i++ {
stack.push(uint256.NewInt(32))
stack.push(start)
opKeccak256(&pc, evmInterpreter, &ScopeContext{mem, stack, nil})
opKeccak256(&pc, evmInterpreter, &ScopeContext{mem, stack, nil, nil})
}
}

Expand Down Expand Up @@ -734,7 +734,7 @@ func TestRandom(t *testing.T) {
pc = uint64(0)
evmInterpreter = env.interpreter
)
opRandom(&pc, evmInterpreter, &ScopeContext{nil, stack, nil})
opRandom(&pc, evmInterpreter, &ScopeContext{nil, stack, nil, nil})
if len(stack.data) != 1 {
t.Errorf("Expected one item on stack after %v, got %d: ", tt.name, len(stack.data))
}
Expand Down Expand Up @@ -776,7 +776,7 @@ func TestBlobHash(t *testing.T) {
evmInterpreter = env.interpreter
)
stack.push(uint256.NewInt(tt.idx))
opBlobHash(&pc, evmInterpreter, &ScopeContext{nil, stack, nil})
opBlobHash(&pc, evmInterpreter, &ScopeContext{nil, stack, nil, nil})
if len(stack.data) != 1 {
t.Errorf("Expected one item on stack after %v, got %d: ", tt.name, len(stack.data))
}
Expand Down Expand Up @@ -917,7 +917,7 @@ func TestOpMCopy(t *testing.T) {
mem.Resize(memorySize)
}
// Do the copy
opMcopy(&pc, evmInterpreter, &ScopeContext{mem, stack, nil})
opMcopy(&pc, evmInterpreter, &ScopeContext{mem, stack, nil, nil})
want := common.FromHex(strings.ReplaceAll(tc.want, " ", ""))
if have := mem.store; !bytes.Equal(want, have) {
t.Errorf("case %d: \nwant: %#x\nhave: %#x\n", i, want, have)
Expand Down
10 changes: 9 additions & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,18 @@ func (miner *Miner) generateWork(params *generateParams) *newPayloadResult {
}
// Read requests if Prague is enabled.
if miner.chainConfig.IsPrague(work.header.Number, work.header.Time) {
requests, err := core.ParseDepositLogs(allLogs, miner.chainConfig)
// Parse Deposits
requests := make([]*types.Request, 0)
reqs, err := core.ParseDepositLogs(allLogs, miner.chainConfig)
if err != nil {
return &newPayloadResult{err: err}
}
requests = append(requests, reqs...)
// Process WithdrawalRequests
context := core.NewEVMBlockContext(work.header, miner.chain, nil)
vmenv := vm.NewEVM(context, vm.TxContext{}, work.state, miner.chainConfig, vm.Config{})
wxs := core.ProcessDequeueWithdrawalRequests(vmenv, work.state)
requests = append(requests, wxs...)
body.Requests = requests
}
block, err := miner.engine.FinalizeAndAssemble(miner.chain, work.header, work.state, &body, work.receipts)
Expand Down

0 comments on commit a45a6ef

Please sign in to comment.