Skip to content

Commit

Permalink
refactor(evm)!: Refactor out dead code from the evm.Params
Browse files Browse the repository at this point in the history
  • Loading branch information
Unique-Divine committed Oct 7, 2024
1 parent 37913c4 commit 83f4cac
Show file tree
Hide file tree
Showing 19 changed files with 117 additions and 266 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#2054](https://github.com/NibiruChain/nibiru/pull/2054) - feat(evm-precompile): Precompile for one-way EVM calls to invoke/execute Wasm contracts.
- [#2060](https://github.com/NibiruChain/nibiru/pull/2060) - fix(evm-precompiles): add assertNumArgs validation
- [#2056](https://github.com/NibiruChain/nibiru/pull/2056) - feat(evm): add oracle precompile
- [#2xxx](https://github.com/NibiruChain/nibiru/pull/2xxx) - refactor(evm)!: Refactor out dead code from the evm.Params


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

Expand Down
10 changes: 6 additions & 4 deletions app/evmante/evmante_gas_consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ func (anteDec AnteDecEthGasConsume) AnteHandle(
return next(newCtx, tx, simulate)
}

evmParams := anteDec.evmKeeper.GetParams(ctx)
evmDenom := evmParams.GetEvmDenom()

var events sdk.Events

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

fees, err := keeper.VerifyFee(txData, evmDenom, baseFeeMicronibiPerGas, ctx.IsCheckTx())
fees, err := keeper.VerifyFee(
txData,
evm.EVMBankDenom,
baseFeeMicronibiPerGas,
ctx.IsCheckTx(),
)
if err != nil {
return ctx, errors.Wrapf(err, "failed to verify the fees")
}
Expand Down
2 changes: 1 addition & 1 deletion app/evmante/evmante_mempool_fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (d MempoolGasPriceDecorator) AnteHandle(
return next(ctx, tx, simulate)
}

minGasPrice := ctx.MinGasPrices().AmountOf(d.evmKeeper.GetParams(ctx).EvmDenom)
minGasPrice := ctx.MinGasPrices().AmountOf(evm.EVMBankDenom)
baseFeeMicronibi := d.evmKeeper.GetBaseFee(ctx)
baseFeeDec := math.LegacyNewDecFromBigInt(baseFeeMicronibi)

Expand Down
3 changes: 1 addition & 2 deletions app/evmante/evmante_sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func (esvd EthSigVerificationDecorator) AnteHandle(
ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler,
) (newCtx sdk.Context, err error) {
chainID := esvd.evmKeeper.EthChainID(ctx)
evmParams := esvd.evmKeeper.GetParams(ctx)
ethCfg := evm.EthereumConfig(chainID)
blockNum := big.NewInt(ctx.BlockHeight())
signer := gethcore.MakeSigner(ethCfg, blockNum)
Expand All @@ -48,7 +47,7 @@ func (esvd EthSigVerificationDecorator) AnteHandle(
)
}

allowUnprotectedTxs := evmParams.GetAllowUnprotectedTxs()
allowUnprotectedTxs := false
ethTx := msgEthTx.AsTransaction()
if !allowUnprotectedTxs && !ethTx.Protected() {
return ctx, errors.Wrapf(
Expand Down
4 changes: 1 addition & 3 deletions app/evmante/evmante_validate_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
txFee := sdk.Coins{}
txGasLimit := uint64(0)

evmParams := vbd.evmKeeper.GetParams(ctx)
baseFee := vbd.evmKeeper.GetBaseFee(ctx)
evmDenom := evmParams.GetEvmDenom()

for _, msg := range protoTx.GetMsgs() {
msgEthTx, ok := msg.(*evm.MsgEthereumTx)
Expand Down Expand Up @@ -126,7 +124,7 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu

txFee = txFee.Add(
sdk.Coin{
Denom: evmDenom,
Denom: evm.EVMBankDenom,
Amount: sdkmath.NewIntFromBigInt(txData.Fee()),
},
)
Expand Down
2 changes: 1 addition & 1 deletion eth/eip712/eip712_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestEIP712TestSuite(t *testing.T) {
func (suite *EIP712TestSuite) SetupTest() {
suite.config = encoding.MakeConfig(app.ModuleBasics)
suite.clientCtx = client.Context{}.WithTxConfig(suite.config.TxConfig)
suite.denom = evm.DefaultEVMDenom
suite.denom = evm.EVMBankDenom

sdk.GetConfig().SetBech32PrefixForAccount(appconst.AccountAddressPrefix, "")
eip712.SetEncodingConfig(suite.config)
Expand Down
9 changes: 1 addition & 8 deletions eth/rpc/backend/call_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,7 @@ func (b *Backend) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) {
return common.Hash{}, err
}

// Query params to use the EVM denomination
res, err := b.queryClient.QueryClient.Params(b.ctx, &evm.QueryParamsRequest{})
if err != nil {
b.logger.Error("failed to query evm params", "error", err.Error())
return common.Hash{}, err
}

cosmosTx, err := ethereumTx.BuildTx(b.clientCtx.TxConfig.NewTxBuilder(), res.Params.EvmDenom)
cosmosTx, err := ethereumTx.BuildTx(b.clientCtx.TxConfig.NewTxBuilder(), evm.EVMBankDenom)
if err != nil {
b.logger.Error("failed to build cosmos tx", "error", err.Error())
return common.Hash{}, err
Expand Down
7 changes: 1 addition & 6 deletions eth/rpc/backend/node_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,8 @@ func (b *Backend) RPCBlockRangeCap() int32 {
// RPCMinGasPrice returns the minimum gas price for a transaction obtained from
// the node config. If set value is 0, it will default to 20.
func (b *Backend) RPCMinGasPrice() int64 {
evmParams, err := b.queryClient.Params(b.ctx, &evm.QueryParamsRequest{})
if err != nil {
return eth.DefaultGasPrice
}

minGasPrice := b.cfg.GetMinGasPrices()
amt := minGasPrice.AmountOf(evmParams.Params.EvmDenom).TruncateInt64()
amt := minGasPrice.AmountOf(evm.EVMBankDenom).TruncateInt64()
if amt == 0 {
return eth.DefaultGasPrice
}
Expand Down
3 changes: 1 addition & 2 deletions eth/rpc/rpcapi/eth_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ func (s *NodeSuite) Test_SimpleTransferTransaction() {
pendingEthTxEventIndex := int32(-1)
for _, event := range events {
if event.Type == evm.PendingEthereumTxEvent {
pendingEthTxEventHash, pendingEthTxEventIndex, err =
evm.GetEthHashAndIndexFromPendingEthereumTxEvent(event)
pendingEthTxEventHash, pendingEthTxEventIndex, err = evm.GetEthHashAndIndexFromPendingEthereumTxEvent(event)
s.Require().NoError(err)
}
if event.Type == evm.TypeUrlEventEthereumTx {
Expand Down
11 changes: 5 additions & 6 deletions proto/eth/evm/v1/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ message FunToken {
// Params defines the EVM module parameters
message Params {

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

View workflow job for this annotation

GitHub Actions / break-check

Previously present field "1" with name "evm_denom" on message "Params" was deleted.

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

View workflow job for this annotation

GitHub Actions / break-check

Previously present field "6" with name "allow_unprotected_txs" on message "Params" was deleted.
option (gogoproto.equal) = true;
// evm_denom represents the token denomination used to run the EVM state
// transitions.
string evm_denom = 1 [ (gogoproto.moretags) = "yaml:\"evm_denom\"" ];
// DEPRECATED: evm_denom
reserved 1;
// DEPRECATED: enable_create
reserved 2;
// DEPRECATED: enable_call
Expand All @@ -44,9 +43,9 @@ message Params {
];
// 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;
// DEPRECATED: allow_unprotected_txs
reserved 6;

// DEPRECATED: active_precompiles
// All precompiles present according to the VM are active.
reserved 7;
Expand Down
Loading

0 comments on commit 83f4cac

Please sign in to comment.