diff --git a/w3vm/vm.go b/w3vm/vm.go index 444ef8d..4214d94 100644 --- a/w3vm/vm.go +++ b/w3vm/vm.go @@ -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, diff --git a/w3vm/vm_test.go b/w3vm/vm_test.go index 94148ce..444524c 100644 --- a/w3vm/vm_test.go +++ b/w3vm/vm_test.go @@ -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 @@ -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(), + ) + } }) } })