Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(evm): simplified config by removing old eth forks #1911

Merged
merged 4 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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 @@
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 @@
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))

Check warning on line 273 in app/evmante_eth.go

View check run for this annotation

Codecov / codecov/patch

app/evmante_eth.go#L273

Added line #L273 was not covered by tests
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 @@
) (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)

Check warning on line 37 in app/evmante_sigverify.go

View check run for this annotation

Codecov / codecov/patch

app/evmante_sigverify.go#L37

Added line #L37 was not covered by tests
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 @@

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

Check warning on line 48 in eth/rpc/backend/call_tx.go

View check run for this annotation

Codecov / codecov/patch

eth/rpc/backend/call_tx.go#L48

Added line #L48 was not covered by tests
}

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
@@ -1,4 +1,4 @@
// Copyright (c) 2023-2024 Nibi, Inc.

Check failure on line 1 in proto/eth/evm/v1/evm.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present message "ChainConfig" was deleted from file.
syntax = "proto3";
package eth.evm.v1;

Expand All @@ -7,7 +7,7 @@
option go_package = "github.com/NibiruChain/nibiru/x/evm";

// Params defines the EVM module parameters
message Params {

Check failure on line 10 in proto/eth/evm/v1/evm.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present field "5" with name "chain_config" on message "Params" was deleted.
option (gogoproto.equal) = true;
// evm_denom represents the token denomination used to run the EVM state
// transitions.
Expand All @@ -18,8 +18,8 @@
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 @@
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 @@ -192,7 +111,7 @@
}

// TraceConfig holds extra parameters to trace functions.
message TraceConfig {

Check failure on line 114 in proto/eth/evm/v1/evm.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present field "10" with name "overrides" on message "TraceConfig" was deleted.
// DEPRECATED: DisableMemory and DisableReturnData have been renamed to
// Enable*.
reserved 4, 7;
Expand All @@ -213,8 +132,8 @@
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
Loading