Skip to content

Commit

Permalink
chore(evm): simplified config by removing old eth forks (#1911)
Browse files Browse the repository at this point in the history
* chore(evm): simplified config by removing old eth forks

* chore: changelog update

* chore(evm): removed chain_config proto
  • Loading branch information
onikonychev authored Jun 7, 2024
1 parent 957c7b2 commit 359e310
Show file tree
Hide file tree
Showing 19 changed files with 263 additions and 2,321 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#1901](https://github.com/NibiruChain/nibiru/pull/1901) - test(evm): more e2e test contracts for edge cases
- [#1907](https://github.com/NibiruChain/nibiru/pull/1907) - test(evm): grpc_query full coverage
- [#1909](https://github.com/NibiruChain/nibiru/pull/1909) - chore(evm): set is_london true by default and removed from config
- [#1911](https://github.com/NibiruChain/nibiru/pull/1911) - chore(evm): simplified config by removing old eth forks

#### Dapp modules: perp, spot, oracle, etc

Expand Down
9 changes: 2 additions & 7 deletions app/evmante_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,7 @@ func (anteDec AnteDecEthGasConsume) AnteHandle(

evmParams := anteDec.EvmKeeper.GetParams(ctx)
evmDenom := evmParams.GetEvmDenom()
chainCfg := evmParams.GetChainConfig()
ethCfg := chainCfg.EthereumConfig(anteDec.EvmKeeper.EthChainID(ctx))

blockHeight := big.NewInt(ctx.BlockHeight())
homestead := ethCfg.IsHomestead(blockHeight)
istanbul := ethCfg.IsIstanbul(blockHeight)
var events sdk.Events

// Use the lowest priority of all the messages as the final one.
Expand Down Expand Up @@ -186,7 +181,7 @@ func (anteDec AnteDecEthGasConsume) AnteHandle(
gasWanted += txData.GetGas()
}

fees, err := keeper.VerifyFee(txData, evmDenom, baseFee, homestead, istanbul, ctx.IsCheckTx())
fees, err := keeper.VerifyFee(txData, evmDenom, baseFee, ctx.IsCheckTx())
if err != nil {
return ctx, errors.Wrapf(err, "failed to verify the fees")
}
Expand Down Expand Up @@ -275,7 +270,7 @@ func (ctd CanTransferDecorator) AnteHandle(
ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler,
) (sdk.Context, error) {
params := ctd.EvmKeeper.GetParams(ctx)
ethCfg := params.ChainConfig.EthereumConfig(ctd.EvmKeeper.EthChainID(ctx))
ethCfg := evm.EthereumConfig(ctd.EvmKeeper.EthChainID(ctx))
signer := gethcore.MakeSigner(ethCfg, big.NewInt(ctx.BlockHeight()))

for _, msg := range tx.GetMsgs() {
Expand Down
3 changes: 1 addition & 2 deletions app/evmante_sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ func (esvd EthSigVerificationDecorator) AnteHandle(
) (newCtx sdk.Context, err error) {
chainID := esvd.EvmKeeper.EthChainID(ctx)
evmParams := esvd.EvmKeeper.GetParams(ctx)
chainCfg := evmParams.GetChainConfig()
ethCfg := chainCfg.EthereumConfig(chainID)
ethCfg := evm.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
signer := gethcore.MakeSigner(ethCfg, blockNum)

Expand Down
2 changes: 1 addition & 1 deletion eth/rpc/backend/call_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (b *Backend) Resend(args evm.JsonTxArgs, gasPrice *hexutil.Big, gasLimit *h

cfg := b.ChainConfig()
if cfg == nil {
cfg = evm.DefaultChainConfig().EthereumConfig(eip155ChainID)
cfg = evm.EthereumConfig(eip155ChainID)
}

signer := gethcore.LatestSigner(cfg)
Expand Down
4 changes: 2 additions & 2 deletions eth/rpc/backend/chain_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func (b *Backend) ChainID() (*hexutil.Big, error) {

// ChainConfig returns the latest ethereum chain configuration
func (b *Backend) ChainConfig() *params.ChainConfig {
params, err := b.queryClient.Params(b.ctx, &evm.QueryParamsRequest{})
_, err := b.queryClient.Params(b.ctx, &evm.QueryParamsRequest{})
if err != nil {
return nil
}

return params.Params.ChainConfig.EthereumConfig(b.chainID)
return evm.EthereumConfig(b.chainID)
}

// BaseFee returns the base fee tracked by the Fee Market module.
Expand Down
4 changes: 2 additions & 2 deletions eth/rpc/backend/chain_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *BackendSuite) TestBaseFee() {
expPass: true,
},
{
name: "pass - base fee or london fork not enabled",
name: "pass - base fee not enabled",
blockRes: &tmrpctypes.ResultBlockResults{Height: 1},
registerMock: func() {
queryClient := s.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
Expand Down Expand Up @@ -202,7 +202,7 @@ func (s *BackendSuite) TestSuggestGasTipCap() {
expPass bool
}{
{
"pass - London hardfork not enabled or feemarket not enabled ",
"pass - Feemarket not enabled ",
func() {},
nil,
big.NewInt(0),
Expand Down
89 changes: 4 additions & 85 deletions proto/eth/evm/v1/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ message Params {
bool enable_call = 3 [(gogoproto.moretags) = "yaml:\"enable_call\""];
// extra_eips defines the additional EIPs for the vm.Config
repeated int64 extra_eips = 4 [(gogoproto.customname) = "ExtraEIPs", (gogoproto.moretags) = "yaml:\"extra_eips\""];
// chain_config defines the EVM chain configuration parameters
ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false];
// DEPRECATED: chain_config
reserved 5;
// allow_unprotected_txs defines if replay-protected (i.e non EIP155
// signed) transactions can be executed on the state machine.
bool allow_unprotected_txs = 6;
Expand All @@ -30,87 +30,6 @@ message Params {
repeated string evm_channels = 8 [(gogoproto.customname) = "EVMChannels"];
}

// ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int values
// instead of *big.Int.
message ChainConfig {
option (gogoproto.equal) = true;
// homestead_block switch (nil no fork, 0 = already homestead)
string homestead_block = 1
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"homestead_block\""];
// dao_fork_block corresponds to TheDAO hard-fork switch block (nil no fork)
string dao_fork_block = 2 [
(gogoproto.customname) = "DAOForkBlock",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"dao_fork_block\""
];
// dao_fork_support defines whether the nodes supports or opposes the DAO hard-fork
bool dao_fork_support = 3
[(gogoproto.customname) = "DAOForkSupport", (gogoproto.moretags) = "yaml:\"dao_fork_support\""];
// eip150_block: EIP150 implements the Gas price changes
// (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (nil no fork)
string eip150_block = 4 [
(gogoproto.customname) = "EIP150Block",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"eip150_block\""
];
// eip150_hash: EIP150 HF hash (needed for header only clients as only gas pricing changed)
string eip150_hash = 5 [(gogoproto.customname) = "EIP150Hash", (gogoproto.moretags) = "yaml:\"byzantium_block\""];
// eip155_block: EIP155Block HF block
string eip155_block = 6 [
(gogoproto.customname) = "EIP155Block",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"eip155_block\""
];
// eip158_block: EIP158 HF block
string eip158_block = 7 [
(gogoproto.customname) = "EIP158Block",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"eip158_block\""
];
// byzantium_block: Byzantium switch block (nil no fork, 0 = already on byzantium)
string byzantium_block = 8
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"byzantium_block\""];
// constantinople_block: Constantinople switch block (nil no fork, 0 = already activated)
string constantinople_block = 9
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"constantinople_block\""];
// petersburg_block: Petersburg switch block (nil same as Constantinople)
string petersburg_block = 10
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"petersburg_block\""];
// istanbul_block: Istanbul switch block (nil no fork, 0 = already on istanbul)
string istanbul_block = 11
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"istanbul_block\""];
// muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no fork, 0 = already activated)
string muir_glacier_block = 12
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"muir_glacier_block\""];
// berlin_block: Berlin switch block (nil = no fork, 0 = already on berlin)
string berlin_block = 13
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"berlin_block\""];
// DEPRECATED: EWASM, YOLOV3 and Catalyst block have been deprecated
reserved 14, 15, 16;
reserved "yolo_v3_block", "ewasm_block", "catalyst_block";
// london_block: London switch block (nil = no fork, 0 = already on london)
string london_block = 17
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"london_block\""];
// arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
string arrow_glacier_block = 18
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"arrow_glacier_block\""];
// DEPRECATED: merge fork block was deprecated: https://github.com/ethereum/go-ethereum/pull/24904
reserved 19;
reserved "merge_fork_block";
// gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = no fork, 0 = already activated)
string gray_glacier_block = 20
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"gray_glacier_block\""];
// merge_netsplit_block: Virtual fork after The Merge to use as a network splitter
string merge_netsplit_block = 21
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"merge_netsplit_block\""];
// shanghai_block switch block (nil = no fork, 0 = already on shanghai)
string shanghai_block = 22
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"shanghai_block\""];
// cancun_block switch block (nil = no fork, 0 = already on cancun)
string cancun_block = 23
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"cancun_block\""];
}

// State represents a single Storage key value pair item.
message State {
// key is the stored key
Expand Down Expand Up @@ -213,8 +132,8 @@ message TraceConfig {
bool debug = 8;
// limit defines the maximum length of output, but zero means unlimited
int32 limit = 9;
// overrides can be used to execute a trace using future fork rules
ChainConfig overrides = 10;
// DEPRECATED: chain_config
reserved 10;
// enable_memory switches memory capture
bool enable_memory = 11 [(gogoproto.jsontag) = "enableMemory"];
// enable_return_data switches the capture of return data
Expand Down
2 changes: 1 addition & 1 deletion proto/eth/evm/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ service Query {
}

// BaseFee queries the base fee of the parent block of the current block,
// it's similar to feemarket module's method, but also checks london hardfork status.
// Similar to feemarket module's method
rpc BaseFee(QueryBaseFeeRequest) returns (QueryBaseFeeResponse) {
option (google.api.http).get = "/nibiru/evm/v1/base_fee";
}
Expand Down
Loading

0 comments on commit 359e310

Please sign in to comment.