Skip to content

Commit b84907b

Browse files
authored
Merge pull request ethereum#437 from ethereum-optimism/fix-post-validation-call
core: fix call to post-validation evm message hook
2 parents 717daa1 + da595e3 commit b84907b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

core/state_transition.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ type Message struct {
155155
Mint *big.Int // Mint is the amount to mint before EVM processing, or nil if there is no minting.
156156
RollupCostData types.RollupCostData // RollupCostData caches data to compute the fee we charge for data availability
157157

158+
// PostValidation is an optional check of the resulting post-state, if and when the message is
159+
// applied fully to the EVM. This function may return an error to deny inclusion of the message.
158160
PostValidation func(evm *vm.EVM, result *ExecutionResult) error
159161
}
160162

@@ -450,7 +452,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
450452
err = nil
451453
}
452454

453-
if st.msg.PostValidation != nil {
455+
if err == nil && st.msg.PostValidation != nil {
454456
if err := st.msg.PostValidation(st.evm, result); err != nil {
455457
return nil, err
456458
}

miner/miner_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ func TestRejectedConditionalTx(t *testing.T) {
188188
})
189189
tx.SetConditional(&types.TransactionConditional{TimestampMax: uint64Ptr(timestamp - 1)})
190190

191-
// 1 pending tx
192-
miner.txpool.Add(types.Transactions{tx}, true, false)
191+
// 1 pending tx (synchronously, it has to be there before it can be rejected)
192+
miner.txpool.Add(types.Transactions{tx}, true, true)
193193
if !miner.txpool.Has(tx.Hash()) {
194194
t.Fatalf("conditional tx is not in the mempool")
195195
}

0 commit comments

Comments
 (0)