Skip to content

Commit

Permalink
feat(x/crosschain): unified external claim msg (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code authored Sep 9, 2024
1 parent fd5ee32 commit e07a3fa
Show file tree
Hide file tree
Showing 32 changed files with 668 additions and 24,228 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ lint-install:
fi

check-no-lint:
@if [ $$(find . -name '*.go' -type f | xargs grep 'nolint\|#nosec' | wc -l) -ne 44 ]; then \
@if [ $$(find . -name '*.go' -type f | xargs grep 'nolint\|#nosec' | wc -l) -ne 42 ]; then \
echo "\033[91m--> increase or decrease nolint, please recheck them\033[0m"; \
echo "\033[91m--> list nolint: \`find . -name '*.go' -type f | xargs grep 'nolint\|#nosec'\`\033[0m"; \
exit 1;\
Expand Down
10 changes: 0 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ import (
"github.com/functionx/fx-core/v8/x/crosschain"
"github.com/functionx/fx-core/v8/x/crosschain/keeper"
crosschaintypes "github.com/functionx/fx-core/v8/x/crosschain/types"
"github.com/functionx/fx-core/v8/x/gravity"
gravitykeeper "github.com/functionx/fx-core/v8/x/gravity/keeper"
gravitytypes "github.com/functionx/fx-core/v8/x/gravity/types"
)

var _ servertypes.Application = (*App)(nil)
Expand Down Expand Up @@ -293,10 +290,6 @@ func (app *App) RegisterServices(cfg module.Configurator) {
gaspricev1.RegisterQueryServer(cfg.QueryServer(), gaspricev1.Querier{})
gaspricev2.RegisterQueryServer(cfg.QueryServer(), gaspricev2.Querier{})

// Deprecated
gravitytypes.RegisterQueryServer(cfg.QueryServer(), gravitykeeper.NewQueryServerImpl(app.EthKeeper))
gravitytypes.RegisterMsgServer(cfg.MsgServer(), gravitykeeper.NewMsgServerImpl(app.EthKeeper))

crosschaintypes.RegisterQueryServer(cfg.QueryServer(), app.CrosschainRouterKeeper)
crosschaintypes.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerRouterImpl(app.CrosschainRouterKeeper))

Expand All @@ -311,9 +304,6 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig
gaspricev1.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
gaspricev2.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Deprecated: Register gravity queries routes from grpc-gateway.
gravity.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
Expand Down
3 changes: 0 additions & 3 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
fxtypes "github.com/functionx/fx-core/v8/types"
crosschaintypes "github.com/functionx/fx-core/v8/x/crosschain/types"
govlegacy "github.com/functionx/fx-core/v8/x/gov/legacy"
gravitytypes "github.com/functionx/fx-core/v8/x/gravity/types"
)

