From 0d6a31bb4621da7cb925db41d3b4703f93a4f2b4 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 27 Dec 2022 11:26:49 +0100 Subject: [PATCH 1/3] miner: allow for extradata in post-merge blocks --- miner/worker.go | 9 ++++++--- miner/worker_test.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index e00a494d015..5a6392ab1d6 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -965,7 +965,7 @@ type generateParams struct { coinbase common.Address // The fee recipient address for including transaction random common.Hash // The randomness generated by beacon chain, empty before the merge noUncle bool // Flag whether the uncle block inclusion is allowed - noExtra bool // Flag whether the extra field assignment is allowed + limitExtra bool // Flag whether the extra field assignment is allowed noTxs bool // Flag whether an empty block without any transaction is expected } @@ -1002,7 +1002,10 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) { Coinbase: genParams.coinbase, } // Set the extra field if it's allowed. - if !genParams.noExtra && len(w.extra) != 0 { + if genParams.limitExtra && len(w.extra) > 32 { + return nil, fmt.Errorf("invalid extra data length: %v", w.extra) + } + if len(w.extra) != 0 { header.Extra = w.extra } // Set the randomness field from the beacon chain if it's available. @@ -1225,7 +1228,7 @@ func (w *worker) getSealingBlock(parent common.Hash, timestamp uint64, coinbase coinbase: coinbase, random: random, noUncle: true, - noExtra: true, + limitExtra: true, noTxs: noTxs, }, result: make(chan *newPayloadResult, 1), diff --git a/miner/worker_test.go b/miner/worker_test.go index 9c7961f7866..5db90546cec 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -568,7 +568,7 @@ func testGetSealingWork(t *testing.T, chainConfig *params.ChainConfig, engine co } _, isClique := engine.(*clique.Clique) if !isClique { - if len(block.Extra()) != 0 { + if len(block.Extra()) != 2 { t.Error("Unexpected extra field") } if block.Coinbase() != coinbase { From f5ee8ee92ccc79fc2c35fcac70d09295721ad2aa Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 27 Dec 2022 11:28:43 +0100 Subject: [PATCH 2/3] miner: nits --- miner/worker.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index 5a6392ab1d6..182de313a75 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -959,13 +959,13 @@ func (w *worker) commitTransactions(env *environment, txs *types.TransactionsByP // generateParams wraps various of settings for generating sealing task. type generateParams struct { - timestamp uint64 // The timstamp for sealing task + timestamp uint64 // The timestamp for sealing task forceTime bool // Flag whether the given timestamp is immutable or not parentHash common.Hash // Parent block hash, empty means the latest chain head coinbase common.Address // The fee recipient address for including transaction random common.Hash // The randomness generated by beacon chain, empty before the merge noUncle bool // Flag whether the uncle block inclusion is allowed - limitExtra bool // Flag whether the extra field assignment is allowed + limitExtra bool // Flag whether the extra field should be limited to 32 byte noTxs bool // Flag whether an empty block without any transaction is expected } From a835275a365794c51ea41471420ed4b1a59237ca Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 27 Dec 2022 20:30:23 +0100 Subject: [PATCH 3/3] miner: remove extradata checks --- miner/worker.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index 182de313a75..45450237fe6 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -965,7 +965,6 @@ type generateParams struct { coinbase common.Address // The fee recipient address for including transaction random common.Hash // The randomness generated by beacon chain, empty before the merge noUncle bool // Flag whether the uncle block inclusion is allowed - limitExtra bool // Flag whether the extra field should be limited to 32 byte noTxs bool // Flag whether an empty block without any transaction is expected } @@ -1001,10 +1000,7 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) { Time: timestamp, Coinbase: genParams.coinbase, } - // Set the extra field if it's allowed. - if genParams.limitExtra && len(w.extra) > 32 { - return nil, fmt.Errorf("invalid extra data length: %v", w.extra) - } + // Set the extra field. if len(w.extra) != 0 { header.Extra = w.extra } @@ -1228,7 +1224,6 @@ func (w *worker) getSealingBlock(parent common.Hash, timestamp uint64, coinbase coinbase: coinbase, random: random, noUncle: true, - limitExtra: true, noTxs: noTxs, }, result: make(chan *newPayloadResult, 1),