Sync from fork #74

Merged
0xmuralik merged 232 commits from murali/update-fork into main 2023-01-10 04:50:57 +00:00
3 changed files with 35 additions and 35 deletions
Showing only changes of commit 0f0996432a - Show all commits

View File

@ -38,20 +38,26 @@ Ref: https://keepachangelog.com/en/1.0.0/
## Unreleased ## Unreleased
### Bug Fixes
* (rpc) [tharsis#1059](https://github.com/tharsis/ethermint/pull/1059) Remove unnecessary event filtering logic on the `eth_baseFee` JSON-RPC endpoint.
## [v0.14.0] - 2022-04-19
### API Breaking
* (evm) [tharsis#1051](https://github.com/tharsis/ethermint/pull/1051) Context block height fix on TraceTx. Removes `tx_index` on `QueryTraceTxRequest` proto type.
### Improvements ### Improvements
* (deps) [tharsis#1046](https://github.com/tharsis/ethermint/pull/1046) Bump Cosmos SDK version to [`v0.45.3`](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.3) * (deps) [tharsis#1046](https://github.com/tharsis/ethermint/pull/1046) Bump Cosmos SDK version to [`v0.45.3`](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.3)
* (rpc) [tharsis#1056](https://github.com/tharsis/ethermint/pull/1056) Make json-rpc namespaces extensible * (rpc) [tharsis#1056](https://github.com/tharsis/ethermint/pull/1056) Make json-rpc namespaces extensible
### Bug Fixes ### Bug Fixes
* (rpc) [tharsis#1050](https://github.com/tharsis/ethermint/pull/1050) `eth_getBlockByNumber` fix on batch transactions * (rpc) [tharsis#1050](https://github.com/tharsis/ethermint/pull/1050) `eth_getBlockByNumber` fix on batch transactions
* (app) [tharsis#658](https://github.com/tharsis/ethermint/issues/658) Support simulations for the EVM. * (app) [tharsis#658](https://github.com/tharsis/ethermint/issues/658) Support simulations for the EVM.
### API Breaking
* (evm) [tharsis#1051](https://github.com/tharsis/ethermint/pull/1051) Context block height fix on TraceTx. Removes `tx_index` on `QueryTraceTxRequest` proto type.
## [v0.13.0] - 2022-04-05 ## [v0.13.0] - 2022-04-05
### API Breaking ### API Breaking

View File

@ -960,7 +960,7 @@ func (e *EVMBackend) ChainConfig() *params.ChainConfig {
// mitigate the base fee changes. // mitigate the base fee changes.
func (e *EVMBackend) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) { func (e *EVMBackend) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) {
if baseFee == nil { if baseFee == nil {
// london hardfork not enabled or feemarket not enabeld // london hardfork not enabled or feemarket not enabled
return big.NewInt(0), nil return big.NewInt(0), nil
} }
@ -986,42 +986,27 @@ func (e *EVMBackend) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) {
return big.NewInt(maxDelta), nil return big.NewInt(maxDelta), nil
} }
// BaseFee returns the base fee tracked by the Fee Market module. If the base fee is not enabled, // BaseFee returns the base fee tracked by the Fee Market module.
// it returns the initial base fee amount. Return nil if London is not activated. // If the base fee is not enabled globally, the query returns nil.
// If the London hard fork is not activated at the current height, the query will
// return nil.
func (e *EVMBackend) BaseFee(height int64) (*big.Int, error) { func (e *EVMBackend) BaseFee(height int64) (*big.Int, error) {
cfg := e.ChainConfig() cfg := e.ChainConfig()
if !cfg.IsLondon(new(big.Int).SetInt64(height)) { if !cfg.IsLondon(new(big.Int).SetInt64(height)) {
return nil, nil return nil, nil
} }
// Checks the feemarket param NoBaseFee settings, return 0 if it is enabled. // return BaseFee if London hard fork is activated and feemarket is not enabled
resParams, err := e.queryClient.FeeMarket.Params(types.ContextWithHeight(height), &feemarkettypes.QueryParamsRequest{})
if err != nil {
return nil, err
}
if resParams.Params.NoBaseFee {
return big.NewInt(0), nil
}
blockRes, err := e.clientCtx.Client.BlockResults(e.ctx, &height)
if err != nil {
return nil, err
}
baseFee := types.BaseFeeFromEvents(blockRes.BeginBlockEvents)
if baseFee != nil {
return baseFee, nil
}
// If we cannot find in events, we tried to get it from the state.
// It will return feemarket.baseFee if london is activated but feemarket is not enable
res, err := e.queryClient.FeeMarket.BaseFee(types.ContextWithHeight(height), &feemarkettypes.QueryBaseFeeRequest{}) res, err := e.queryClient.FeeMarket.BaseFee(types.ContextWithHeight(height), &feemarkettypes.QueryBaseFeeRequest{})
if err == nil && res.BaseFee != nil { if err != nil {
return res.BaseFee.BigInt(), nil return nil, err
} }
if res.BaseFee == nil {
return nil, nil return nil, nil
}
return res.BaseFee.BigInt(), nil
} }
// GetEthereumMsgsFromTendermintBlock returns all real MsgEthereumTxs from a Tendermint block. // GetEthereumMsgsFromTendermintBlock returns all real MsgEthereumTxs from a Tendermint block.

View File

@ -16,19 +16,24 @@ import (
func (k Keeper) CalculateBaseFee(ctx sdk.Context) *big.Int { func (k Keeper) CalculateBaseFee(ctx sdk.Context) *big.Int {
params := k.GetParams(ctx) params := k.GetParams(ctx)
// Ignore the calculation if not enable // Ignore the calculation if not enabled
if !params.IsBaseFeeEnabled(ctx.BlockHeight()) { if !params.IsBaseFeeEnabled(ctx.BlockHeight()) {
return nil return nil
} }
consParams := ctx.ConsensusParams() consParams := ctx.ConsensusParams()
// If the current block is the first EIP-1559 block, return the InitialBaseFee. // If the current block is the first EIP-1559 block, return the base fee
// defined in the parameters (DefaultBaseFee if it hasn't been changed by
// governance).
if ctx.BlockHeight() == params.EnableHeight { if ctx.BlockHeight() == params.EnableHeight {
return params.BaseFee.BigInt() return params.BaseFee.BigInt()
} }
// get the block gas used and the base fee values for the parent block. // get the block gas used and the base fee values for the parent block.
// NOTE: this is not the parent's base fee but the current block's base fee,
// as it is retrieved from the transient store, which is committed to the
// persistent KVStore after EndBlock (ABCI Commit).
parentBaseFee := params.BaseFee.BigInt() parentBaseFee := params.BaseFee.BigInt()
if parentBaseFee == nil { if parentBaseFee == nil {
return nil return nil
@ -37,10 +42,14 @@ func (k Keeper) CalculateBaseFee(ctx sdk.Context) *big.Int {
parentGasUsed := k.GetBlockGasUsed(ctx) parentGasUsed := k.GetBlockGasUsed(ctx)
gasLimit := new(big.Int).SetUint64(math.MaxUint64) gasLimit := new(big.Int).SetUint64(math.MaxUint64)
// NOTE: a MaxGas equal to -1 means that block gas is unlimited
if consParams != nil && consParams.Block.MaxGas > -1 { if consParams != nil && consParams.Block.MaxGas > -1 {
gasLimit = big.NewInt(consParams.Block.MaxGas) gasLimit = big.NewInt(consParams.Block.MaxGas)
} }
// CONTRACT: ElasticityMultiplier cannot be 0 as it's checked in the params
// validation
parentGasTargetBig := new(big.Int).Div(gasLimit, new(big.Int).SetUint64(uint64(params.ElasticityMultiplier))) parentGasTargetBig := new(big.Int).Div(gasLimit, new(big.Int).SetUint64(uint64(params.ElasticityMultiplier)))
if !parentGasTargetBig.IsUint64() { if !parentGasTargetBig.IsUint64() {
return nil return nil