Skip to content

Commit

Permalink
Merge pull request #437 from ethereum-optimism/fix-post-validation-call
Browse files Browse the repository at this point in the history
core: fix call to post-validation evm message hook
  • Loading branch information
axelKingsley authored Nov 26, 2024
2 parents 717daa1 + da595e3 commit b84907b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ type Message struct {
Mint *big.Int // Mint is the amount to mint before EVM processing, or nil if there is no minting.
RollupCostData types.RollupCostData // RollupCostData caches data to compute the fee we charge for data availability

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

Expand Down Expand Up @@ -450,7 +452,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
err = nil
}

if st.msg.PostValidation != nil {
if err == nil && st.msg.PostValidation != nil {
if err := st.msg.PostValidation(st.evm, result); err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions miner/miner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ func TestRejectedConditionalTx(t *testing.T) {
})
tx.SetConditional(&types.TransactionConditional{TimestampMax: uint64Ptr(timestamp - 1)})

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

0 comments on commit b84907b

Please sign in to comment.