diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 5ee7aeb8f5..a44108c4c7 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -521,7 +521,7 @@ func (ethash *Ethash) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number)) // Header seems complete, assemble into a block and return - return types.NewBlock(header, &types.Body{Transactions: body.Transactions, Uncles: body.Uncles}, receipts, trie.NewStackTrie(nil)), nil + return types.NewBlock(header, &types.Body{Transactions: body.Transactions, Uncles: body.Uncles, Withdrawals: body.Withdrawals}, receipts, trie.NewStackTrie(nil)), nil } // SealHash returns the hash of a block prior to it being sealed. diff --git a/core/evm.go b/core/evm.go index 9ee10f7e46..4db90afe3c 100644 --- a/core/evm.go +++ b/core/evm.go @@ -150,6 +150,17 @@ func CanTransfer(db vm.StateDB, addr common.Address, amount *uint256.Int) bool { // Transfer subtracts amount from sender and adds amount to recipient using the given Db func Transfer(db vm.StateDB, sender, recipient common.Address, amount *uint256.Int) { + // get inputs before + input1 := db.GetBalance(sender) + input2 := db.GetBalance(recipient) + db.SubBalance(sender, amount, tracing.BalanceChangeTransfer) db.AddBalance(recipient, amount, tracing.BalanceChangeTransfer) + + // get outputs after + output1 := db.GetBalance(sender) + output2 := db.GetBalance(recipient) + + // add transfer log + AddTransferLog(db, sender, recipient, amount.ToBig(), input1.ToBig(), input2.ToBig(), output1.ToBig(), output2.ToBig()) } diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index 92262822ab..eff5288822 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -443,7 +443,7 @@ func newTestBackend(t *testing.T, n int, gspec *core.Genesis, engine consensus.E } ) accman, acc := newTestAccountManager(t) - gspec.Alloc[acc.Address] = types.Account{Balance: big.NewInt(params.Ether)} + // gspec.Alloc[acc.Address] = types.Account{Balance: big.NewInt(params.Ether)} // Generate blocks for testing db, blocks, _ := core.GenerateChainWithGenesis(gspec, engine, n, generator) txlookupLimit := uint64(0) diff --git a/miner/worker.go b/miner/worker.go index 650ca55a4f..32c847aa52 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1764,19 +1764,16 @@ func (w *worker) commit(ctx context.Context, env *environment, interval func(), return err } - // If we're post merge, just ignore - if !w.isTTDReached(block.Header()) { - select { - case w.taskCh <- &task{ctx: ctx, receipts: env.receipts, state: env.state, block: block, createdAt: time.Now()}: - fees := totalFees(block, env.receipts) - feesInEther := new(big.Float).Quo(new(big.Float).SetInt(fees), big.NewFloat(params.Ether)) - log.Info("Commit new sealing work", "number", block.Number(), "sealhash", w.engine.SealHash(block.Header()), - "txs", env.tcount, "gas", block.GasUsed(), "fees", feesInEther, - "elapsed", common.PrettyDuration(time.Since(start))) + select { + case w.taskCh <- &task{ctx: ctx, receipts: env.receipts, state: env.state, block: block, createdAt: time.Now()}: + fees := totalFees(block, env.receipts) + feesInEther := new(big.Float).Quo(new(big.Float).SetInt(fees), big.NewFloat(params.Ether)) + log.Info("Commit new sealing work", "number", block.Number(), "sealhash", w.engine.SealHash(block.Header()), + "txs", env.tcount, "gas", block.GasUsed(), "fees", feesInEther, + "elapsed", common.PrettyDuration(time.Since(start))) - case <-w.exitCh: - log.Info("Worker has exited") - } + case <-w.exitCh: + log.Info("Worker has exited") } } @@ -1806,13 +1803,6 @@ func (w *worker) getSealingBlock(params *generateParams) *newPayloadResult { } } -// isTTDReached returns the indicator if the given block has reached the total -// terminal difficulty for The Merge transition. -func (w *worker) isTTDReached(header *types.Header) bool { - td, ttd := w.chain.GetTd(header.ParentHash, header.Number.Uint64()-1), w.chain.Config().TerminalTotalDifficulty - return td != nil && ttd != nil && td.Cmp(ttd) >= 0 -} - // adjustResubmitInterval adjusts the resubmit interval. func (w *worker) adjustResubmitInterval(message *intervalAdjust) { select {