diff --git a/Dockerfile b/Dockerfile index 2a83820428d6..69abd2bc4230 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG VERSION="" ARG BUILDNUM="" # Build Geth in a stock Go builder container -FROM golang:1.23-alpine AS builder +FROM --platform=${BUILDPLATFORM} golang:1.23-alpine as builder RUN apk add --no-cache gcc musl-dev linux-headers git diff --git a/consensus/moonchain/consensus.go b/consensus/moonchain/consensus.go index 6a0ee4984fc1..bd1cead76192 100644 --- a/consensus/moonchain/consensus.go +++ b/consensus/moonchain/consensus.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "github.com/ethereum/go-ethereum/core/tracing" "math/big" "strings" "time" @@ -196,13 +197,17 @@ func (t *Moonchain) Prepare(chain consensus.ChainHeaderReader, header *types.Hea // // Note: The block header and state database might be updated to reflect any // consensus rules that happen at finalization (e.g. block rewards). -func (t *Moonchain) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) { +func (t *Moonchain) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body) { // no block rewards in l2 header.UncleHash = types.CalcUncleHash(nil) header.Difficulty = common.Big0 // Withdrawals processing. - for _, w := range withdrawals { - state.AddBalance(w.Address, uint256.MustFromBig(new(big.Int).SetUint64(w.Amount))) + for _, w := range body.Withdrawals { + state.AddBalance( + w.Address, + uint256.MustFromBig(new(big.Int).SetUint64(w.Amount)), + tracing.BalanceIncreaseWithdrawal, + ) } header.Root = state.IntermediateRoot(true) } @@ -212,14 +217,14 @@ func (t *Moonchain) Finalize(chain consensus.ChainHeaderReader, header *types.He // // Note: The block header and state database might be updated to reflect any // consensus rules that happen at finalization (e.g. block rewards). -func (t *Moonchain) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt, withdrawals []*types.Withdrawal) (*types.Block, error) { - if withdrawals == nil { - withdrawals = make([]*types.Withdrawal, 0) +func (t *Moonchain) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) { + if body.Withdrawals == nil { + body.Withdrawals = make([]*types.Withdrawal, 0) } // Verify anchor transaction - if len(txs) != 0 { // Transactions list might be empty when building empty payload. - isAnchor, err := t.ValidateAnchorTx(txs[0], header) + if len(body.Transactions) != 0 { // Transactions list might be empty when building empty payload. + isAnchor, err := t.ValidateAnchorTx(body.Transactions[0], header) if err != nil { return nil, err } @@ -229,10 +234,8 @@ func (t *Moonchain) FinalizeAndAssemble(chain consensus.ChainHeaderReader, heade } // Finalize block - t.Finalize(chain, header, state, txs, uncles, withdrawals) - return types.NewBlockWithWithdrawals( - header, txs, nil /* ignore uncles */, receipts, withdrawals, trie.NewStackTrie(nil), - ), nil + t.Finalize(chain, header, state, body) + return types.NewBlock(header, body, receipts, trie.NewStackTrie(nil)), nil } // Seal generates a new sealing request for the given input block and pushes diff --git a/consensus/moonchain/consensus_test.go b/consensus/moonchain/consensus_test.go index 565d813640e5..aac1e3cef39d 100644 --- a/consensus/moonchain/consensus_test.go +++ b/consensus/moonchain/consensus_test.go @@ -2,14 +2,13 @@ package moonchain_test import ( "bytes" + "github.com/ethereum/go-ethereum/consensus/moonchain" "math/big" - "strings" "testing" "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/consensus" - "github.com/ethereum/go-ethereum/consensus/taiko" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" @@ -30,7 +29,7 @@ var ( genesis *core.Genesis txs []*types.Transaction - testEngine *taiko.Taiko + testEngine *moonchain.Moonchain ) func init() { @@ -38,17 +37,9 @@ func init() { config.GrayGlacierBlock = nil config.ArrowGlacierBlock = nil config.Ethash = nil - config.Taiko = true - testEngine = taiko.New(config) - - taikoL2AddressPrefix := strings.TrimPrefix(config.ChainID.String(), "0") - - taikoL2Address := common.HexToAddress( - "0x" + - taikoL2AddressPrefix + - strings.Repeat("0", common.AddressLength*2-len(taikoL2AddressPrefix)-len(taiko.TaikoL2AddressSuffix)) + - taiko.TaikoL2AddressSuffix, - ) + config.Mxc = true + testEngine = moonchain.New(config) + moonchainL2Address := common.HexToAddress("0x1000777700000000000000000000000000000001") genesis = &core.Genesis{ Config: config, @@ -64,9 +55,9 @@ func init() { Nonce: 0, GasTipCap: common.Big0, GasFeeCap: new(big.Int).SetUint64(875_000_000), - Data: taiko.AnchorSelector, - Gas: taiko.AnchorGasLimit, - To: &taikoL2Address, + Data: moonchain.AnchorSelector, + Gas: moonchain.AnchorGasLimit, + To: &moonchainL2Address, }), types.MustSignNewTx(testKey, types.LatestSigner(genesis.Config), &types.LegacyTx{ Nonce: 0, @@ -122,7 +113,7 @@ func newTestBackend(t *testing.T) (*eth.Ethereum, []*types.Block) { t.Fatalf("can't import test blocks: %v", err) } - if _, ok := ethservice.Engine().(*taiko.Taiko); !ok { + if _, ok := ethservice.Engine().(*moonchain.Moonchain); !ok { t.Fatalf("not use taiko engine") } @@ -134,7 +125,7 @@ func generateTestChain() []*types.Block { generate := func(i int, g *core.BlockGen) { g.OffsetTime(5) - g.SetExtra([]byte("test_taiko")) + g.SetExtra([]byte("test_moonchain")) g.SetDifficulty(common.Big0) for i, tx := range txs { diff --git a/core/state_transition.go b/core/state_transition.go index 5a192844a68a..05dfc34cf593 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -497,11 +497,11 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { ) feeTreasury := new(big.Int).Sub(totalFee, feeCoinbase) if st.evm.ChainConfig().Mxc { - st.state.AddBalance(st.getMoonchainTreasuryAddress(), uint256.MustFromBig(feeTreasury)) + st.state.AddBalance(st.getMoonchainTreasuryAddress(), uint256.MustFromBig(feeTreasury), tracing.BalanceIncreaseTreasury) } else { - st.state.AddBalance(st.getTreasuryAddress(), uint256.MustFromBig(feeTreasury)) + st.state.AddBalance(st.getTreasuryAddress(), uint256.MustFromBig(feeTreasury), tracing.BalanceIncreaseTreasury) } - st.state.AddBalance(st.evm.Context.Coinbase, uint256.MustFromBig(feeCoinbase)) + st.state.AddBalance(st.evm.Context.Coinbase, uint256.MustFromBig(feeCoinbase), tracing.BalanceIncreaseBaseFeeSharing) } // add the coinbase to the witness iff the fee is greater than 0 if rules.IsEIP4762 && fee.Sign() != 0 { diff --git a/miner/payload_building.go b/miner/payload_building.go index fc394f0043d0..d47b080093e1 100644 --- a/miner/payload_building.go +++ b/miner/payload_building.go @@ -265,7 +265,7 @@ func (miner *Miner) buildPayload(args *BuildPayloadArgs, witness bool) (*Payload select { case <-timer.C: // CHANGE(moonchain): do not update payload. - if w.chainConfig.Mxc { + if miner.chainConfig.Mxc { continue } // CHANGE(taiko): do not update payload. diff --git a/params/moonchain_config.go b/params/moonchain_config.go index 07181f9a4c68..90b486fca085 100644 --- a/params/moonchain_config.go +++ b/params/moonchain_config.go @@ -17,7 +17,6 @@ var networkIDToChainConfigByMoonchain = map[*big.Int]*ChainConfig{ MoonchainGenevaNetworkID: MoonchainChainConfig, MainnetChainConfig.ChainID: MainnetChainConfig, SepoliaChainConfig.ChainID: SepoliaChainConfig, - GoerliChainConfig.ChainID: GoerliChainConfig, TestChainConfig.ChainID: TestChainConfig, NonActivatedConfig.ChainID: NonActivatedConfig, } diff --git a/params/moonchain_config_test.go b/params/moonchain_config_test.go index 2effdf8f8b27..dc6b88baf55f 100644 --- a/params/moonchain_config_test.go +++ b/params/moonchain_config_test.go @@ -31,11 +31,6 @@ func TestNetworkIDToChainConfigOrDefaultByMoonchain(t *testing.T) { SepoliaChainConfig.ChainID, SepoliaChainConfig, }, - { - "goerli", - GoerliChainConfig.ChainID, - GoerliChainConfig, - }, { "doesntExist", big.NewInt(89390218390),