Skip to content

Commit

Permalink
w3vm: fix tx coinbase tip (#207)
Browse files Browse the repository at this point in the history
* added blob test

* update test

* fix

---------

Co-authored-by: lmittmann <[email protected]>
  • Loading branch information
lmittmann and lmittmann authored Jan 10, 2025
1 parent 788439c commit 76734e4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion w3vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (v *VM) buildMessage(msg *w3types.Message, skipAccChecks bool) (*core.Messa
GasLimit: gasLimit,
GasPrice: gasPrice,
GasFeeCap: gasFeeCap,
GasTipCap: gasFeeCap,
GasTipCap: gasTipCap,
Data: input,
AccessList: msg.AccessList,
BlobGasFeeCap: msg.BlobGasFeeCap,
Expand Down
23 changes: 23 additions & 0 deletions w3vm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ func TestVMApply_Integration(t *testing.T) {
t.Run(blockNumber.String(), func(t *testing.T) {
t.Parallel()

// fetch block
var (
block *types.Block
receipts types.Receipts
Expand Down Expand Up @@ -758,6 +759,28 @@ func TestVMApply_Integration(t *testing.T) {
t.Fatalf("[%v,%d,%s] (-want +got)\n%s", block.Number(), j, tx.Hash(), diff)
}
}

// check coinbase balance at the end of the block
if !params.MainnetChainConfig.IsShanghai(block.Number(), block.Time()) {
return // only check postmerge blocks for correct coinbase balance
}

var wantCoinbaseBal *big.Int
if err := client.Call(
eth.Balance(block.Coinbase(), block.Number()).Returns(&wantCoinbaseBal),
); err != nil {
t.Fatalf("Failed to fetch coinbase balance: %v", err)
}

// actual coinbase balance after all txs were applied
gotCoinbaseBal, _ := vm.Balance(block.Coinbase())
if wantCoinbaseBal.Cmp(gotCoinbaseBal) != 0 {
t.Fatalf("Coinbase balance: want: %s, got: %s (%s)",
w3.FromWei(wantCoinbaseBal, 18),
w3.FromWei(gotCoinbaseBal, 18),
block.Coinbase(),
)
}
})
}
})
Expand Down

0 comments on commit 76734e4

Please sign in to comment.