Skip to content

Commit

Permalink
Removing unused method and setting header values
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard-Voiculescu committed Oct 4, 2024
1 parent 65f117b commit 7821ea6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
45 changes: 0 additions & 45 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"io"
"io/fs"
"math/big"
"net/http"
"os"
"path/filepath"
Expand All @@ -40,7 +39,6 @@ import (
"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
tmos "github.com/cometbft/cometbft/libs/os"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -127,9 +125,6 @@ import (
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ethcommon "github.com/ethereum/go-ethereum/common"
ethhexutil "github.com/ethereum/go-ethereum/common/hexutil"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/evmos/ethermint/client/docs"

"github.com/evmos/ethermint/app/ante"
Expand Down Expand Up @@ -1112,43 +1107,3 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable())
return paramsKeeper
}

// Call this method in to OnBlockStart call
func TmBlockHeaderToEVM(
ctx sdk.Context,
block tmproto.Header,
k *evmkeeper.Keeper,
) (header *ethtypes.Header) {
number := big.NewInt(block.Height)
lastHash := ethcommon.BytesToHash(block.LastBlockId.Hash)
appHash := ethcommon.BytesToHash(block.AppHash)
txHash := ethcommon.BytesToHash(block.DataHash)
resultHash := ethcommon.BytesToHash(block.LastResultsHash)
miner := ethcommon.BytesToAddress(block.ProposerAddress)
gasLimit, gasWanted := uint64(0), uint64(0)

header = &ethtypes.Header{
Number: number,
ParentHash: lastHash,
Nonce: ethtypes.BlockNonce{}, // todo: check if this applies to injective
MixDigest: ethcommon.Hash{}, // todo: check if this applies to injective
UncleHash: ethtypes.EmptyUncleHash, // todo: check if this applies to injective
Bloom: ethtypes.Bloom{}, // k.GetBlockBloom(ctx, block.Height), // todo: check how to implement this
Root: appHash,
Coinbase: miner,
Difficulty: big.NewInt(0), // todo: check if this applies to injective
Extra: ethhexutil.Bytes{}, // todo: check if this applies to injective
GasLimit: gasLimit,
GasUsed: gasWanted,
Time: uint64(block.Time.Unix()),
TxHash: txHash,
ReceiptHash: resultHash,
BaseFee: nil, // k.GetBaseFeePerGas(ctx).RoundInt().BigInt(), // todo: check how to implement this
}

return
}

func ptr[T any](t T) *T {
return &t
}
3 changes: 2 additions & 1 deletion x/evm/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (k *Keeper) BeginBlock(ctx sdk.Context) error {
Number: big.NewInt(ctx.BlockHeight()),
Time: uint64(ctx.BlockTime().Unix()),
ParentHash: ethcommon.BytesToHash(ctx.BlockHeader().LastBlockId.Hash),
Coinbase: ethcommon.BytesToAddress(ctx.BlockHeader().ProposerAddress),
}, nil, nil, nil)

finalizedHeaderNumber := ctx.BlockHeight() - 1
Expand All @@ -50,7 +51,7 @@ func (k *Keeper) BeginBlock(ctx sdk.Context) error {

k.evmTracer.OnBlockStart(tracing.BlockEvent{
Block: b,
TD: big.NewInt(1),
TD: big.NewInt(0),
Finalized: finalizedHeader,
})
}
Expand Down

0 comments on commit 7821ea6

Please sign in to comment.