evm: allow to append logs after a post processing hook (#1025)
* add log after tx post processing hook add changelog fix tests rename variable minimum change version * Update x/evm/keeper/state_transition.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
parent
7d11c93992
commit
56c4a31f10
@ -47,6 +47,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
|
|
||||||
* (feemarket) [tharsis#1021](https://github.com/tharsis/ethermint/pull/1021) Fix fee market migration.
|
* (feemarket) [tharsis#1021](https://github.com/tharsis/ethermint/pull/1021) Fix fee market migration.
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* (evm) [tharsis#1025](https://github.com/tharsis/ethermint/pull/1025) Allow to append logs after a post processing hook.
|
||||||
|
|
||||||
## [v0.12.1] - 2022-03-29
|
## [v0.12.1] - 2022-03-29
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
@ -235,7 +235,6 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
|
|||||||
bloomReceipt = ethtypes.BytesToBloom(bloom.Bytes())
|
bloomReceipt = ethtypes.BytesToBloom(bloom.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
if !res.Failed() {
|
|
||||||
cumulativeGasUsed := res.GasUsed
|
cumulativeGasUsed := res.GasUsed
|
||||||
if ctx.BlockGasMeter() != nil {
|
if ctx.BlockGasMeter() != nil {
|
||||||
limit := ctx.BlockGasMeter().Limit()
|
limit := ctx.BlockGasMeter().Limit()
|
||||||
@ -251,7 +250,6 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
|
|||||||
receipt := ðtypes.Receipt{
|
receipt := ðtypes.Receipt{
|
||||||
Type: tx.Type(),
|
Type: tx.Type(),
|
||||||
PostState: nil, // TODO: intermediate state root
|
PostState: nil, // TODO: intermediate state root
|
||||||
Status: ethtypes.ReceiptStatusSuccessful,
|
|
||||||
CumulativeGasUsed: cumulativeGasUsed,
|
CumulativeGasUsed: cumulativeGasUsed,
|
||||||
Bloom: bloomReceipt,
|
Bloom: bloomReceipt,
|
||||||
Logs: logs,
|
Logs: logs,
|
||||||
@ -263,6 +261,8 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
|
|||||||
TransactionIndex: txConfig.TxIndex,
|
TransactionIndex: txConfig.TxIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !res.Failed() {
|
||||||
|
receipt.Status = ethtypes.ReceiptStatusSuccessful
|
||||||
// Only call hooks if tx executed successfully.
|
// Only call hooks if tx executed successfully.
|
||||||
if err = k.PostTxProcessing(tmpCtx, msg, receipt); err != nil {
|
if err = k.PostTxProcessing(tmpCtx, msg, receipt); err != nil {
|
||||||
// If hooks return error, revert the whole tx.
|
// If hooks return error, revert the whole tx.
|
||||||
@ -280,11 +280,10 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
|
|||||||
return nil, sdkerrors.Wrapf(err, "failed to refund gas leftover gas to sender %s", msg.From())
|
return nil, sdkerrors.Wrapf(err, "failed to refund gas leftover gas to sender %s", msg.From())
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(logs) > 0 {
|
if len(receipt.Logs) > 0 {
|
||||||
// Update transient block bloom filter
|
// Update transient block bloom filter
|
||||||
k.SetBlockBloomTransient(ctx, bloom)
|
k.SetBlockBloomTransient(ctx, receipt.Bloom.Big())
|
||||||
|
k.SetLogSizeTransient(ctx, uint64(txConfig.LogIndex)+uint64(len(receipt.Logs)))
|
||||||
k.SetLogSizeTransient(ctx, uint64(txConfig.LogIndex)+uint64(len(logs)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
k.SetTxIndexTransient(ctx, uint64(txConfig.TxIndex)+1)
|
k.SetTxIndexTransient(ctx, uint64(txConfig.TxIndex)+1)
|
||||||
|
Loading…
Reference in New Issue
Block a user