Skip to content

Commit

Permalink
Adding EndBlock tracer and using the k.evmTracer instead of the trace…
Browse files Browse the repository at this point in the history
…r from the config
  • Loading branch information
Eduard-Voiculescu committed Oct 4, 2024
1 parent 94e8033 commit 5376e54
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions x/evm/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/tracing"
"github.com/ethereum/go-ethereum/core/types"
"math/big"
Expand All @@ -32,24 +31,18 @@ func (k *Keeper) BeginBlock(ctx sdk.Context) error {
return err
}

cfg, err := k.EVMConfig(ctx, k.ChainID(), common.Hash{})
if err != nil {
return err
}

if cfg.Tracer != nil {
if k.evmTracer != nil && k.evmTracer.OnBlockStart != nil {
b := types.NewBlock(&types.Header{
Number: big.NewInt(ctx.BlockHeight()),
Time: uint64(ctx.BlockTime().Unix()),
}, nil, nil, nil)

cfg.Tracer.OnBlockStart(tracing.BlockEvent{
k.evmTracer.OnBlockStart(tracing.BlockEvent{
Block: b,
TD: big.NewInt(1),
// Finalized: , // todo: how to set up the header here?
// Safe: , // todo: how to set up the header here?
})

}

return nil
Expand All @@ -62,15 +55,11 @@ func (k *Keeper) EndBlock(ctx sdk.Context) error {
k.CollectTxBloom(ctx)
k.RemoveParamsCache(ctx)

// TODO: call EndBlock on Tracer
//config, err := k.EVMConfig(ctx, k.ChainID(), common.Hash{})
//if err != nil {
// return err
//}
//
//defer func() {
// config.Tracer.OnBlockEnd(nil)
//}()
if k.evmTracer != nil && k.evmTracer.OnBlockEnd != nil {
defer func() {
k.evmTracer.OnBlockEnd(nil)
}()
}

return nil
}

0 comments on commit 5376e54

Please sign in to comment.