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: remove claims mod & migrate EVMChannels param to evm params #2084

Merged
merged 28 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b5e73df
add params to evm
GAtom22 Nov 27, 2023
3ecd9e8
gen proto
GAtom22 Nov 27, 2023
4648e92
chore: migrate claims params to evm
GAtom22 Nov 27, 2023
38e7b89
add changelog entry
GAtom22 Nov 27, 2023
341918e
fix test
GAtom22 Nov 27, 2023
96b5389
remove unused functions
GAtom22 Nov 27, 2023
39ed044
address go.mod warning
GAtom22 Nov 27, 2023
778b2c6
Merge branch 'main' into GAtom22/migrate-params
GAtom22 Nov 27, 2023
4afbd38
remove deprecated authorized channels param
GAtom22 Nov 28, 2023
ae70865
Merge branch 'GAtom22/migrate-params' of https://github.com/evmos/evm…
GAtom22 Nov 28, 2023
6d87b40
Merge branch 'main' into GAtom22/migrate-params
GAtom22 Nov 28, 2023
cbcf895
add evm store migration
GAtom22 Nov 28, 2023
d87cabf
make format
GAtom22 Nov 28, 2023
38f7b6a
Merge branch 'main' into GAtom22/migrate-params
GAtom22 Nov 28, 2023
e393c90
Revert "remove unused functions"
GAtom22 Nov 28, 2023
834ea69
fix lint issues
GAtom22 Nov 28, 2023
80a8d46
update exp gas values
GAtom22 Nov 28, 2023
dce68b7
fix type registration
GAtom22 Nov 28, 2023
bc4232a
add IsEVMChannel func
GAtom22 Nov 28, 2023
8c16f35
remove claims module
GAtom22 Nov 28, 2023
563f85b
update changelog
GAtom22 Nov 28, 2023
4aa0ef4
remove claims proto
GAtom22 Nov 28, 2023
7b4f66a
Merge branch 'main' into GAtom22/migrate-params
GAtom22 Nov 28, 2023
ebbc438
update lic
GAtom22 Nov 28, 2023
eb25de6
Merge branch 'main' into GAtom22/migrate-params
0xstepit Nov 29, 2023
3bfa880
Merge branch 'main' into GAtom22/migrate-params
fedekunze Nov 29, 2023
80abb67
address review comments
GAtom22 Nov 29, 2023
8f4c058
Merge branch 'main' into GAtom22/migrate-params
GAtom22 Nov 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (werc20) [#2074](https://github.com/evmos/evmos/pull/2074) Add `werc20` EVM Extension acceptance tests with `WEVMOS` contract.
- (erc20) [#2075](https://github.com/evmos/evmos/pull/2075) Align allowance adjustment errors with ERC20 contracts.
- (erc20) [#2080](https://github.com/evmos/evmos/pull/2080) Add ERC20 integration test setup.
- (evm) [#2084](https://github.com/evmos/evmos/pull/2084) Migrate `x/claims` params to the `x/evm` module params.

### Bug Fixes

Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,7 @@ func (app *Evmos) setupUpgradeHandlers() {
v16.CreateUpgradeHandler(
app.mm, app.configurator,
app.EvmKeeper,
app.ClaimsKeeper,
),
)

Expand Down
14 changes: 14 additions & 0 deletions app/upgrades/v16/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/evmos/evmos/v15/precompiles/p256"
"github.com/evmos/evmos/v15/utils"
claimskeeper "github.com/evmos/evmos/v15/x/claims/keeper"
evmkeeper "github.com/evmos/evmos/v15/x/evm/keeper"
)

Expand All @@ -16,6 +17,7 @@ func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
ek *evmkeeper.Keeper,
ck *claimskeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)
Expand All @@ -28,6 +30,18 @@ func CreateUpgradeHandler(
}
}

// Step #1 to deprecate claims module:
// migrate (desired) params
claimsParams := ck.GetParams(ctx)
evmParams := ek.GetParams(ctx)

evmParams.AuthorizedChannels = claimsParams.AuthorizedChannels
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
evmParams.EVMChannels = claimsParams.EVMChannels

if err := ek.SetParams(ctx, evmParams); err != nil {
logger.Error("failed to migrate AuthorizedChannels and EVMChannels params", "error", err.Error())
}

// recovery module is deprecated since it is renamed to "revenue" module
logger.Debug("deleting recovery module from version map...")
delete(vm, "recovery")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
github.com/btcsuite/btcd/btcutil v1.1.3
github.com/cometbft/cometbft v0.37.3-0.20230920093934-46df7b597e3c
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/btcutil v1.0.5
github.com/cosmos/cosmos-proto v1.0.0-beta.3
github.com/cosmos/cosmos-sdk v0.47.5
github.com/cosmos/go-bip39 v1.0.0
Expand Down Expand Up @@ -92,6 +91,7 @@ require (
github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect
github.com/confio/ics23/go v0.9.0 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v0.21.0-alpha.1.0.20230904092046-df3db2d96583 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
Expand Down
89 changes: 0 additions & 89 deletions precompiles/erc20/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,6 @@ func (s *PrecompileTestSuite) setupSendAuthz(
s.Require().NoError(err, "failed to set up send authorization")
}

func (is *IntegrationTestSuite) setupSendAuthz(
grantee sdk.AccAddress, granterPriv cryptotypes.PrivKey, amount sdk.Coins,
) {
err := setupSendAuthz(
is.network,
is.factory,
grantee,
granterPriv,
amount,
)
Expect(err).ToNot(HaveOccurred(), "failed to set up send authorization")
}

func setupSendAuthz(
network commonnetwork.Network,
factory commonfactory.TxFactory,
Expand Down Expand Up @@ -92,54 +79,6 @@ func setupSendAuthz(
return nil
}

// setupSendAuthzForContract is a helper function which executes an approval
// for the given contract data.
//
// If:
// - the classic ERC20 contract is used, it calls the `approve` method on the contract.
// - in other cases, it sends a `MsgGrant` to set up the authorization.
func (is *IntegrationTestSuite) setupSendAuthzForContract(
callType CallType, contractData ContractsData, grantee common.Address, granterPriv cryptotypes.PrivKey, amount sdk.Coins,
) {
Expect(amount).To(HaveLen(1), "expected only one coin")
Expect(amount[0].Denom).To(Equal(is.tokenDenom),
"this test utility only works with the token denom in the context of these integration tests",
)

switch {
case slices.Contains(nativeCallTypes, callType):
is.setupSendAuthz(grantee.Bytes(), granterPriv, amount)
case slices.Contains(erc20CallTypes, callType):
is.setupSendAuthzForERC20(callType, contractData, grantee, granterPriv, amount)
default:
panic("unknown contract call type")
}
}

// setupSendAuthzForERC20 is a helper function to set up a SendAuthorization for
// a given grantee and granter combination for a given amount.
func (is *IntegrationTestSuite) setupSendAuthzForERC20(
callType CallType, contractData ContractsData, grantee common.Address, granterPriv cryptotypes.PrivKey, amount sdk.Coins,
) {
if callType == erc20V5CallerCall {
// NOTE: When using the ERC20 caller contract, we must still approve from the actual ERC20 v5 contract.
callType = erc20V5Call
}

abiEvents := contractData.GetContractData(callType).ABI.Events

txArgs, callArgs := is.getTxAndCallArgs(callType, contractData, auth.ApproveMethod, grantee, amount.AmountOf(is.tokenDenom).BigInt())

approveCheck := testutil.LogCheckArgs{
ABIEvents: abiEvents,
ExpEvents: []string{auth.EventTypeApproval},
ExpPass: true,
}

_, _, err := is.factory.CallContractAndCheckLogs(granterPriv, txArgs, callArgs, approveCheck)
Expect(err).ToNot(HaveOccurred(), "failed to execute approve")
}

// requireOut is a helper utility to reduce the amount of boilerplate code in the query tests.
//
// It requires the output bytes and error to match the expected values. Additionally, the method outputs
Expand Down Expand Up @@ -453,34 +392,6 @@ func (cd ContractsData) GetContractData(callType CallType) ContractData {
return data
}

// fundWithTokens is a helper function for the scope of the ERC20 integration tests.
// Depending on the passed call type, it funds the given address with tokens either
// using the Bank module or by minting straight on the ERC20 contract.
func (is *IntegrationTestSuite) fundWithTokens(
callType CallType,
contractData ContractsData,
receiver common.Address,
fundCoins sdk.Coins,
) {
Expect(fundCoins).To(HaveLen(1), "expected only one coin")
Expect(fundCoins[0].Denom).To(Equal(is.tokenDenom),
"this helper function only supports funding with the token denom in the context of these integration tests",
)

var err error

switch {
case slices.Contains(nativeCallTypes, callType):
err = is.network.FundAccount(receiver.Bytes(), fundCoins)
case slices.Contains(erc20CallTypes, callType):
err = is.MintERC20(callType, contractData, receiver, fundCoins.AmountOf(is.tokenDenom).BigInt())
default:
panic("unknown contract call type")
}

Expect(err).ToNot(HaveOccurred(), "failed to fund account")
}

// MintERC20 is a helper function to mint tokens on the ERC20 contract.
//
// NOTE: we are checking that there was a Transfer event emitted (which happens on minting).
Expand Down
5 changes: 5 additions & 0 deletions proto/ethermint/evm/v1/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ message Params {
// active_precompiles defines the slice of hex addresses of the precompiled
// contracts that are active
repeated string active_precompiles = 7;
// authorized_channels is the list of authorized channel identifiers that can perform address
// attestations via IBC.
repeated string authorized_channels = 8;
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
// evm_channels is the list of channel identifiers from EVM compatible chains
repeated string evm_channels = 9 [(gogoproto.customname) = "EVMChannels"];
}

// ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int values
Expand Down
6 changes: 3 additions & 3 deletions x/evm/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
const invalidAddress = "0x0000"

// expGasConsumed is the gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee)
const expGasConsumed = 7328
const expGasConsumed = 7427

// expGasConsumedWithFeeMkt is the gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee) with enabled feemarket
const expGasConsumedWithFeeMkt = 7322
const expGasConsumedWithFeeMkt = 7421

func (suite *KeeperTestSuite) TestQueryAccount() {
var (
Expand Down Expand Up @@ -937,7 +937,7 @@ func (suite *KeeperTestSuite) TestTraceTx() {
},
expPass: true,
traceResponse: "{\"gas\":34828,\"failed\":false,\"returnValue\":\"0000000000000000000000000000000000000000000000000000000000000001\",\"structLogs\":[{\"pc\":0,\"op\":\"PUSH1\",\"gas\":",
expFinalGas: 25244, // gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee) + gas consumed in malleate func
expFinalGas: 26432, // gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee) + gas consumed in malleate func
},
{
msg: "invalid chain id",
Expand Down