Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into eip-1559
Browse files Browse the repository at this point in the history
  • Loading branch information
fedekunze authored Dec 15, 2021
2 parents ed92b57 + 50e4637 commit 4152fbd
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 38 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/clean-artifacts.yml

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

### State Machine Breaking

- (evm) [tharsis#840](https://github.com/tharsis/ethermint/pull/840) Store empty topics as empty array rather than nil.
- (feemarket) [tharsis#822](https://github.com/tharsis/ethermint/pull/822) Update EIP1559 base fee in `BeginBlock`.
- (evm) [tharsis#817](https://github.com/tharsis/ethermint/pull/817) Use `effectiveGasPrice` in ante handler, add `effectiveGasPrice` to tx receipt.

### Improvements
Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ func NewEthermintApp(
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
feemarkettypes.ModuleName,
evmtypes.ModuleName,
minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName,
Expand Down
2 changes: 1 addition & 1 deletion rpc/ethereum/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ func (e *EVMBackend) BaseFee(height int64) (*big.Int, error) {
return nil, err
}

baseFee := types.BaseFeeFromEvents(blockRes.EndBlockEvents)
baseFee := types.BaseFeeFromEvents(blockRes.BeginBlockEvents)
if baseFee != nil {
return baseFee, nil
}
Expand Down
4 changes: 2 additions & 2 deletions rpc/ethereum/namespaces/eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (api *PublicFilterAPI) NewBlockFilter() rpc.ID {
continue
}

baseFee := types.BaseFeeFromEvents(data.ResultEndBlock.Events)
baseFee := types.BaseFeeFromEvents(data.ResultBeginBlock.Events)

header := types.EthHeaderFromTendermint(data.Header, ethtypes.Bloom{}, baseFee)
api.filtersMu.Lock()
Expand Down Expand Up @@ -310,7 +310,7 @@ func (api *PublicFilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, er
continue
}

baseFee := types.BaseFeeFromEvents(data.ResultEndBlock.Events)
baseFee := types.BaseFeeFromEvents(data.ResultBeginBlock.Events)

// TODO: fetch bloom from events
header := types.EthHeaderFromTendermint(data.Header, ethtypes.Bloom{}, baseFee)
Expand Down
4 changes: 4 additions & 0 deletions x/evm/keeper/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ func (suite *KeeperTestSuite) TestAddLog() {
&ethtypes.Log{
Address: addr,
TxHash: txHash,
Topics: make([]common.Hash, 0),
},
func() {},
},
Expand All @@ -606,6 +607,7 @@ func (suite *KeeperTestSuite) TestAddLog() {
TxHash: txHash2,
TxIndex: 1,
Index: 1,
Topics: make([]common.Hash, 0),
},
func() {
suite.app.EvmKeeper.SetTxHashTransient(txHash)
Expand All @@ -624,6 +626,7 @@ func (suite *KeeperTestSuite) TestAddLog() {
&ethtypes.Log{
Address: addr,
TxHash: txHash3,
Topics: make([]common.Hash, 0),
},
func() {},
},
Expand All @@ -638,6 +641,7 @@ func (suite *KeeperTestSuite) TestAddLog() {
TxHash: txHash4,
TxIndex: 1,
Index: 1,
Topics: make([]common.Hash, 0),
},
func() {
suite.app.EvmKeeper.SetTxHashTransient(txHash)
Expand Down
12 changes: 6 additions & 6 deletions x/evm/types/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ func (log *Log) Validate() error {

// ToEthereum returns the Ethereum type Log from a Ethermint proto compatible Log.
func (log *Log) ToEthereum() *ethtypes.Log {
var topics []common.Hash // nolint: prealloc
for i := range log.Topics {
topics = append(topics, common.HexToHash(log.Topics[i]))
topics := make([]common.Hash, len(log.Topics))
for i, topic := range log.Topics {
topics[i] = common.HexToHash(topic)
}

return &ethtypes.Log{
Expand Down Expand Up @@ -108,9 +108,9 @@ func LogsToEthereum(logs []*Log) []*ethtypes.Log {

// NewLogFromEth creates a new Log instance from a Ethereum type Log.
func NewLogFromEth(log *ethtypes.Log) *Log {
var topics []string // nolint: prealloc
for _, topic := range log.Topics {
topics = append(topics, topic.String())
topics := make([]string, len(log.Topics))
for i, topic := range log.Topics {
topics[i] = topic.String()
}

return &Log{
Expand Down
4 changes: 0 additions & 4 deletions x/evm/types/tx_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ func (args *TransactionArgs) ToTransaction() *MsgEthereumTx {
maxPriorityFeePerGas = sdk.NewIntFromBigInt(args.MaxPriorityFeePerGas.ToInt())
}

if args.GasPrice != nil {
gasPrice = sdk.NewIntFromBigInt(args.GasPrice.ToInt())
}

if args.Value != nil {
value = sdk.NewIntFromBigInt(args.Value.ToInt())
}
Expand Down
11 changes: 7 additions & 4 deletions x/feemarket/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// EndBlock also retrieves the bloom filter value from the transient store and commits it to the
// KVStore. The EVM end block logic doesn't update the validator set, thus it returns
// an empty slice.
func (k *Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) {
// BeginBlock updates base fee
func (k *Keeper) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
baseFee := k.CalculateBaseFee(ctx)

// return immediately if base fee is nil
Expand All @@ -29,7 +27,12 @@ func (k *Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) {
sdk.NewAttribute(types.AttributeKeyBaseFee, baseFee.String()),
),
})
}

// EndBlock update block gas used.
// The EVM end block logic doesn't update the validator set, thus it returns
// an empty slice.
func (k *Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) {
if ctx.BlockGasMeter() == nil {
k.Logger(ctx).Error("block gas meter is nil when setting block gas used")
return
Expand Down
2 changes: 1 addition & 1 deletion x/feemarket/keeper/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// CalculateBaseFee calculates the base fee for the current block. This is only calculated once per
// block during EndBlock. If the NoBaseFee parameter is enabled or below activation height, this function returns nil.
// block during BeginBlock. If the NoBaseFee parameter is enabled or below activation height, this function returns nil.
// NOTE: This code is inspired from the go-ethereum EIP1559 implementation and adapted to Cosmos SDK-based
// chains. For the canonical code refer to: https://github.com/ethereum/go-ethereum/blob/master/consensus/misc/eip1559.go
func (k Keeper) CalculateBaseFee(ctx sdk.Context) *big.Int {
Expand Down
4 changes: 3 additions & 1 deletion x/feemarket/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
}

// BeginBlock returns the begin block for the fee market module.
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {}
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
am.keeper.BeginBlock(ctx, req)
}

// EndBlock returns the end blocker for the fee market module. It returns no validator
// updates.
Expand Down

0 comments on commit 4152fbd

Please sign in to comment.