func Test_MsgServiceRouter(t *testing.T) {
Expand All @@ -31,8 +30,6 @@ func Test_MsgServiceRouter(t *testing.T) {
deprecated := map[string]struct{}{
sdk.MsgTypeURL(&crosschaintypes.MsgSetOrchestratorAddress{}): {},
sdk.MsgTypeURL(&crosschaintypes.MsgAddOracleDeposit{}): {},
sdk.MsgTypeURL(&gravitytypes.MsgSetOrchestratorAddress{}): {},
sdk.MsgTypeURL(&gravitytypes.MsgFxOriginatedTokenClaim{}): {},
sdk.MsgTypeURL(&govlegacy.MsgUpdateParams{}): {},
}
for _, msg := range encodingConfig.InterfaceRegistry.ListImplementations(sdk.MsgInterfaceProtoName) {
Expand Down
4 changes: 0 additions & 4 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
etherminttypes "github.com/evmos/ethermint/types"

crosschaintypes "github.com/functionx/fx-core/v8/x/crosschain/types"
gravitytypes "github.com/functionx/fx-core/v8/x/gravity/types"
)

// EncodingConfig specifies the concrete encoding types to use for a given app.
Expand All @@ -38,9 +37,6 @@ func MakeEncodingConfig() EncodingConfig {
crosschaintypes.RegisterLegacyAminoCodec(encodingConfig.Amino)
crosschaintypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)

gravitytypes.RegisterLegacyAminoCodec(encodingConfig.Amino)
gravitytypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)

registerCryptoEthSecp256k1(encodingConfig.Amino)

govcodec.Amino = encodingConfig.Amino
Expand Down
4 changes: 2 additions & 2 deletions app/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ func TestMakeEncodingConfig_RegisterInterfaces(t *testing.T) {
for interfaceImpls.Next() {
count1++
}
assert.Equal(t, 32, count1)
assert.Equal(t, 31, count1)

implInterfaces := interfaceRegistry.FieldByName("implInterfaces").MapRange()
var count2 int
for implInterfaces.Next() {
count2++
}
assert.Equal(t, 299, count2)
assert.Equal(t, 277, count2)

typeURLMap := interfaceRegistry.FieldByName("typeURLMap").MapRange()
for typeURLMap.Next() {
Expand Down
44 changes: 3 additions & 41 deletions app/interface_registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"cosmos.vesting.v1beta1.VestingAccount",
"ethermint.evm.v1.TxData",
"fx.ibc.applications.transfer.v1.MemoPacket",
"gravity.v1beta1.EthereumClaim",
"gravity.v1beta1.ExternalClaim",
"ibc.core.channel.v1.ChannelI",
"ibc.core.channel.v1.CounterpartyChannelI",
Expand Down Expand Up @@ -210,18 +209,17 @@
"/fx.gravity.crosschain.v1.MsgBondedOracleResponse",
"/fx.gravity.crosschain.v1.MsgBridgeCall",
"/fx.gravity.crosschain.v1.MsgBridgeCallClaim",
"/fx.gravity.crosschain.v1.MsgBridgeCallClaimResponse",
"/fx.gravity.crosschain.v1.MsgBridgeCallConfirm",
"/fx.gravity.crosschain.v1.MsgBridgeCallConfirmResponse",
"/fx.gravity.crosschain.v1.MsgBridgeCallResponse",
"/fx.gravity.crosschain.v1.MsgBridgeCallResultClaim",
"/fx.gravity.crosschain.v1.MsgBridgeCallResultClaimResponse",
"/fx.gravity.crosschain.v1.MsgBridgeTokenClaim",
"/fx.gravity.crosschain.v1.MsgBridgeTokenClaimResponse",
"/fx.gravity.crosschain.v1.MsgCancelPendingBridgeCall",
"/fx.gravity.crosschain.v1.MsgCancelPendingBridgeCallResponse",
"/fx.gravity.crosschain.v1.MsgCancelSendToExternal",
"/fx.gravity.crosschain.v1.MsgCancelSendToExternalResponse",
"/fx.gravity.crosschain.v1.MsgClaim",
"/fx.gravity.crosschain.v1.MsgClaimResponse",
"/fx.gravity.crosschain.v1.MsgConfirmBatch",
"/fx.gravity.crosschain.v1.MsgConfirmBatchResponse",
"/fx.gravity.crosschain.v1.MsgEditBridger",
Expand All @@ -231,17 +229,14 @@
"/fx.gravity.crosschain.v1.MsgOracleSetConfirm",
"/fx.gravity.crosschain.v1.MsgOracleSetConfirmResponse",
"/fx.gravity.crosschain.v1.MsgOracleSetUpdatedClaim",
"/fx.gravity.crosschain.v1.MsgOracleSetUpdatedClaimResponse",
"/fx.gravity.crosschain.v1.MsgReDelegate",
"/fx.gravity.crosschain.v1.MsgReDelegateResponse",
"/fx.gravity.crosschain.v1.MsgRequestBatch",
"/fx.gravity.crosschain.v1.MsgRequestBatchResponse",
"/fx.gravity.crosschain.v1.MsgSendToExternal",
"/fx.gravity.crosschain.v1.MsgSendToExternalClaim",
"/fx.gravity.crosschain.v1.MsgSendToExternalClaimResponse",
"/fx.gravity.crosschain.v1.MsgSendToExternalResponse",
"/fx.gravity.crosschain.v1.MsgSendToFxClaim",
"/fx.gravity.crosschain.v1.MsgSendToFxClaimResponse",
"/fx.gravity.crosschain.v1.MsgSetOrchestratorAddress",
"/fx.gravity.crosschain.v1.MsgUnbondedOracle",
"/fx.gravity.crosschain.v1.MsgUnbondedOracleResponse",
Expand All @@ -252,24 +247,6 @@
"/fx.gravity.crosschain.v1.MsgWithdrawReward",
"/fx.gravity.crosschain.v1.MsgWithdrawRewardResponse",
"/fx.gravity.crosschain.v1.UpdateChainOraclesProposal",
"/fx.gravity.v1.MsgCancelSendToEth",
"/fx.gravity.v1.MsgCancelSendToEthResponse",
"/fx.gravity.v1.MsgConfirmBatch",
"/fx.gravity.v1.MsgConfirmBatchResponse",
"/fx.gravity.v1.MsgDepositClaim",
"/fx.gravity.v1.MsgDepositClaimResponse",
"/fx.gravity.v1.MsgFxOriginatedTokenClaim",
"/fx.gravity.v1.MsgRequestBatch",
"/fx.gravity.v1.MsgRequestBatchResponse",
"/fx.gravity.v1.MsgSendToEth",
"/fx.gravity.v1.MsgSendToEthResponse",
"/fx.gravity.v1.MsgSetOrchestratorAddress",
"/fx.gravity.v1.MsgValsetConfirm",
"/fx.gravity.v1.MsgValsetConfirmResponse",
"/fx.gravity.v1.MsgValsetUpdatedClaim",
"/fx.gravity.v1.MsgValsetUpdatedClaimResponse",
"/fx.gravity.v1.MsgWithdrawClaim",
"/fx.gravity.v1.MsgWithdrawClaimResponse",
"/fx.ibc.applications.transfer.v1.IbcCallEvmPacket",
"/fx.ibc.applications.transfer.v1.MsgTransfer",
"/fx.migrate.v1.MsgMigrateAccount",
Expand Down Expand Up @@ -420,37 +397,22 @@
"/fx.gravity.crosschain.v1.MsgAddPendingPoolRewards",
"/fx.gravity.crosschain.v1.MsgBondedOracle",
"/fx.gravity.crosschain.v1.MsgBridgeCall",
"/fx.gravity.crosschain.v1.MsgBridgeCallClaim",
"/fx.gravity.crosschain.v1.MsgBridgeCallConfirm",
"/fx.gravity.crosschain.v1.MsgBridgeCallResultClaim",
"/fx.gravity.crosschain.v1.MsgBridgeTokenClaim",
"/fx.gravity.crosschain.v1.MsgCancelPendingBridgeCall",
"/fx.gravity.crosschain.v1.MsgCancelSendToExternal",
"/fx.gravity.crosschain.v1.MsgClaim",
"/fx.gravity.crosschain.v1.MsgConfirmBatch",
"/fx.gravity.crosschain.v1.MsgEditBridger",
"/fx.gravity.crosschain.v1.MsgIncreaseBridgeFee",
"/fx.gravity.crosschain.v1.MsgOracleSetConfirm",
"/fx.gravity.crosschain.v1.MsgOracleSetUpdatedClaim",
"/fx.gravity.crosschain.v1.MsgReDelegate",
"/fx.gravity.crosschain.v1.MsgRequestBatch",
"/fx.gravity.crosschain.v1.MsgSendToExternal",
"/fx.gravity.crosschain.v1.MsgSendToExternalClaim",
"/fx.gravity.crosschain.v1.MsgSendToFxClaim",
"/fx.gravity.crosschain.v1.MsgSetOrchestratorAddress",
"/fx.gravity.crosschain.v1.MsgUnbondedOracle",
"/fx.gravity.crosschain.v1.MsgUpdateChainOracles",
"/fx.gravity.crosschain.v1.MsgUpdateParams",
"/fx.gravity.crosschain.v1.MsgWithdrawReward",
"/fx.gravity.v1.MsgCancelSendToEth",
"/fx.gravity.v1.MsgConfirmBatch",
"/fx.gravity.v1.MsgDepositClaim",
"/fx.gravity.v1.MsgFxOriginatedTokenClaim",
"/fx.gravity.v1.MsgRequestBatch",
"/fx.gravity.v1.MsgSendToEth",
"/fx.gravity.v1.MsgSetOrchestratorAddress",
"/fx.gravity.v1.MsgValsetConfirm",
"/fx.gravity.v1.MsgValsetUpdatedClaim",
"/fx.gravity.v1.MsgWithdrawClaim",
"/fx.ibc.applications.transfer.v1.MsgTransfer",
"/fx.migrate.v1.MsgMigrateAccount",
"/fx.staking.v1.MsgEditConsensusPubKey",
Expand Down
2 changes: 0 additions & 2 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ import (
fxevmkeeper "github.com/functionx/fx-core/v8/x/evm/keeper"
fxgovkeeper "github.com/functionx/fx-core/v8/x/gov/keeper"
fxgovtypes "github.com/functionx/fx-core/v8/x/gov/types"
gravitytypes "github.com/functionx/fx-core/v8/x/gravity/types"
fxtransfer "github.com/functionx/fx-core/v8/x/ibc/applications/transfer"
fxtransferkeeper "github.com/functionx/fx-core/v8/x/ibc/applications/transfer/keeper"
fxibctransfertypes "github.com/functionx/fx-core/v8/x/ibc/applications/transfer/types"
Expand Down Expand Up @@ -552,7 +551,6 @@ func NewAppKeeper(
)

ibcTransferRouter := fxibctransfertypes.NewRouter().
AddRoute(gravitytypes.ModuleName, appKeepers.EthKeeper).
AddRoute(ethtypes.ModuleName, appKeepers.EthKeeper).
AddRoute(bsctypes.ModuleName, appKeepers.BscKeeper).
AddRoute(polygontypes.ModuleName, appKeepers.PolygonKeeper).
Expand Down
21 changes: 10 additions & 11 deletions docs/swagger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func TestSwaggerConfig(t *testing.T) {
assert.Equal(t, 6, handler.Value().Len())
}
if handler.Key().String() == "GET" {
assert.Equal(t, 222, handler.Value().Len())
assert.Equal(t, 198, handler.Value().Len())
}
}
assert.Equal(t, 33, len(route))
assert.Equal(t, 32, len(route))
ignoreLen := len(route) - len(c.Apis)
for _, v := range c.Apis {
for key := range route {
Expand All @@ -72,16 +72,15 @@ func TestSwaggerConfig(t *testing.T) {

// ignore routes:
// 1. other/v1/gas_price
// 2. fx/gravity/v1
// 3. fx/other/gas_price
// 4. fx/base/v1
// 5. fx/ibc/applications
// 6. ibc/core/channel/v1
// 7. ibc/core/client/v1
// 8. ibc/core/connection/v1
// 9. cosmos/gov/v1beta1
// 2. fx/other/gas_price
// 3. fx/base/v1
// 4. fx/ibc/applications
// 5. ibc/core/channel/v1
// 6. ibc/core/client/v1
// 7. ibc/core/connection/v1
// 8. cosmos/gov/v1beta1
assert.Equal(t, ignoreLen, len(route))
assert.Equal(t, 9, len(route))
assert.Equal(t, 8, len(route))
}

type config struct {
Expand Down
19 changes: 10 additions & 9 deletions proto/fx/gravity/crosschain/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "fx/gravity/crosschain/v1/types.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/functionx/fx-core/x/crosschain/types";

Expand All @@ -19,26 +20,17 @@ service Msg {
rpc UnbondedOracle(MsgUnbondedOracle) returns (MsgUnbondedOracleResponse);

rpc OracleSetConfirm(MsgOracleSetConfirm) returns (MsgOracleSetConfirmResponse);
rpc OracleSetUpdateClaim(MsgOracleSetUpdatedClaim) returns (MsgOracleSetUpdatedClaimResponse);

rpc BridgeTokenClaim(MsgBridgeTokenClaim) returns (MsgBridgeTokenClaimResponse);

rpc SendToFxClaim(MsgSendToFxClaim) returns (MsgSendToFxClaimResponse);

rpc SendToExternal(MsgSendToExternal) returns (MsgSendToExternalResponse);
rpc CancelSendToExternal(MsgCancelSendToExternal) returns (MsgCancelSendToExternalResponse);
rpc SendToExternalClaim(MsgSendToExternalClaim) returns (MsgSendToExternalClaimResponse);

rpc RequestBatch(MsgRequestBatch) returns (MsgRequestBatchResponse);
rpc ConfirmBatch(MsgConfirmBatch) returns (MsgConfirmBatchResponse);

rpc BridgeCallClaim(MsgBridgeCallClaim) returns (MsgBridgeCallClaimResponse);

rpc BridgeCall(MsgBridgeCall) returns (MsgBridgeCallResponse);
rpc CancelPendingBridgeCall(MsgCancelPendingBridgeCall) returns (MsgCancelPendingBridgeCallResponse);

rpc BridgeCallConfirm(MsgBridgeCallConfirm) returns (MsgBridgeCallConfirmResponse);
rpc BridgeCallResultClaim(MsgBridgeCallResultClaim) returns (MsgBridgeCallResultClaimResponse);

// UpdateParams defines a governance operation for updating the x/crosschain
// module parameters. The authority is hard-coded to the x/gov module account.
Expand All @@ -48,6 +40,8 @@ service Msg {
rpc AddPendingPoolRewards(MsgAddPendingPoolRewards) returns (MsgAddPendingPoolRewardsResponse);

rpc UpdateChainOracles(MsgUpdateChainOracles) returns (MsgUpdateChainOraclesResponse);

rpc Claim(MsgClaim) returns (MsgClaimResponse) {}
}

message MsgBondedOracle {
Expand Down Expand Up @@ -409,3 +403,10 @@ message MsgAddPendingPoolRewards {
}

message MsgAddPendingPoolRewardsResponse {}

message MsgClaim {
string chain_name = 1;
google.protobuf.Any claim = 3 [(cosmos_proto.accepts_interface) = "ExternalClaim"];
}

message MsgClaimResponse {}
66 changes: 0 additions & 66 deletions proto/fx/gravity/v1/genesis.proto

This file was deleted.

Loading

0 comments on commit e07a3fa

Please sign in to comment.