From fefe91bb5d697efdf4e0f3584c2c12d4aa739fb3 Mon Sep 17 00:00:00 2001 From: Piers Powlesland Date: Mon, 28 Feb 2022 19:03:29 +0000 Subject: [PATCH] Add more in depth comment on call to Prepare --- miner/worker.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/miner/worker.go b/miner/worker.go index 45e8203b10..1a7180140e 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -171,7 +171,19 @@ func (w *worker) pending() (*types.Block, *state.StateDB) { stateCopy := w.snapshotState.Copy() // Call Prepare to ensure that any access logs from the last executed // transaction have been erased. - // See https://github.com/celo-org/celo-blockchain/pull/1858#issuecomment-1054159493 + // + // Prior to the upstream PR + // https://github.com/ethereum/go-ethereum/pull/21509 the state returned + // from pending was ready to use for transaction execution, that PR + // essentially changed the contract of the pendng method, in that the + // returned state was not ready for transaction execution and required + // Prepare to be called on it first, but notably the PR did not update any + // of the callers of pending to ensure that Prepare was called. I think + // this broke some of the eth rpc apis. Calling Prepare here essentially + // restores the previous contract for this method which was that the + // returned state is ready to use for transaction execution. + // + // See https://github.com/celo-org/celo-blockchain/pull/1858#issuecomment-1054159493 for more details. stateCopy.Prepare(common.Hash{}, 0) return w.snapshotBlock, stateCopy }