Skip to content

Commit

Permalink
refactor(evm): Remove unnecessary params: enable_call, enable_create. (
Browse files Browse the repository at this point in the history
  • Loading branch information
Unique-Divine authored Aug 9, 2024
1 parent be07667 commit b10a084
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 245 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#1985](https://github.com/NibiruChain/nibiru/pull/1985) - feat(evm)!: Use atto denomination for the wei units in the EVM so that NIBI is "ether" to clients. Only micronibi (unibi) amounts can be transferred. All clients follow the constraint equation, 1 ether == 1 NIBI == 10^6 unibi == 10^18 wei.
- [#1986](https://github.com/NibiruChain/nibiru/pull/1986) - feat(evm): Combine both account queries into "/eth.evm.v1.Query/EthAccount", accepting both nibi-prefixed Bech32 addresses and Ethereum-type hexadecimal addresses as input.
- [#1989](https://github.com/NibiruChain/nibiru/pull/1989) - refactor(evm): simplify evm module address
- [#1997](https://github.com/NibiruChain/nibiru/pull/1997) - refactor(evm): Remove unnecessary params: "enable_call", "enable_create".

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

Expand Down
15 changes: 0 additions & 15 deletions app/evmante/evmante_validate_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu

evmParams := vbd.evmKeeper.GetParams(ctx)
baseFee := vbd.evmKeeper.GetBaseFee(ctx)
enableCreate := evmParams.GetEnableCreate()
enableCall := evmParams.GetEnableCall()
evmDenom := evmParams.GetEvmDenom()

for _, msg := range protoTx.GetMsgs() {
Expand All @@ -119,19 +117,6 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
return ctx, errorsmod.Wrap(err, "failed to unpack MsgEthereumTx Data")
}

// return error if contract creation or call are disabled through governance
if !enableCreate && txData.GetTo() == nil {
return ctx, errorsmod.Wrap(
evm.ErrCreateDisabled,
"failed to create new contract",
)
} else if !enableCall && txData.GetTo() != nil {
return ctx, errorsmod.Wrap(
evm.ErrCallDisabled,
"failed to call contract",
)
}

if baseFee == nil && txData.TxType() == gethcore.DynamicFeeTxType {
return ctx, errorsmod.Wrap(
gethcore.ErrTxTypeNotSupported,
Expand Down
32 changes: 0 additions & 32 deletions app/evmante/evmante_validate_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,38 +124,6 @@ func (s *TestSuite) TestEthValidateBasicDecorator() {
},
wantErr: "tx AuthInfo SignerInfos should be empty",
},
{
name: "sad: tx for contract creation with param disabled",
paramsSetup: func(deps *evmtest.TestDeps) evm.Params {
params := evm.DefaultParams()
params.EnableCreate = false
return params
},
txSetup: func(deps *evmtest.TestDeps) sdk.Tx {
txBuilder := deps.EncCfg.TxConfig.NewTxBuilder()
tx, err := evmtest.HappyCreateContractTx(deps).BuildTx(txBuilder, eth.EthBaseDenom)
s.Require().NoError(err)
return tx
},
wantErr: "EVM Create operation is disabled",
},
{
name: "sad: tx for contract call with param disabled",
paramsSetup: func(deps *evmtest.TestDeps) evm.Params {
params := evm.DefaultParams()
params.EnableCall = false
return params
},
txSetup: func(deps *evmtest.TestDeps) sdk.Tx {
chainID := deps.Chain.EvmKeeper.EthChainID(deps.Ctx)
gasLimit := uint64(10)
to := evmtest.NewEthAccInfo().EthAddr
fees := sdk.NewCoins(sdk.NewInt64Coin("unibi", int64(gasLimit)))
msg := buildEthMsg(chainID, gasLimit, "", &to)
return buildTx(deps, true, msg, gasLimit, fees)
},
wantErr: "EVM Call operation is disabled",
},
{
name: "sad: tx without extension options should fail",
txSetup: func(deps *evmtest.TestDeps) sdk.Tx {
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 @@ -32,12 +32,11 @@ message Params {
// evm_denom represents the token denomination used to run the EVM state
// transitions.
string evm_denom = 1 [ (gogoproto.moretags) = "yaml:\"evm_denom\"" ];
// enable_create: Enables contract creation by allowing for state transitions
// that use the "vm.Create" function
bool enable_create = 2 [ (gogoproto.moretags) = "yaml:\"enable_create\"" ];
// enable_call: Enables contract calls by allowing for state transitions that
// use the "vm.Call" function
bool enable_call = 3 [ (gogoproto.moretags) = "yaml:\"enable_call\"" ];
// DEPRECATED: enable_create
reserved 2;
// DEPRECATED: enable_call
reserved 3;

// extra_eips defines the additional EIPs for the vm.Config
repeated int64 extra_eips = 4 [
(gogoproto.customname) = "ExtraEIPs",
Expand Down
8 changes: 0 additions & 8 deletions x/evm/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ const (
const (
codeErrInvalidState = uint32(iota) + 2 // NOTE: code 1 is reserved for internal errors
codeErrZeroAddress
codeErrCreateDisabled
codeErrCallDisabled
codeErrInvalidAmount
codeErrInvalidGasPrice
codeErrInvalidGasFee
Expand All @@ -43,12 +41,6 @@ var (
// ErrZeroAddress returns an error resulting from an zero (empty) ethereum Address.
ErrZeroAddress = errorsmod.Register(ModuleName, codeErrZeroAddress, "invalid zero address")

// ErrCreateDisabled returns an error if the EnableCreate parameter is false.
ErrCreateDisabled = errorsmod.Register(ModuleName, codeErrCreateDisabled, "EVM Create operation is disabled")

// ErrCallDisabled returns an error if the EnableCall parameter is false.
ErrCallDisabled = errorsmod.Register(ModuleName, codeErrCallDisabled, "EVM Call operation is disabled")

// ErrInvalidAmount returns an error if a tx contains an invalid amount.
ErrInvalidAmount = errorsmod.Register(ModuleName, codeErrInvalidAmount, "invalid transaction amount")

Expand Down
Loading

0 comments on commit b10a084

Please sign in to comment.