Skip to content

Commit

Permalink
Merge branch 'main' into dapp-tests/update-contract-deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
kollegian authored Oct 9, 2024
2 parents 9da7205 + c613181 commit b34b929
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 49 deletions.
4 changes: 2 additions & 2 deletions app/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func (app *App) AddCosmosEventsToEVMReceiptIfApplicable(ctx sdk.Context, tx sdk.
return
}
logs := []*ethtypes.Log{}
wasmGasLimit := app.EvmKeeper.GetDeliverTxHookWasmGasLimit(ctx)
queryCtx := ctx.WithGasMeter(sdk.NewGasMeterWithMultiplier(ctx, wasmGasLimit))
// wasmGasLimit := app.EvmKeeper.GetDeliverTxHookWasmGasLimit(ctx)
queryCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter(1, 1))
for _, wasmEvent := range wasmEvents {
contractAddr, found := GetAttributeValue(wasmEvent, wasmtypes.AttributeKeyContractAddr)
if !found {
Expand Down
8 changes: 4 additions & 4 deletions contracts/test/EVMCompatabilityTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe("EVM Test", function () {
testToken = await TestToken.deploy("TestToken", "TTK");

const EVMCompatibilityTester = await ethers.getContractFactory("EVMCompatibilityTester");
evmTester = await EVMCompatibilityTester.deploy();
evmTester = await EVMCompatibilityTester.deploy({ gasPrice: ethers.parseUnits('100', 'gwei') });

await Promise.all([evmTester.waitForDeployment(), testToken.waitForDeployment()])

Expand Down Expand Up @@ -148,7 +148,7 @@ describe("EVM Test", function () {

await delay()
// Set balance
await testToken.setBalance(owner.address, setAmount);
await testToken.setBalance(owner.address, setAmount, { gasPrice: ethers.parseUnits('100', 'gwei') });

// Prepare call data for balanceOf function of MyToken
const balanceOfData = testToken.interface.encodeFunctionData("balanceOf", [owner.address]);
Expand All @@ -169,7 +169,7 @@ describe("EVM Test", function () {
describe("Msg Properties", function() {
it("Should store and retrieve msg properties correctly", async function() {
// Store msg properties
const txResponse = await evmTester.storeMsgProperties({ value: 1 });
const txResponse = await evmTester.storeMsgProperties({ value: 1, gasPrice: ethers.parseUnits('100', 'gwei') });
await txResponse.wait();

// Retrieve stored msg properties
Expand Down Expand Up @@ -1004,7 +1004,7 @@ describe("EVM Test", function () {

// increment value
debug("Incrementing value...")
const resp = await box.boxIncr();
const resp = await box.boxIncr({ gasPrice: ethers.parseUnits('100', 'gwei') });
await resp.wait();

// make sure value is incremented
Expand Down
2 changes: 1 addition & 1 deletion evmrpc/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func verifyBlockResult(t *testing.T, resObj map[string]interface{}) {
require.Equal(t, "0x0", tx["yParity"])
require.Equal(t, "0x0000000000000000000000000000000000000000000000000000000000000002", resObj["transactionsRoot"])
require.Equal(t, []interface{}{}, resObj["uncles"])
require.Equal(t, "0x174876e800", resObj["baseFeePerGas"])
require.Equal(t, "0x3b9aca00", resObj["baseFeePerGas"])
require.Equal(t, "0x0", resObj["totalDifficulty"])
}

Expand Down
20 changes: 12 additions & 8 deletions evmrpc/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package evmrpc_test

import (
"errors"
"fmt"
"math/big"
"testing"

Expand Down Expand Up @@ -61,7 +62,8 @@ func TestGasPrice(t *testing.T) {
resObj := sendRequestGood(t, "gasPrice")
Ctx = Ctx.WithBlockHeight(8)
result := resObj["result"].(string)
require.Equal(t, "0x174876e800", result)
oneGwei := "0x3b9aca00"
require.Equal(t, oneGwei, result)
}

func TestFeeHistory(t *testing.T) {
Expand All @@ -80,12 +82,12 @@ func TestFeeHistory(t *testing.T) {
Ctx = Ctx.WithBlockHeight(1) // Simulate context with a specific block height

testCases := []feeHistoryTestCase{
{name: "Valid request by number", blockCount: 1, lastBlock: "0x8", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Valid request by latest", blockCount: 1, lastBlock: "latest", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Valid request by earliest", blockCount: 1, lastBlock: "earliest", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Request on the same block", blockCount: 1, lastBlock: "0x1", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Request on future block", blockCount: 1, lastBlock: "0x9", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Block count truncates", blockCount: 1025, lastBlock: "latest", rewardPercentiles: []interface{}{25}, expectedOldest: "0x1", expectedReward: "0x0", expectedBaseFee: "0x174876e800", expectedGasUsed: 0.5},
{name: "Valid request by number", blockCount: 1, lastBlock: "0x8", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Valid request by latest", blockCount: 1, lastBlock: "latest", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Valid request by earliest", blockCount: 1, lastBlock: "earliest", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Request on the same block", blockCount: 1, lastBlock: "0x1", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Request on future block", blockCount: 1, lastBlock: "0x9", rewardPercentiles: []interface{}{0.5}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Block count truncates", blockCount: 1025, lastBlock: "latest", rewardPercentiles: []interface{}{25}, expectedOldest: "0x1", expectedReward: "0x170cdc1e00", expectedBaseFee: "0x3b9aca00", expectedGasUsed: 0.5},
{name: "Too many percentiles", blockCount: 10, lastBlock: "latest", rewardPercentiles: make([]interface{}, 101), expectedError: errors.New("rewardPercentiles length must be less than or equal to 100")},
{name: "Invalid percentiles order", blockCount: 10, lastBlock: "latest", rewardPercentiles: []interface{}{99, 1}, expectedError: errors.New("invalid reward percentiles: must be ascending and between 0 and 100")},
}
Expand All @@ -111,6 +113,8 @@ func TestFeeHistory(t *testing.T) {
reward, ok := rewards[0].([]interface{})
require.True(t, ok, "Expected reward to be a slice of interfaces")
require.Equal(t, 1, len(reward), "Expected exactly one sub-item in reward")
fmt.Println("resObj", resObj)

require.Equal(t, tc.expectedReward, reward[0].(string), "Reward does not match expected value")

require.Equal(t, tc.expectedBaseFee, resObj["baseFeePerGas"].([]interface{})[0].(string))
Expand Down Expand Up @@ -164,5 +168,5 @@ func TestMaxPriorityFeePerGas(t *testing.T) {
Ctx = Ctx.WithBlockHeight(1)
// Mimic request sending and handle the response
resObj := sendRequestGood(t, "maxPriorityFeePerGas")
assert.Equal(t, "0x0", resObj["result"])
assert.Equal(t, "0x170cdc1e00", resObj["result"])
}
2 changes: 1 addition & 1 deletion precompiles/pointer/pointer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestAddNative(t *testing.T) {
evm = vm.NewEVM(*blockCtx, vm.TxContext{}, statedb, cfg, vm.Config{})
ret, g, err := p.RunAndCalculateGas(evm, caller, caller, append(p.GetExecutor().(*pointer.PrecompileExecutor).AddNativePointerID, args...), suppliedGas, nil, nil, false, false)
require.Nil(t, err)
require.Equal(t, uint64(8881522), g)
require.Equal(t, uint64(8881534), g)
outputs, err := m.Outputs.Unpack(ret)
require.Nil(t, err)
addr := outputs[0].(common.Address)
Expand Down
2 changes: 1 addition & 1 deletion testutil/keeper/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func EpochKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
cdc := codec.NewProtoCodec(registry)

paramsSubspace := typesparams.NewSubspace(cdc,
types.Amino,
codec.NewLegacyAmino(),
storeKey,
memStoreKey,
"EpochParams",
Expand Down
9 changes: 7 additions & 2 deletions x/epoch/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
}

var (
Amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterCodec(amino)
amino.Seal()
}
3 changes: 3 additions & 0 deletions x/evm/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func (fc EVMFeeCheckDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b
if txData.GetGasFeeCap().Cmp(fc.getMinimumFee(ctx)) < 0 {
return ctx, sdkerrors.ErrInsufficientFee
}
if txData.GetGasTipCap().Sign() < 0 {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "gas fee cap cannot be negative")
}

// if EVM version is Cancun or later, and the transaction contains at least one blob, we need to
// make sure the transaction carries a non-zero blob fee cap.
Expand Down
37 changes: 37 additions & 0 deletions x/evm/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ func TestEVMFeeCheckDecorator(t *testing.T) {
return ctx, nil
})
require.NotNil(t, err)

// should fail because of negative gas tip cap
txData.GasTipCap = big.NewInt(-1)
txData.GasFeeCap = big.NewInt(10000000000000)
tx, err = ethtypes.SignTx(ethtypes.NewTx(&txData), signer, key)
require.Nil(t, err)
typedTx = newDynamicFeeTxWithoutValidation(tx)
msg, err = types.NewMsgEVMTransaction(typedTx)
require.Nil(t, err)
ctx, err = preprocessor.AnteHandle(ctx, mockTx{msgs: []sdk.Msg{msg}}, false, func(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error) {
return ctx, nil
})
require.Nil(t, err)
_, err = handler.AnteHandle(ctx, mockTx{msgs: []sdk.Msg{msg}}, false, func(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error) {
return ctx, nil
})
require.NotNil(t, err)
require.Contains(t, err.Error(), "gas fee cap cannot be negative")
}

func TestCalculatePriorityScenarios(t *testing.T) {
Expand Down Expand Up @@ -227,3 +245,22 @@ func TestCalculatePriorityScenarios(t *testing.T) {
})
}
}

func newDynamicFeeTxWithoutValidation(tx *ethtypes.Transaction) *ethtx.DynamicFeeTx {
txData := &ethtx.DynamicFeeTx{
Nonce: tx.Nonce(),
Data: tx.Data(),
GasLimit: tx.Gas(),
}

v, r, s := tx.RawSignatureValues()
ethtx.SetConvertIfPresent(tx.To(), func(to *common.Address) string { return to.Hex() }, txData.SetTo)
ethtx.SetConvertIfPresent(tx.Value(), sdk.NewIntFromBigInt, txData.SetAmount)
ethtx.SetConvertIfPresent(tx.GasFeeCap(), sdk.NewIntFromBigInt, txData.SetGasFeeCap)
ethtx.SetConvertIfPresent(tx.GasTipCap(), sdk.NewIntFromBigInt, txData.SetGasTipCap)
al := tx.AccessList()
ethtx.SetConvertIfPresent(&al, ethtx.NewAccessList, txData.SetAccesses)

txData.SetSignatureValues(tx.ChainId(), v, r, s)
return txData
}
2 changes: 0 additions & 2 deletions x/evm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ func (server msgServer) EVMTransaction(goCtx context.Context, msg *types.MsgEVMT
originalGasMeter.ConsumeGas(adjustedGasUsed.TruncateInt().Uint64(), "evm transaction")
}()

fmt.Println("JEREMYDEBUG: calling apply evm message from EVMTransaction")
res, applyErr := server.applyEVMMessage(ctx, emsg, stateDB, gp)
serverRes = &types.MsgEVMTransactionResponse{
Hash: tx.Hash().Hex(),
Expand Down Expand Up @@ -230,7 +229,6 @@ func (k *Keeper) GetEVMMessage(ctx sdk.Context, tx *ethtypes.Transaction, sender
}

func (k Keeper) applyEVMMessage(ctx sdk.Context, msg *core.Message, stateDB *state.DBImpl, gp core.GasPool) (*core.ExecutionResult, error) {
// fmt.Printf("JEREMYDEBUG: In applyEVMMessage, msg = %+v\n", msg)
blockCtx, err := k.GetVMBlockContext(ctx, gp)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions x/evm/migrations/migrate_eip_1559_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func MigrateEip1559Params(ctx sdk.Context, k *keeper.Keeper) error {
keeperParams.MaxDynamicBaseFeeUpwardAdjustment = types.DefaultParams().MaxDynamicBaseFeeUpwardAdjustment
keeperParams.MaxDynamicBaseFeeDownwardAdjustment = types.DefaultParams().MaxDynamicBaseFeeDownwardAdjustment
keeperParams.TargetGasUsedPerBlock = types.DefaultParams().TargetGasUsedPerBlock
keeperParams.MinimumFeePerGas = types.DefaultParams().MinimumFeePerGas
k.SetParams(ctx, keeperParams)
return nil
}
1 change: 1 addition & 0 deletions x/evm/migrations/migrate_eip_1559_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ func TestMigrateEip1559Params(t *testing.T) {
require.Equal(t, keeperParams.MaxDynamicBaseFeeUpwardAdjustment, types.DefaultParams().MaxDynamicBaseFeeUpwardAdjustment)
require.Equal(t, keeperParams.MaxDynamicBaseFeeDownwardAdjustment, types.DefaultParams().MaxDynamicBaseFeeDownwardAdjustment)
require.Equal(t, keeperParams.TargetGasUsedPerBlock, types.DefaultParams().TargetGasUsedPerBlock)
require.Equal(t, keeperParams.MinimumFeePerGas, types.DefaultParams().MinimumFeePerGas)
}
7 changes: 3 additions & 4 deletions x/evm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ func (AppModuleBasic) Name() string {
return types.ModuleName
}

func (AppModuleBasic) RegisterCodec(*codec.LegacyAmino) {}

func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino) {}
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterCodec(cdc)
}

// RegisterInterfaces registers the module's interface types
func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {
Expand Down Expand Up @@ -286,7 +286,6 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
// EndBlock executes all ABCI EndBlock logic respective to the evm module. It
// returns no validator updates.
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
fmt.Println("JEREMYDEBUG: block gas used", req.BlockGasUsed, ", block height", ctx.BlockHeight())
newBaseFee := am.keeper.AdjustDynamicBaseFeePerGas(ctx, uint64(req.BlockGasUsed))
if newBaseFee != nil {
metrics.GaugeEvmBlockBaseFee(newBaseFee.TruncateInt().BigInt(), req.Height)
Expand Down
5 changes: 3 additions & 2 deletions x/evm/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ func TestQuerierRoute(t *testing.T) {
func TestModuleExportGenesis(t *testing.T) {
k, ctx := testkeeper.MockEVMKeeper()
module := evm.NewAppModule(nil, k)
jsonMsg := module.ExportGenesis(ctx, types.ModuleCdc)
cdc := app.MakeEncodingConfig().Marshaler
jsonMsg := module.ExportGenesis(ctx, cdc)
jsonStr := string(jsonMsg)
assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"100000000000.000000000000000000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[],\"deliver_tx_hook_wasm_gas_limit\":\"300000\",\"max_dynamic_base_fee_upward_adjustment\":\"0.000000000000000000\",\"max_dynamic_base_fee_downward_adjustment\":\"0.000000000000000000\",\"target_gas_used_per_block\":\"100000\"},\"address_associations\":[{\"sei_address\":\"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu\",\"eth_address\":\"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F\"}],\"codes\":[],\"states\":[],\"nonces\":[],\"serialized\":[{\"prefix\":\"Fg==\",\"key\":\"AwAC\",\"value\":\"AAAAAAAAAAM=\"},{\"prefix\":\"Fg==\",\"key\":\"BAAG\",\"value\":\"AAAAAAAAAAQ=\"}]}", jsonStr)
assert.Equal(t, `{"params":{"priority_normalizer":"1.000000000000000000","base_fee_per_gas":"0.000000000000000000","minimum_fee_per_gas":"1000000000.000000000000000000","whitelisted_cw_code_hashes_for_delegate_call":[],"deliver_tx_hook_wasm_gas_limit":"300000","max_dynamic_base_fee_upward_adjustment":"0.018900000000000000","max_dynamic_base_fee_downward_adjustment":"0.003900000000000000","target_gas_used_per_block":"250000"},"address_associations":[{"sei_address":"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu","eth_address":"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F"}],"codes":[],"states":[],"nonces":[],"serialized":[{"prefix":"Fg==","key":"AwAC","value":"AAAAAAAAAAM="},{"prefix":"Fg==","key":"BAAG","value":"AAAAAAAAAAQ="}]}`, jsonStr)
}

func TestConsensusVersion(t *testing.T) {
Expand Down
12 changes: 10 additions & 2 deletions x/evm/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
AminoCdc = codec.NewAminoCodec(amino)
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterCodec(amino)
cryptocodec.RegisterCrypto(amino)
amino.Seal()
}
Expand All @@ -31,6 +31,14 @@ func GetAmino() *codec.LegacyAmino {
return amino
}

func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgAssociate{}, "evm/MsgAssociate", nil)
cdc.RegisterConcrete(&MsgEVMTransaction{}, "evm/MsgEVMTransaction", nil)
cdc.RegisterConcrete(&MsgSend{}, "evm/MsgSend", nil)
cdc.RegisterConcrete(&MsgRegisterPointer{}, "evm/MsgRegisterPointer", nil)
cdc.RegisterConcrete(&MsgAssociateContractAddress{}, "evm/MsgAssociateContractAddress", nil)
}

func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*govtypes.Content)(nil),
&AddERCNativePointerProposal{},
Expand Down
10 changes: 5 additions & 5 deletions x/evm/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ var DefaultPriorityNormalizer = sdk.NewDec(1)
// DefaultBaseFeePerGas determines how much usei per gas spent is
// burnt rather than go to validators (similar to base fee on
// Ethereum).
var DefaultBaseFeePerGas = sdk.NewDec(0) // used for static base fee, deprecated in favor of dynamic base fee
var DefaultMinFeePerGas = sdk.NewDec(100000000000)
var DefaultBaseFeePerGas = sdk.NewDec(0) // used for static base fee, deprecated in favor of dynamic base fee
var DefaultMinFeePerGas = sdk.NewDec(1000000000) // 1gwei
var DefaultDeliverTxHookWasmGasLimit = uint64(300000)

var DefaultWhitelistedCwCodeHashesForDelegateCall = generateDefaultWhitelistedCwCodeHashesForDelegateCall()

var DefaultMaxDynamicBaseFeeUpwardAdjustment = sdk.NewDec(0)
var DefaultMaxDynamicBaseFeeDownwardAdjustment = sdk.NewDec(0)
var DefaultTargetGasUsedPerBlock = uint64(100000)
var DefaultMaxDynamicBaseFeeUpwardAdjustment = sdk.NewDecWithPrec(189, 4) // 1.89%
var DefaultMaxDynamicBaseFeeDownwardAdjustment = sdk.NewDecWithPrec(39, 4) // .39%
var DefaultTargetGasUsedPerBlock = uint64(250000) // 250k

var _ paramtypes.ParamSet = (*Params)(nil)

Expand Down
8 changes: 5 additions & 3 deletions x/mint/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)

var amino = codec.NewLegacyAmino()
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterCodec(amino)
cryptocodec.RegisterCrypto(amino)
amino.Seal()
}
Expand All @@ -23,5 +27,3 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
&UpdateMinterProposal{},
)
}

var ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
2 changes: 1 addition & 1 deletion x/oracle/keeper/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func MakeEncodingConfig(_ *testing.T) simparams.EncodingConfig {

ModuleBasics.RegisterLegacyAminoCodec(amino)
ModuleBasics.RegisterInterfaces(interfaceRegistry)
types.RegisterLegacyAminoCodec(amino)
types.RegisterCodec(amino)
types.RegisterInterfaces(interfaceRegistry)
return simparams.EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Expand Down
2 changes: 1 addition & 1 deletion x/oracle/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (AppModuleBasic) Name() string {

// RegisterLegacyAminoCodec registers the module's types on the given LegacyAmino codec.
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
types.RegisterLegacyAminoCodec(cdc)
types.RegisterCodec(cdc)
}

// RegisterInterfaces registers the module's interface types
Expand Down
12 changes: 9 additions & 3 deletions x/oracle/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/msgservice"
)

func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgAggregateExchangeRateVote{}, "oracle/MsgAggregateExchangeRateVote", nil)
cdc.RegisterConcrete(&MsgDelegateFeedConsent{}, "oracle/MsgDelegateFeedConsent", nil)
}
Expand All @@ -24,6 +24,12 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
}

var (
Amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterCodec(amino)
sdk.RegisterLegacyAminoCodec(amino)
amino.Seal()
}
2 changes: 1 addition & 1 deletion x/tokenfactory/keeper/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestMigrate2to3(t *testing.T) {
cdc := codec.NewProtoCodec(registry)

paramsSubspace := typesparams.NewSubspace(cdc,
types.Amino,
codec.NewLegacyAmino(),
storeKey,
memStoreKey,
"TokenfactoryParams",
Expand Down
Loading

0 comments on commit b34b929

Please sign in to comment.