From 62fe71c7364005a0aadb8bb422afba9bd9c952ba Mon Sep 17 00:00:00 2001 From: keruch <53012408+keruch@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:08:29 +0300 Subject: [PATCH] feat(rollapp): query for genesis bridge validation (#1564) Co-authored-by: danwt <30197399+danwt@users.noreply.github.com> --- ibctesting/genesis_bridge_test.go | 28 +- .../genesis_bridge_data.proto | 8 +- .../dymension/rollapp/query.proto | 14 + .../genesisbridge/genesis_bridge_data.go | 75 --- x/rollapp/genesisbridge/genesis_transfer.go | 62 -- x/rollapp/genesisbridge/ibc_module.go | 119 +--- .../grpc_query_validate_genesis_bridge.go | 33 + x/rollapp/types/genesis_bridge_data.go | 133 ++++ .../genesis_bridge_data.pb.go | 95 ++- .../genesis_bridge_data_test.go | 33 +- .../types/genesis_bridge_data_validator.go | 123 ++++ x/rollapp/types/query.pb.go | 617 ++++++++++++++++-- 12 files changed, 949 insertions(+), 391 deletions(-) rename proto/dymensionxyz/dymension/{genesisbridge => rollapp}/genesis_bridge_data.proto (86%) delete mode 100644 x/rollapp/genesisbridge/genesis_bridge_data.go delete mode 100644 x/rollapp/genesisbridge/genesis_transfer.go create mode 100644 x/rollapp/keeper/grpc_query_validate_genesis_bridge.go create mode 100644 x/rollapp/types/genesis_bridge_data.go rename x/rollapp/{genesisbridge => types}/genesis_bridge_data.pb.go (82%) rename x/rollapp/{genesisbridge => types}/genesis_bridge_data_test.go (86%) create mode 100644 x/rollapp/types/genesis_bridge_data_validator.go diff --git a/ibctesting/genesis_bridge_test.go b/ibctesting/genesis_bridge_test.go index 0b974a4bf..5736ffad9 100644 --- a/ibctesting/genesis_bridge_test.go +++ b/ibctesting/genesis_bridge_test.go @@ -6,22 +6,20 @@ import ( "time" "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - "github.com/dymensionxyz/dymension/v3/testutil/sample" - irotypes "github.com/dymensionxyz/dymension/v3/x/iro/types" - "github.com/dymensionxyz/dymension/v3/x/rollapp/genesisbridge" - rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" + ibctesting "github.com/cosmos/ibc-go/v7/testing" + "github.com/stretchr/testify/suite" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dymensionxyz/dymension/v3/app/apptesting" appparams "github.com/dymensionxyz/dymension/v3/app/params" - "github.com/stretchr/testify/suite" - - "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + "github.com/dymensionxyz/dymension/v3/testutil/sample" + irotypes "github.com/dymensionxyz/dymension/v3/x/iro/types" + rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" ) var successAck = channeltypes.CommitAcknowledgement(channeltypes.NewResultAcknowledgement([]byte{byte(1)}).Acknowledgement()) @@ -232,7 +230,7 @@ func (s *transferGenesisSuite) TestInvalidGenesisDenomMetadata() { rollapp := s.hubApp().RollappKeeper.MustGetRollapp(s.hubCtx(), rollappChainID()) packet := s.genesisBridgePacket(rollapp.GenesisInfo) - var gb genesisbridge.GenesisBridgeData + var gb rollapptypes.GenesisBridgeData err := json.Unmarshal(packet.Data, &gb) s.Require().NoError(err) @@ -277,7 +275,7 @@ func (s *transferGenesisSuite) TestInvalidGenesisTransfer() { packet := s.genesisBridgePacket(rollapp.GenesisInfo) // change the amount in the genesis transfer - var gb genesisbridge.GenesisBridgeData + var gb rollapptypes.GenesisBridgeData err := json.Unmarshal(packet.Data, &gb) s.Require().NoError(err) gb.GenesisTransfer.Amount = "1242353645" @@ -366,7 +364,7 @@ func (s *transferGenesisSuite) genesisBridgePacket(raGenesisInfo rollapptypes.Ge display := raGenesisInfo.NativeDenom.Display initialSupply := raGenesisInfo.InitialSupply - var gb genesisbridge.GenesisBridgeData + var gb rollapptypes.GenesisBridgeData meta := banktypes.Metadata{ DenomUnits: []*banktypes.DenomUnit{ @@ -385,7 +383,7 @@ func (s *transferGenesisSuite) genesisBridgePacket(raGenesisInfo rollapptypes.Ge } s.Require().NoError(meta.Validate()) // sanity check the test is written correctly - gb.GenesisInfo = genesisbridge.GenesisBridgeInfo{ + gb.GenesisInfo = rollapptypes.GenesisBridgeInfo{ GenesisChecksum: "checksum", Bech32Prefix: "ethm", NativeDenom: rollapptypes.DenomMetadata{ @@ -405,7 +403,7 @@ func (s *transferGenesisSuite) genesisBridgePacket(raGenesisInfo rollapptypes.Ge denom, raGenesisInfo.GenesisTransferAmount().String(), s.rollappChain().SenderAccount.GetAddress().String(), - genesisbridge.HubRecipient, + rollapptypes.HubRecipient, "", ) gb.GenesisTransfer = &gTransfer diff --git a/proto/dymensionxyz/dymension/genesisbridge/genesis_bridge_data.proto b/proto/dymensionxyz/dymension/rollapp/genesis_bridge_data.proto similarity index 86% rename from proto/dymensionxyz/dymension/genesisbridge/genesis_bridge_data.proto rename to proto/dymensionxyz/dymension/rollapp/genesis_bridge_data.proto index 92aa5af5a..d6d99ddf3 100644 --- a/proto/dymensionxyz/dymension/genesisbridge/genesis_bridge_data.proto +++ b/proto/dymensionxyz/dymension/rollapp/genesis_bridge_data.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package dymensionxyz.dymension.genesisbridge; +package dymensionxyz.dymension.rollapp; import "gogoproto/gogo.proto"; import "cosmos/bank/v1beta1/bank.proto"; @@ -8,7 +8,7 @@ import "dymensionxyz/dymension/rollapp/metadata.proto"; import "dymensionxyz/dymension/rollapp/genesis_info.proto"; -option go_package = "github.com/dymensionxyz/dymension/v3/x/rollapp/genesisbridge"; +option go_package = "github.com/dymensionxyz/dymension/v3/x/rollapp/types"; // GenesisBridgeData is the data struct that is passed to the hub for the // genesis bridge flow @@ -30,12 +30,12 @@ message GenesisBridgeInfo { // unique bech32 prefix string bech32_prefix = 2; // native_denom is the base denom for the native token - rollapp.DenomMetadata native_denom = 3 [ (gogoproto.nullable) = false ]; + DenomMetadata native_denom = 3 [ (gogoproto.nullable) = false ]; // initial_supply is the initial supply of the native token string initial_supply = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // accounts on the Hub to fund with some bootstrapping transfers - repeated rollapp.GenesisAccount genesis_accounts = 5 [ (gogoproto.nullable) = false ]; + repeated GenesisAccount genesis_accounts = 5 [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/proto/dymensionxyz/dymension/rollapp/query.proto b/proto/dymensionxyz/dymension/rollapp/query.proto index 24dedab2d..90074a44a 100644 --- a/proto/dymensionxyz/dymension/rollapp/query.proto +++ b/proto/dymensionxyz/dymension/rollapp/query.proto @@ -10,6 +10,7 @@ import "dymensionxyz/dymension/rollapp/params.proto"; import "dymensionxyz/dymension/rollapp/rollapp.proto"; import "dymensionxyz/dymension/rollapp/state_info.proto"; import "dymensionxyz/dymension/rollapp/app.proto"; +import "dymensionxyz/dymension/rollapp/genesis_bridge_data.proto"; // Query defines the gRPC querier service. service Query { @@ -64,6 +65,9 @@ service Query { rpc ObsoleteDRSVersions(QueryObsoleteDRSVersionsRequest) returns (QueryObsoleteDRSVersionsResponse) { option (google.api.http).get = "/dymensionxyz/dymension/rollapp/obsolete_drs_versions"; } + + // Validates provided genesis bridge data against the hub. + rpc ValidateGenesisBridge(QueryValidateGenesisBridgeRequest) returns (QueryValidateGenesisBridgeResponse); } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -147,3 +151,13 @@ message QueryObsoleteDRSVersionsRequest {} message QueryObsoleteDRSVersionsResponse { repeated uint32 drs_versions = 1; } + +message QueryValidateGenesisBridgeRequest { + string rollappId = 1; + GenesisBridgeData data = 2 [ (gogoproto.nullable) = false ]; +} + +message QueryValidateGenesisBridgeResponse { + bool valid = 1; + string err = 2; +} diff --git a/x/rollapp/genesisbridge/genesis_bridge_data.go b/x/rollapp/genesisbridge/genesis_bridge_data.go deleted file mode 100644 index 73a2c987a..000000000 --- a/x/rollapp/genesisbridge/genesis_bridge_data.go +++ /dev/null @@ -1,75 +0,0 @@ -package genesisbridge - -import ( - fmt "fmt" - - "cosmossdk.io/errors" - errorsmod "cosmossdk.io/errors" - types "github.com/dymensionxyz/dymension/v3/x/rollapp/types" - "github.com/dymensionxyz/gerr-cosmos/gerrc" -) - -// ValidateBasic performs basic validation checks on the GenesisBridgeData. -func (data GenesisBridgeData) ValidateBasic() error { - // Validate genesis info - if err := data.GenesisInfo.ValidateBasic(); err != nil { - return errors.Wrap(err, "invalid genesis info") - } - - // Validate metadata - if err := data.NativeDenom.Validate(); err != nil { - return errors.Wrap(err, "invalid metadata") - } - - // validate metadata corresponding to the genesis info denom - // check the base denom, display unit and decimals - if data.NativeDenom.Base != data.GenesisInfo.NativeDenom.Base { - return fmt.Errorf("metadata denom does not match genesis info denom") - } - - // validate the decimals of the display denom - valid := false - for _, unit := range data.NativeDenom.DenomUnits { - if unit.Denom == data.GenesisInfo.NativeDenom.Display { - if unit.Exponent == data.GenesisInfo.NativeDenom.Exponent { - valid = true - break - } - } - } - if !valid { - return fmt.Errorf("denom metadata does not contain display unit with the correct exponent") - } - - // Validate genesis transfers - if data.GenesisTransfer != nil { - if err := data.GenesisTransfer.ValidateBasic(); err != nil { - return errors.Wrap(err, "invalid genesis transfer") - } - - // validate the genesis transfer denom - if data.GenesisInfo.NativeDenom.Base != data.GenesisTransfer.Denom { - return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "denom mismatch") - } - } - - return nil -} - -// converts to a native type and validates that -func (info GenesisBridgeInfo) ValidateBasic() error { - // wrap the genesis info in a GenesisInfo struct, to reuse the validation logic - raGenesisInfo := types.GenesisInfo{ - GenesisChecksum: info.GenesisChecksum, - Bech32Prefix: info.Bech32Prefix, - NativeDenom: info.NativeDenom, - InitialSupply: info.InitialSupply, - GenesisAccounts: &types.GenesisAccounts{Accounts: info.GenesisAccounts}, - } - - if !raGenesisInfo.AllSet() { - return fmt.Errorf("missing fields in genesis info") - } - - return raGenesisInfo.Validate() -} diff --git a/x/rollapp/genesisbridge/genesis_transfer.go b/x/rollapp/genesisbridge/genesis_transfer.go deleted file mode 100644 index 5f24ad1bf..000000000 --- a/x/rollapp/genesisbridge/genesis_transfer.go +++ /dev/null @@ -1,62 +0,0 @@ -package genesisbridge - -import ( - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - - "github.com/dymensionxyz/dymension/v3/x/rollapp/types" - gerrc "github.com/dymensionxyz/gerr-cosmos/gerrc" -) - -const ( - // HubRecipient is the address of `x/rollapp` module's account on the hub chain. - HubRecipient = "dym1mk7pw34ypusacm29m92zshgxee3yreums8avur" -) - -// HandleGenesisTransfer handles the genesis transfer packet, if present, and expected. -// We assume that genesis info is already validated, and the genesis transfer is expected to fulfill the genesis info. -func (w IBCModule) handleGenesisTransfer(ctx sdk.Context, ra types.Rollapp, packet channeltypes.Packet, gTransfer *transfertypes.FungibleTokenPacketData) error { - if ra.GenesisInfo.RequiresTransfer() && gTransfer == nil { - return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis transfer required") - } - if !ra.GenesisInfo.RequiresTransfer() && gTransfer != nil { - return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis transfer not expected") - } - if gTransfer == nil { - return nil - } - - // validate the receiver - if gTransfer.Receiver != HubRecipient { - return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "receiver mismatch") - } - - // validate that the transfer amount matches the expected amount, which is the sum of all genesis accounts - expectedAmount := ra.GenesisInfo.GenesisTransferAmount() - if expectedAmount.String() != gTransfer.Amount { - return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "amount mismatch") - } - - // split the transfer to the genesis accounts - for _, acc := range ra.GenesisInfo.Accounts() { - // create a new packet for each account - data := transfertypes.NewFungibleTokenPacketData( - gTransfer.Denom, - acc.Amount.String(), - gTransfer.Sender, - acc.Address, - "", - ) - - // mint and send tokens to the account - // No event emitted, as we called the transfer keeper directly (vs the transfer middleware stack) - err := w.transferKeeper.OnRecvPacket(ctx, packet, data) - if err != nil { - return errorsmod.Wrapf(err, "on receive packet: %s", acc.Address) - } - } - - return nil -} diff --git a/x/rollapp/genesisbridge/ibc_module.go b/x/rollapp/genesisbridge/ibc_module.go index 7e6ad86f9..3faede4c0 100644 --- a/x/rollapp/genesisbridge/ibc_module.go +++ b/x/rollapp/genesisbridge/ibc_module.go @@ -2,21 +2,14 @@ package genesisbridge import ( "encoding/json" - "errors" - "fmt" - "slices" errorsmod "cosmossdk.io/errors" "github.com/cometbft/cometbft/libs/log" sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" "github.com/cosmos/ibc-go/v7/modules/core/exported" - - "github.com/dymensionxyz/gerr-cosmos/gerrc" "github.com/dymensionxyz/sdk-utils/utils/uevent" - "github.com/dymensionxyz/sdk-utils/utils/uibc" "github.com/dymensionxyz/dymension/v3/x/rollapp/types" ) @@ -101,40 +94,37 @@ func (w IBCModule) OnRecvPacket( l := w.logger(ctx, packet).With("rollapp_id", ra.RollappId) // parse the genesis bridge data - var genesisBridgeData GenesisBridgeData + var genesisBridgeData types.GenesisBridgeData if err := json.Unmarshal(packet.GetData(), &genesisBridgeData); err != nil { l.Error("Unmarshal genesis bridge data.", "err", err) return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "unmarshal genesis bridge data")) } - // stateless validation of the genesis bridge data - if err := genesisBridgeData.ValidateBasic(); err != nil { - l.Error("Validate basic genesis bridge data.", "err", err) - return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "validate basic genesis bridge data")) + // validate the genesis bridge data against the hub's genesis info + err = types.NewGenesisBridgeValidator(genesisBridgeData, ra.GenesisInfo).Validate() + if err != nil { + return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "validate and get actionable data")) } - // validate genesis info against the expected data set on the rollapp - err = w.ValidateGenesisBridge(ra, genesisBridgeData.GenesisInfo) + trace, denom, err := genesisBridgeData.IBCDenom(ra.RollappId, ra.ChannelId) if err != nil { - l.Error("Validate genesis info.", "err", err) - return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "validate genesis info")) + return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "genesis bridge data: to IBC denom")) } - // register the denom metadata. the supplied denom is validated on validateBasic - raBaseDenom, err := w.registerDenomMetadata(ctx, ra.RollappId, ra.ChannelId, genesisBridgeData.NativeDenom) - if err != nil { - l.Error("Register denom metadata.", "err", err) - return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "transfer genesis: register denom metadata")) + genesisPackets := genesisBridgeData.GenesisAccPackets() + + w.transferKeeper.SetDenomTrace(ctx, trace) + if err := w.denomKeeper.CreateDenomMetadata(ctx, denom); err != nil { + return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "create denom metadata")) } - // validate and handle the genesis transfer - err = w.handleGenesisTransfer(ctx, *ra, packet, genesisBridgeData.GenesisTransfer) - if err != nil { - l.Error("Handle genesis transfer.", "err", err) - return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "handle genesis transfer")) + for _, data := range genesisPackets { + if err := w.transferKeeper.OnRecvPacket(ctx, packet, data); err != nil { + return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "handle genesis transfer")) + } } - err = w.EnableTransfers(ctx, ra, raBaseDenom) + err = w.EnableTransfers(ctx, ra, denom.Base) if err != nil { l.Error("Enable transfers.", "err", err) return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "transfer genesis: enable transfers")) @@ -142,7 +132,7 @@ func (w IBCModule) OnRecvPacket( ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeTransfersEnabled, sdk.NewAttribute(types.AttributeKeyRollappId, ra.RollappId), - sdk.NewAttribute(types.AttributeRollappIBCdenom, raBaseDenom), + sdk.NewAttribute(types.AttributeRollappIBCdenom, denom.Base), )) // return success ack @@ -151,79 +141,6 @@ func (w IBCModule) OnRecvPacket( return successAck } -func (w IBCModule) ValidateGenesisBridge(ra *types.Rollapp, data GenesisBridgeInfo) error { - raInfo := ra.GenesisInfo - - if data.GenesisChecksum != raInfo.GenesisChecksum { - return fmt.Errorf("genesis checksum mismatch: expected: %v, got: %v", raInfo.GenesisChecksum, data.GenesisChecksum) - } - - if data.Bech32Prefix != raInfo.Bech32Prefix { - return fmt.Errorf("bech32 prefix mismatch: expected: %v, got: %v", raInfo.Bech32Prefix, data.Bech32Prefix) - } - - if data.NativeDenom != raInfo.NativeDenom { - return fmt.Errorf("native denom mismatch: expected: %v, got: %v", raInfo.NativeDenom, data.NativeDenom) - } - - if !data.InitialSupply.Equal(raInfo.InitialSupply) { - return fmt.Errorf("initial supply mismatch: expected: %v, got: %v", raInfo.InitialSupply, data.InitialSupply) - } - - err := compareGenesisAccounts(raInfo.Accounts(), data.GenesisAccounts) - if err != nil { - return errorsmod.Wrap(err, "genesis accounts mismatch") - } - - return nil -} - -func compareGenesisAccounts(raCommitted []types.GenesisAccount, gbData []types.GenesisAccount) error { - if len(raCommitted) != len(gbData) { - return fmt.Errorf("genesis accounts length mismatch: expected %d, got %d", len(raCommitted), len(gbData)) - } - - for _, acc := range raCommitted { - found := slices.ContainsFunc(gbData, func(dataAcc types.GenesisAccount) bool { - return dataAcc.Address == acc.Address && dataAcc.Amount.Equal(acc.Amount) - }) - - if !found { - return fmt.Errorf("genesis account mismatch: account %s with amount %v not found in data", acc.Address, acc.Amount) - } - } - - return nil -} - -func (w IBCModule) registerDenomMetadata(ctx sdk.Context, rollappID, channelID string, m banktypes.Metadata) (string, error) { - // Set the trace for the ibc denom - trace := uibc.GetForeignDenomTrace(channelID, m.Base) - w.transferKeeper.SetDenomTrace(ctx, trace) - - // Change the base to the ibc denom, and add an alias to the original - m.Base = trace.IBCDenom() - m.Description = fmt.Sprintf("auto-generated ibc denom for rollapp: base: %s: rollapp: %s", m.GetBase(), rollappID) - for i, u := range m.DenomUnits { - if u.Exponent == 0 { - m.DenomUnits[i].Aliases = append(m.DenomUnits[i].Aliases, u.Denom) - m.DenomUnits[i].Denom = m.GetBase() - } - } - - if err := m.Validate(); err != nil { - return "", errorsmod.Wrap(errors.Join(gerrc.ErrInvalidArgument, err), "metadata validate") - } - - // We go by the denom keeper instead of calling bank directly, so denom creation hooks are called - err := w.denomKeeper.CreateDenomMetadata(ctx, m) - if err != nil { - return "", errorsmod.Wrap(err, "create denom metadata") - } - - return m.Base, nil -} - // EnableTransfers marks the end of the genesis bridge phase. // It sets the transfers enabled flag on the rollapp. // It also calls the after transfers enabled hook. diff --git a/x/rollapp/keeper/grpc_query_validate_genesis_bridge.go b/x/rollapp/keeper/grpc_query_validate_genesis_bridge.go new file mode 100644 index 000000000..97dfcd3e3 --- /dev/null +++ b/x/rollapp/keeper/grpc_query_validate_genesis_bridge.go @@ -0,0 +1,33 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/dymensionxyz/dymension/v3/x/rollapp/types" +) + +func (k Keeper) ValidateGenesisBridge(goCtx context.Context, req *types.QueryValidateGenesisBridgeRequest) (*types.QueryValidateGenesisBridgeResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + ra, ok := k.GetRollapp(ctx, req.GetRollappId()) + if !ok { + return nil, status.Error(codes.InvalidArgument, types.ErrRollappNotFound.Error()) + } + + err := types.NewGenesisBridgeValidator(req.Data, ra.GenesisInfo).Validate() + // we want to distinguish between the gRPC error and the error from the validation, + // so we put the validation error in the response + if err != nil { + return &types.QueryValidateGenesisBridgeResponse{Valid: false, Err: err.Error()}, nil + } + + return &types.QueryValidateGenesisBridgeResponse{Valid: true}, nil +} diff --git a/x/rollapp/types/genesis_bridge_data.go b/x/rollapp/types/genesis_bridge_data.go new file mode 100644 index 000000000..f4f415389 --- /dev/null +++ b/x/rollapp/types/genesis_bridge_data.go @@ -0,0 +1,133 @@ +package types + +import ( + "fmt" + + "cosmossdk.io/errors" + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + "github.com/dymensionxyz/gerr-cosmos/gerrc" + "github.com/dymensionxyz/sdk-utils/utils/uibc" + "github.com/dymensionxyz/sdk-utils/utils/uslice" +) + +// ValidateBasic performs basic validation checks on the GenesisBridgeData. +func (d GenesisBridgeData) ValidateBasic() error { + // Validate genesis info + if err := d.GenesisInfo.ValidateBasic(); err != nil { + return errors.Wrap(err, "invalid genesis info") + } + + // Validate metadata + if err := d.NativeDenom.Validate(); err != nil { + return errors.Wrap(err, "invalid metadata") + } + + // validate metadata corresponding to the genesis info denom + // check the base denom, display unit and decimals + if d.NativeDenom.Base != d.GenesisInfo.NativeDenom.Base { + return fmt.Errorf("metadata denom does not match genesis info denom") + } + + // validate the decimals of the display denom + valid := false + for _, unit := range d.NativeDenom.DenomUnits { + if unit.Denom == d.GenesisInfo.NativeDenom.Display { + if unit.Exponent == d.GenesisInfo.NativeDenom.Exponent { + valid = true + break + } + } + } + if !valid { + return fmt.Errorf("denom metadata does not contain display unit with the correct exponent") + } + + // Validate genesis transfers + if d.GenesisTransfer != nil { + if err := d.GenesisTransfer.ValidateBasic(); err != nil { + return errors.Wrap(err, "invalid genesis transfer") + } + + // validate the genesis transfer denom + if d.GenesisInfo.NativeDenom.Base != d.GenesisTransfer.Denom { + return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "denom mismatch") + } + } + + return nil +} + +// IBCDenom extracts the IBC denom trace and metadata from the rollapp native denom. +func (d GenesisBridgeData) IBCDenom(rollappID, channelID string) (transfertypes.DenomTrace, banktypes.Metadata, error) { + m := d.NativeDenom + trace := uibc.GetForeignDenomTrace(channelID, m.Base) + + // Change the base to the ibc denom, and add an alias to the original + m.Base = trace.IBCDenom() + m.Description = fmt.Sprintf("auto-generated ibc denom for rollapp: base: %s: rollapp: %s", m.GetBase(), rollappID) + for i, u := range m.DenomUnits { + if u.Exponent == 0 { + m.DenomUnits[i].Aliases = append(m.DenomUnits[i].Aliases, u.Denom) + m.DenomUnits[i].Denom = m.Base + } + } + + if err := m.Validate(); err != nil { + return transfertypes.DenomTrace{}, banktypes.Metadata{}, fmt.Errorf("validate IBC denom metadata: %w", err) + } + return trace, m, nil +} + +// GenesisAccPackets creates a new packet for each genesis account. +func (d *GenesisBridgeData) GenesisAccPackets() []transfertypes.FungibleTokenPacketData { + return uslice.Map(d.GenesisInfo.Accounts(), func(acc GenesisAccount) transfertypes.FungibleTokenPacketData { + return transfertypes.NewFungibleTokenPacketData( + d.GenesisTransfer.Denom, + acc.Amount.String(), + d.GenesisTransfer.Sender, + acc.Address, + "", + ) + }) +} + +// Handling should be based on length and contents, not nil status +func (i GenesisBridgeInfo) Accounts() []GenesisAccount { + if i.GenesisAccounts == nil { + return nil + } + return i.GenesisAccounts +} + +func (i GenesisBridgeInfo) RequiresTransfer() bool { + return 0 < len(i.Accounts()) +} + +func (i GenesisBridgeInfo) GenesisTransferAmount() math.Int { + total := math.ZeroInt() + for _, a := range i.Accounts() { + total = total.Add(a.Amount) + } + return total +} + +// converts to a native type and validates that +func (i GenesisBridgeInfo) ValidateBasic() error { + // wrap the genesis info in a GenesisInfo struct, to reuse the validation logic + raGenesisInfo := GenesisInfo{ + GenesisChecksum: i.GenesisChecksum, + Bech32Prefix: i.Bech32Prefix, + NativeDenom: i.NativeDenom, + InitialSupply: i.InitialSupply, + GenesisAccounts: &GenesisAccounts{Accounts: i.GenesisAccounts}, + } + + if !raGenesisInfo.AllSet() { + return fmt.Errorf("missing fields in genesis info") + } + + return raGenesisInfo.Validate() +} diff --git a/x/rollapp/genesisbridge/genesis_bridge_data.pb.go b/x/rollapp/types/genesis_bridge_data.pb.go similarity index 82% rename from x/rollapp/genesisbridge/genesis_bridge_data.pb.go rename to x/rollapp/types/genesis_bridge_data.pb.go index 6956ad872..05aeec750 100644 --- a/x/rollapp/genesisbridge/genesis_bridge_data.pb.go +++ b/x/rollapp/types/genesis_bridge_data.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: dymensionxyz/dymension/genesisbridge/genesis_bridge_data.proto +// source: dymensionxyz/dymension/rollapp/genesis_bridge_data.proto -package genesisbridge +package types import ( fmt "fmt" @@ -10,7 +10,6 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" types1 "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - types2 "github.com/dymensionxyz/dymension/v3/x/rollapp/types" io "io" math "math" math_bits "math/bits" @@ -42,7 +41,7 @@ func (m *GenesisBridgeData) Reset() { *m = GenesisBridgeData{} } func (m *GenesisBridgeData) String() string { return proto.CompactTextString(m) } func (*GenesisBridgeData) ProtoMessage() {} func (*GenesisBridgeData) Descriptor() ([]byte, []int) { - return fileDescriptor_6038c1fc23369a68, []int{0} + return fileDescriptor_3b325fcde35853ba, []int{0} } func (m *GenesisBridgeData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -100,18 +99,18 @@ type GenesisBridgeInfo struct { // unique bech32 prefix Bech32Prefix string `protobuf:"bytes,2,opt,name=bech32_prefix,json=bech32Prefix,proto3" json:"bech32_prefix,omitempty"` // native_denom is the base denom for the native token - NativeDenom types2.DenomMetadata `protobuf:"bytes,3,opt,name=native_denom,json=nativeDenom,proto3" json:"native_denom"` + NativeDenom DenomMetadata `protobuf:"bytes,3,opt,name=native_denom,json=nativeDenom,proto3" json:"native_denom"` // initial_supply is the initial supply of the native token InitialSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=initial_supply,json=initialSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"initial_supply"` // accounts on the Hub to fund with some bootstrapping transfers - GenesisAccounts []types2.GenesisAccount `protobuf:"bytes,5,rep,name=genesis_accounts,json=genesisAccounts,proto3" json:"genesis_accounts"` + GenesisAccounts []GenesisAccount `protobuf:"bytes,5,rep,name=genesis_accounts,json=genesisAccounts,proto3" json:"genesis_accounts"` } func (m *GenesisBridgeInfo) Reset() { *m = GenesisBridgeInfo{} } func (m *GenesisBridgeInfo) String() string { return proto.CompactTextString(m) } func (*GenesisBridgeInfo) ProtoMessage() {} func (*GenesisBridgeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_6038c1fc23369a68, []int{1} + return fileDescriptor_3b325fcde35853ba, []int{1} } func (m *GenesisBridgeInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -154,14 +153,14 @@ func (m *GenesisBridgeInfo) GetBech32Prefix() string { return "" } -func (m *GenesisBridgeInfo) GetNativeDenom() types2.DenomMetadata { +func (m *GenesisBridgeInfo) GetNativeDenom() DenomMetadata { if m != nil { return m.NativeDenom } - return types2.DenomMetadata{} + return DenomMetadata{} } -func (m *GenesisBridgeInfo) GetGenesisAccounts() []types2.GenesisAccount { +func (m *GenesisBridgeInfo) GetGenesisAccounts() []GenesisAccount { if m != nil { return m.GenesisAccounts } @@ -169,49 +168,49 @@ func (m *GenesisBridgeInfo) GetGenesisAccounts() []types2.GenesisAccount { } func init() { - proto.RegisterType((*GenesisBridgeData)(nil), "dymensionxyz.dymension.genesisbridge.GenesisBridgeData") - proto.RegisterType((*GenesisBridgeInfo)(nil), "dymensionxyz.dymension.genesisbridge.GenesisBridgeInfo") + proto.RegisterType((*GenesisBridgeData)(nil), "dymensionxyz.dymension.rollapp.GenesisBridgeData") + proto.RegisterType((*GenesisBridgeInfo)(nil), "dymensionxyz.dymension.rollapp.GenesisBridgeInfo") } func init() { - proto.RegisterFile("dymensionxyz/dymension/genesisbridge/genesis_bridge_data.proto", fileDescriptor_6038c1fc23369a68) + proto.RegisterFile("dymensionxyz/dymension/rollapp/genesis_bridge_data.proto", fileDescriptor_3b325fcde35853ba) } -var fileDescriptor_6038c1fc23369a68 = []byte{ - // 528 bytes of a gzipped FileDescriptorProto +var fileDescriptor_3b325fcde35853ba = []byte{ + // 515 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0xdb, 0x6d, 0x20, 0x2d, 0xed, 0xf8, 0x13, 0x71, 0xa8, 0x2a, 0x91, 0x4d, 0x03, 0xa1, - 0xed, 0x50, 0x5b, 0x6d, 0x85, 0xb8, 0x20, 0x24, 0xca, 0x34, 0xb4, 0x03, 0xd2, 0x54, 0xc6, 0x0e, - 0x5c, 0x32, 0xc7, 0x71, 0x53, 0x2b, 0x89, 0x6d, 0xc5, 0x4e, 0xd4, 0xf2, 0x29, 0xf8, 0x06, 0x7c, - 0x9d, 0x1d, 0x77, 0x44, 0x1c, 0x26, 0xd4, 0x7e, 0x04, 0xbe, 0x00, 0x8a, 0xed, 0xb4, 0x5d, 0xa5, - 0x32, 0x4e, 0xed, 0xfb, 0xf6, 0x7d, 0x1f, 0x3f, 0xcf, 0xaf, 0xaf, 0xf3, 0x2e, 0x9c, 0xa6, 0x84, - 0x49, 0xca, 0xd9, 0x64, 0xfa, 0x0d, 0x2e, 0x0a, 0x18, 0x11, 0x46, 0x24, 0x95, 0x41, 0x46, 0xc3, - 0x88, 0x54, 0x95, 0x6f, 0x4a, 0x3f, 0x44, 0x0a, 0x01, 0x91, 0x71, 0xc5, 0xdd, 0x97, 0xab, 0xfb, - 0x60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0xb9, 0x57, 0xfb, 0xfa, - 0x76, 0xc5, 0xf1, 0x86, 0x7b, 0x2f, 0xfa, 0x70, 0xb2, 0x7e, 0xf4, 0xe6, 0x38, 0x83, 0x87, 0xfa, - 0xec, 0xfb, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xc1, 0x44, 0xd3, 0x21, 0x04, 0x00, 0x00, + 0x18, 0xc6, 0x9b, 0x6d, 0x20, 0x2d, 0xed, 0xf8, 0x13, 0x71, 0x88, 0x2a, 0x91, 0x4d, 0x43, 0x42, + 0xdb, 0xa1, 0xb6, 0x9a, 0x82, 0xc4, 0x95, 0x32, 0x0d, 0xed, 0x00, 0x9a, 0xca, 0xe0, 0xb0, 0x4b, + 0x70, 0x1c, 0x37, 0xb5, 0x92, 0xd8, 0x56, 0xec, 0x44, 0x2d, 0x9f, 0x82, 0x2b, 0xdf, 0x68, 0xc7, + 0x1d, 0x11, 0x87, 0x09, 0xb5, 0x1f, 0x81, 0x2f, 0x80, 0xe2, 0x38, 0x6d, 0x99, 0xc4, 0xd6, 0x53, + 0xfb, 0xbe, 0x79, 0xdf, 0xc7, 0xcf, 0xf3, 0xd3, 0x6b, 0xbf, 0x89, 0x66, 0x19, 0x61, 0x92, 0x72, + 0x36, 0x9d, 0x7d, 0x83, 0xcb, 0x02, 0xe6, 0x3c, 0x4d, 0x91, 0x10, 0x30, 0x26, 0x8c, 0x48, 0x2a, + 0x83, 0x30, 0xa7, 0x51, 0x4c, 0x82, 0x08, 0x29, 0x04, 0x44, 0xce, 0x15, 0x77, 0xbc, 0xf5, 0x4d, + 0xb0, 0x2c, 0x80, 0xd9, 0xec, 0x3e, 0x8b, 0x79, 0xcc, 0xf5, 0x28, 0xac, 0xfe, 0xd5, 0x5b, 0x5d, + 0x0f, 0x73, 0x99, 0x71, 0x09, 0x43, 0xc4, 0x12, 0x58, 0xf6, 0x43, 0xa2, 0x50, 0x5f, 0x17, 0xe6, + 0xfb, 0x31, 0x0d, 0x31, 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, 0x61, 0xef, 0x85, 0x04, 0x4f, 0x06, + 0x7e, 0x20, 0x72, 0x32, 0xa6, 0x53, 0x9d, 0x75, 0x77, 0xd4, 0xa9, 0x9b, 0xe7, 0xba, 0xe7, 0x7c, + 0xb9, 0xc5, 0xa3, 0xce, 0xd0, 0xbb, 0x8f, 0xb5, 0x86, 0x70, 0x17, 0x9f, 0xcf, 0xf6, 0x23, 0xca, + 0xa8, 0xa2, 0x28, 0x0d, 0x64, 0x21, 0x44, 0x3a, 0x73, 0x77, 0xaa, 0xd7, 0x87, 0xa0, 0x1a, 0xfd, + 0x75, 0xb3, 0xff, 0x32, 0xa6, 0x6a, 0x52, 0x84, 0x00, 0xf3, 0x0c, 0x9a, 0x8b, 0xad, 0x7f, 0x7a, + 0x32, 0x4a, 0xa0, 0x9a, 0x09, 0x22, 0xc1, 0x19, 0x53, 0xa3, 0x3d, 0xa3, 0xf2, 0x49, 0x8b, 0x38, + 0xc1, 0x2a, 0x3e, 0xc2, 0x98, 0x17, 0x4c, 0x49, 0xf7, 0xc1, 0xc1, 0xf6, 0x51, 0xdb, 0x07, 0x1b, + 0x9e, 0xc7, 0xdb, 0x7a, 0xcd, 0x78, 0x6e, 0xa0, 0x99, 0xae, 0x1c, 0x7e, 0xbc, 0x9a, 0x7b, 0xd6, + 0xf5, 0xdc, 0xb3, 0x7e, 0xcf, 0x3d, 0xeb, 0xfb, 0xc2, 0x6b, 0x5d, 0x2f, 0xbc, 0xd6, 0xcf, 0x85, + 0xd7, 0xba, 0x7c, 0xb5, 0xe6, 0xf8, 0x3f, 0x97, 0x5e, 0x0e, 0xe0, 0x74, 0x79, 0xee, 0x3a, 0x43, + 0xf8, 0x50, 0x1f, 0xfa, 0xe0, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x25, 0x6b, 0x0a, 0x02, 0x07, + 0x04, 0x00, 0x00, } func (m *GenesisBridgeData) Marshal() (dAtA []byte, err error) { @@ -742,7 +741,7 @@ func (m *GenesisBridgeInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.GenesisAccounts = append(m.GenesisAccounts, types2.GenesisAccount{}) + m.GenesisAccounts = append(m.GenesisAccounts, GenesisAccount{}) if err := m.GenesisAccounts[len(m.GenesisAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/rollapp/genesisbridge/genesis_bridge_data_test.go b/x/rollapp/types/genesis_bridge_data_test.go similarity index 86% rename from x/rollapp/genesisbridge/genesis_bridge_data_test.go rename to x/rollapp/types/genesis_bridge_data_test.go index f67c2cbe9..24296e9c7 100644 --- a/x/rollapp/genesisbridge/genesis_bridge_data_test.go +++ b/x/rollapp/types/genesis_bridge_data_test.go @@ -1,4 +1,4 @@ -package genesisbridge_test +package types_test import ( "testing" @@ -8,12 +8,11 @@ import ( transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" "github.com/stretchr/testify/require" - "github.com/dymensionxyz/dymension/v3/x/rollapp/genesisbridge" "github.com/dymensionxyz/dymension/v3/x/rollapp/types" ) func TestGenesisBridgeData_ValidateBasic(t *testing.T) { - validGenInfo := genesisbridge.GenesisBridgeInfo{ + validGenInfo := types.GenesisBridgeInfo{ GenesisChecksum: "checksum", Bech32Prefix: "prefix", NativeDenom: types.DenomMetadata{ @@ -52,12 +51,12 @@ func TestGenesisBridgeData_ValidateBasic(t *testing.T) { tests := []struct { name string - data genesisbridge.GenesisBridgeData + data types.GenesisBridgeData wantErr bool }{ { name: "valid data", - data: genesisbridge.GenesisBridgeData{ + data: types.GenesisBridgeData{ GenesisInfo: validGenInfo, NativeDenom: validMetadata, }, @@ -65,7 +64,7 @@ func TestGenesisBridgeData_ValidateBasic(t *testing.T) { }, { name: "valid data with genesis transfer", - data: genesisbridge.GenesisBridgeData{ + data: types.GenesisBridgeData{ GenesisInfo: validGenInfo, NativeDenom: validMetadata, GenesisTransfer: &validGenTransfer, @@ -74,8 +73,8 @@ func TestGenesisBridgeData_ValidateBasic(t *testing.T) { }, { name: "invalid genesis info", - data: genesisbridge.GenesisBridgeData{ - GenesisInfo: genesisbridge.GenesisBridgeInfo{ + data: types.GenesisBridgeData{ + GenesisInfo: types.GenesisBridgeInfo{ GenesisChecksum: "", Bech32Prefix: "prefix", NativeDenom: types.DenomMetadata{ @@ -92,7 +91,7 @@ func TestGenesisBridgeData_ValidateBasic(t *testing.T) { }, { name: "invalid metadata", - data: genesisbridge.GenesisBridgeData{ + data: types.GenesisBridgeData{ GenesisInfo: validGenInfo, NativeDenom: banktypes.Metadata{ Base: "base", @@ -113,7 +112,7 @@ func TestGenesisBridgeData_ValidateBasic(t *testing.T) { }, { name: "invalid genesis transfer", - data: genesisbridge.GenesisBridgeData{ + data: types.GenesisBridgeData{ GenesisInfo: validGenInfo, NativeDenom: validMetadata, GenesisTransfer: &transfertypes.FungibleTokenPacketData{ @@ -128,7 +127,7 @@ func TestGenesisBridgeData_ValidateBasic(t *testing.T) { }, { name: "metadata not matching genesis info denom", - data: genesisbridge.GenesisBridgeData{ + data: types.GenesisBridgeData{ GenesisInfo: validGenInfo, NativeDenom: banktypes.Metadata{ Base: "base", @@ -149,7 +148,7 @@ func TestGenesisBridgeData_ValidateBasic(t *testing.T) { }, { name: "genesis transfer denom is wrong", - data: genesisbridge.GenesisBridgeData{ + data: types.GenesisBridgeData{ GenesisInfo: validGenInfo, NativeDenom: validMetadata, GenesisTransfer: &transfertypes.FungibleTokenPacketData{ @@ -164,8 +163,8 @@ func TestGenesisBridgeData_ValidateBasic(t *testing.T) { }, { name: "duplicate genesis accounts", - data: genesisbridge.GenesisBridgeData{ - GenesisInfo: genesisbridge.GenesisBridgeInfo{ + data: types.GenesisBridgeData{ + GenesisInfo: types.GenesisBridgeInfo{ GenesisChecksum: "checksum", Bech32Prefix: "prefix", NativeDenom: types.DenomMetadata{ @@ -200,12 +199,12 @@ func TestGenesisBridgeData_ValidateBasic(t *testing.T) { func TestGenesisBridgeInfo_ValidateBasic(t *testing.T) { tests := []struct { name string - info genesisbridge.GenesisBridgeInfo + info types.GenesisBridgeInfo wantErr bool }{ { name: "valid info", - info: genesisbridge.GenesisBridgeInfo{ + info: types.GenesisBridgeInfo{ GenesisChecksum: "checksum", Bech32Prefix: "prefix", NativeDenom: types.DenomMetadata{ @@ -220,7 +219,7 @@ func TestGenesisBridgeInfo_ValidateBasic(t *testing.T) { }, { name: "missing fields", - info: genesisbridge.GenesisBridgeInfo{ + info: types.GenesisBridgeInfo{ GenesisChecksum: "", Bech32Prefix: "prefix", NativeDenom: types.DenomMetadata{ diff --git a/x/rollapp/types/genesis_bridge_data_validator.go b/x/rollapp/types/genesis_bridge_data_validator.go new file mode 100644 index 000000000..3a360d5b5 --- /dev/null +++ b/x/rollapp/types/genesis_bridge_data_validator.go @@ -0,0 +1,123 @@ +package types + +import ( + "errors" + "fmt" + "slices" + + errorsmod "cosmossdk.io/errors" + "github.com/dymensionxyz/gerr-cosmos/gerrc" +) + +// HubRecipient is the address of `x/rollapp` module's account on the rollapp chain. +const HubRecipient = "dym1mk7pw34ypusacm29m92zshgxee3yreums8avur" + +type GenesisBridgeValidator struct { + rollapp GenesisBridgeData // what the rollapp sent over IBC + hub GenesisInfo // what the rollapp thinks is correct +} + +func NewGenesisBridgeValidator( + rollappGenesis GenesisBridgeData, + hubGenesis GenesisInfo, +) *GenesisBridgeValidator { + return &GenesisBridgeValidator{ + rollapp: rollappGenesis, + hub: hubGenesis, + } +} + +func (v *GenesisBridgeValidator) Validate() error { + if err := v.rollapp.ValidateBasic(); err != nil { + return errorsmod.Wrap(err, "validate basic genesis bridge data") + } + + if err := validateAgainstHub(v.rollapp.GenesisInfo, v.hub); err != nil { + return errorsmod.Wrap(err, "validate against rollapp") + } + + err := v.rollapp.NativeDenom.Validate() + if err != nil { + return errorsmod.Wrap(errors.Join(gerrc.ErrInvalidArgument, err), "metadata validate") + } + + err = v.validateGenesisTransfer() + if err != nil { + return errorsmod.Wrap(err, "validate genesis transfer") + } + + return nil +} + +func validateAgainstHub(rollapp GenesisBridgeInfo, hub GenesisInfo) error { + if rollapp.GenesisChecksum != hub.GenesisChecksum { + return fmt.Errorf("genesis checksum mismatch: expected: %v, got: %v", hub.GenesisChecksum, rollapp.GenesisChecksum) + } + + if rollapp.Bech32Prefix != hub.Bech32Prefix { + return fmt.Errorf("bech32 prefix mismatch: expected: %v, got: %v", hub.Bech32Prefix, rollapp.Bech32Prefix) + } + + if rollapp.NativeDenom != hub.NativeDenom { + return fmt.Errorf("native denom mismatch: expected: %v, got: %v", hub.NativeDenom, rollapp.NativeDenom) + } + + if !rollapp.InitialSupply.Equal(hub.InitialSupply) { + return fmt.Errorf("initial supply mismatch: expected: %v, got: %v", hub.InitialSupply, rollapp.InitialSupply) + } + + err := compareGenesisAccounts(hub.Accounts(), rollapp.Accounts()) + if err != nil { + return errorsmod.Wrap(err, "genesis accounts mismatch") + } + return nil +} + +func compareGenesisAccounts(raCommitted []GenesisAccount, gbData []GenesisAccount) error { + if len(raCommitted) != len(gbData) { + return fmt.Errorf("genesis accounts length mismatch: expected %d, got %d", len(raCommitted), len(gbData)) + } + + for _, acc := range raCommitted { + found := slices.ContainsFunc(gbData, func(dataAcc GenesisAccount) bool { + return dataAcc.Address == acc.Address && dataAcc.Amount.Equal(acc.Amount) + }) + + if !found { + return fmt.Errorf("genesis account mismatch: account %s with amount %v not found in data", acc.Address, acc.Amount) + } + } + + return nil +} + +// validateGenesisTransfer validates the genesis transfer. +func (v *GenesisBridgeValidator) validateGenesisTransfer() error { + gTransfer := v.rollapp.GenesisTransfer + requiresTransfer := v.hub.RequiresTransfer() + + // required but not present + if requiresTransfer && gTransfer == nil { + return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis transfer required") + } + // not required but present + if !requiresTransfer && gTransfer != nil { + return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "genesis transfer not expected") + } + if gTransfer == nil { + return nil + } + + // validate the receiver + if gTransfer.Receiver != HubRecipient { + return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "receiver mismatch") + } + + // validate that the transfer amount matches the expected amount, which is the sum of all genesis accounts + expectedAmount := v.hub.GenesisTransferAmount() + if expectedAmount.String() != gTransfer.Amount { + return errorsmod.Wrap(gerrc.ErrFailedPrecondition, "amount mismatch") + } + + return nil +} diff --git a/x/rollapp/types/query.pb.go b/x/rollapp/types/query.pb.go index f86e67779..f731e925c 100644 --- a/x/rollapp/types/query.pb.go +++ b/x/rollapp/types/query.pb.go @@ -857,6 +857,110 @@ func (m *QueryObsoleteDRSVersionsResponse) GetDrsVersions() []uint32 { return nil } +type QueryValidateGenesisBridgeRequest struct { + RollappId string `protobuf:"bytes,1,opt,name=rollappId,proto3" json:"rollappId,omitempty"` + Data GenesisBridgeData `protobuf:"bytes,2,opt,name=data,proto3" json:"data"` +} + +func (m *QueryValidateGenesisBridgeRequest) Reset() { *m = QueryValidateGenesisBridgeRequest{} } +func (m *QueryValidateGenesisBridgeRequest) String() string { return proto.CompactTextString(m) } +func (*QueryValidateGenesisBridgeRequest) ProtoMessage() {} +func (*QueryValidateGenesisBridgeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_00a0238fb38306fa, []int{17} +} +func (m *QueryValidateGenesisBridgeRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryValidateGenesisBridgeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryValidateGenesisBridgeRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryValidateGenesisBridgeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryValidateGenesisBridgeRequest.Merge(m, src) +} +func (m *QueryValidateGenesisBridgeRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryValidateGenesisBridgeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryValidateGenesisBridgeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryValidateGenesisBridgeRequest proto.InternalMessageInfo + +func (m *QueryValidateGenesisBridgeRequest) GetRollappId() string { + if m != nil { + return m.RollappId + } + return "" +} + +func (m *QueryValidateGenesisBridgeRequest) GetData() GenesisBridgeData { + if m != nil { + return m.Data + } + return GenesisBridgeData{} +} + +type QueryValidateGenesisBridgeResponse struct { + Valid bool `protobuf:"varint,1,opt,name=valid,proto3" json:"valid,omitempty"` + Err string `protobuf:"bytes,2,opt,name=err,proto3" json:"err,omitempty"` +} + +func (m *QueryValidateGenesisBridgeResponse) Reset() { *m = QueryValidateGenesisBridgeResponse{} } +func (m *QueryValidateGenesisBridgeResponse) String() string { return proto.CompactTextString(m) } +func (*QueryValidateGenesisBridgeResponse) ProtoMessage() {} +func (*QueryValidateGenesisBridgeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_00a0238fb38306fa, []int{18} +} +func (m *QueryValidateGenesisBridgeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryValidateGenesisBridgeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryValidateGenesisBridgeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryValidateGenesisBridgeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryValidateGenesisBridgeResponse.Merge(m, src) +} +func (m *QueryValidateGenesisBridgeResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryValidateGenesisBridgeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryValidateGenesisBridgeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryValidateGenesisBridgeResponse proto.InternalMessageInfo + +func (m *QueryValidateGenesisBridgeResponse) GetValid() bool { + if m != nil { + return m.Valid + } + return false +} + +func (m *QueryValidateGenesisBridgeResponse) GetErr() string { + if m != nil { + return m.Err + } + return "" +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "dymensionxyz.dymension.rollapp.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "dymensionxyz.dymension.rollapp.QueryParamsResponse") @@ -875,6 +979,8 @@ func init() { proto.RegisterType((*QueryRegisteredDenomsResponse)(nil), "dymensionxyz.dymension.rollapp.QueryRegisteredDenomsResponse") proto.RegisterType((*QueryObsoleteDRSVersionsRequest)(nil), "dymensionxyz.dymension.rollapp.QueryObsoleteDRSVersionsRequest") proto.RegisterType((*QueryObsoleteDRSVersionsResponse)(nil), "dymensionxyz.dymension.rollapp.QueryObsoleteDRSVersionsResponse") + proto.RegisterType((*QueryValidateGenesisBridgeRequest)(nil), "dymensionxyz.dymension.rollapp.QueryValidateGenesisBridgeRequest") + proto.RegisterType((*QueryValidateGenesisBridgeResponse)(nil), "dymensionxyz.dymension.rollapp.QueryValidateGenesisBridgeResponse") } func init() { @@ -882,75 +988,82 @@ func init() { } var fileDescriptor_00a0238fb38306fa = []byte{ - // 1078 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0x38, 0xae, 0x13, 0xbf, 0xb4, 0x22, 0x9a, 0x46, 0x21, 0xb8, 0xc1, 0x75, 0x17, 0xa9, - 0x75, 0x0b, 0xda, 0x95, 0x63, 0xdc, 0x10, 0xa5, 0x29, 0x75, 0x94, 0x36, 0xa4, 0x82, 0x12, 0x36, - 0xfc, 0x11, 0x20, 0x64, 0xad, 0xeb, 0x89, 0xb3, 0x68, 0xbd, 0xbb, 0xf5, 0x6c, 0x22, 0xbb, 0x51, - 0x2e, 0x88, 0x0f, 0x80, 0xc4, 0x27, 0xe0, 0x0b, 0x70, 0xe5, 0x8c, 0xb8, 0x44, 0x88, 0x43, 0x25, - 0x0e, 0x70, 0x01, 0xa1, 0x84, 0xef, 0xc0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0xc5, - 0x62, 0xa6, 0xde, 0x88, 0x19, 0xa7, 0x6c, 0x08, 0x55, 0xab, 0xb4, 0x14, 0xa5, 0xca, 0x41, 0x90, - 0x4a, 0x78, 0x24, 0x6e, 0x3e, 0x39, 0x3d, 0xcb, 0x92, 0x17, 0x67, 0x59, 0xf2, 0xd7, 0x59, 0x96, - 0x7c, 0x73, 0x9e, 0x9d, 0x7a, 0x71, 0x9e, 0x9d, 0xfa, 0xfd, 0x3c, 0x3b, 0xf5, 0xd9, 0x9b, 0x75, - 0xd3, 0x3b, 0x38, 0xac, 0xaa, 0x4f, 0x9d, 0xc6, 0x30, 0xe8, 0xa3, 0xa2, 0xd6, 0x0a, 0xf0, 0xbd, - 0xb6, 0xcb, 0x78, 0x35, 0x25, 0x3e, 0xf9, 0x8a, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xce, - 0xc4, 0xdb, 0x56, 0x0f, 0x00, 0x00, + // 1188 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0x38, 0xae, 0x13, 0xbf, 0x16, 0x35, 0x9a, 0x86, 0x10, 0xdc, 0xe0, 0x26, 0x8b, 0xd4, + 0xba, 0x05, 0x79, 0xe5, 0x04, 0x37, 0x8d, 0xd2, 0x94, 0x3a, 0x4a, 0x1b, 0x52, 0x4a, 0x09, 0x1b, + 0x28, 0x02, 0x84, 0xac, 0x75, 0x77, 0xb2, 0x59, 0xb4, 0xde, 0xdd, 0xee, 0x6c, 0xa2, 0xb8, 0x51, + 0x2e, 0x88, 0x33, 0x42, 0xe2, 0x5e, 0x89, 0x7f, 0x80, 0x2b, 0x67, 0xc4, 0x25, 0x42, 0x1c, 0x2a, + 0x71, 0x80, 0x0b, 0x08, 0x25, 0xfc, 0x0f, 0x5c, 0x91, 0x67, 0xde, 0xae, 0x7f, 0x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ca, 0x30, 0xd8, 0x7e, + 0x87, 0xbe, 0x23, 0x02, 0xd9, 0xa8, 0xd9, 0xd0, 0x5b, 0x49, 0x79, 0x75, 0xf7, 0xda, 0xdc, 0xd2, + 0x10, 0x9e, 0x67, 0x95, 0xd2, 0xfa, 0x52, 0x6a, 0x97, 0xa0, 0x1e, 0x08, 0x55, 0x87, 0xf4, 0x67, + 0x02, 0x13, 0xdd, 0x6d, 0x8d, 0x26, 0x0b, 0xa0, 0x3e, 0xbd, 0x34, 0xb7, 0x32, 0xa4, 0x37, 0x2a, + 0x5b, 0x12, 0xca, 0x16, 0x68, 0x29, 0x36, 0x79, 0x22, 0x84, 0xaa, 0x6c, 0xb7, 0xf4, 0x37, 0x02, + 0x97, 0x7a, 0xf4, 0xd1, 0x84, 0xa1, 0xd7, 0xbf, 0x49, 0x27, 0x0c, 0xbd, 0x01, 0x2d, 0x5c, 0x59, + 0x11, 0xaa, 0x16, 0x69, 0x39, 0x4e, 0x95, 0x8b, 0x20, 0xd5, 0xf6, 0x8e, 0x4f, 0x9f, 0x13, 0x78, + 0xb9, 0x67, 0x27, 0xa5, 0x95, 0x44, 0xd4, 0x06, 0x4d, 0x05, 0xb9, 0xd5, 0xff, 0x02, 0x81, 0x13, + 0xeb, 0xa3, 0xa3, 0xe3, 0x3c, 0x79, 0x71, 0x9c, 0x27, 0x7f, 0x1d, 0xe7, 0xc9, 0x37, 0x27, 0xf9, + 0x91, 0x17, 0x27, 0xf9, 0x91, 0xdf, 0x4f, 0xf2, 0x23, 0x9f, 0xbe, 0x65, 0x5a, 0xc1, 0xce, 0x6e, + 0xad, 0xf8, 0xc4, 0xad, 0xf7, 0xd3, 0xbe, 0xb7, 0xa0, 0xee, 0x47, 0x17, 0x10, 0x34, 0x3c, 0xc6, + 0x6b, 0x19, 0xf1, 0xc9, 0xbd, 0xf0, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x67, 0xd2, 0xff, 0xd0, + 0x10, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -983,6 +1096,8 @@ type QueryClient interface { RegisteredDenoms(ctx context.Context, in *QueryRegisteredDenomsRequest, opts ...grpc.CallOption) (*QueryRegisteredDenomsResponse, error) // Queries a list of obsolete DRS versions. ObsoleteDRSVersions(ctx context.Context, in *QueryObsoleteDRSVersionsRequest, opts ...grpc.CallOption) (*QueryObsoleteDRSVersionsResponse, error) + // Validates provided genesis bridge data against the hub. + ValidateGenesisBridge(ctx context.Context, in *QueryValidateGenesisBridgeRequest, opts ...grpc.CallOption) (*QueryValidateGenesisBridgeResponse, error) } type queryClient struct { @@ -1074,6 +1189,15 @@ func (c *queryClient) ObsoleteDRSVersions(ctx context.Context, in *QueryObsolete return out, nil } +func (c *queryClient) ValidateGenesisBridge(ctx context.Context, in *QueryValidateGenesisBridgeRequest, opts ...grpc.CallOption) (*QueryValidateGenesisBridgeResponse, error) { + out := new(QueryValidateGenesisBridgeResponse) + err := c.cc.Invoke(ctx, "/dymensionxyz.dymension.rollapp.Query/ValidateGenesisBridge", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -1094,6 +1218,8 @@ type QueryServer interface { RegisteredDenoms(context.Context, *QueryRegisteredDenomsRequest) (*QueryRegisteredDenomsResponse, error) // Queries a list of obsolete DRS versions. ObsoleteDRSVersions(context.Context, *QueryObsoleteDRSVersionsRequest) (*QueryObsoleteDRSVersionsResponse, error) + // Validates provided genesis bridge data against the hub. + ValidateGenesisBridge(context.Context, *QueryValidateGenesisBridgeRequest) (*QueryValidateGenesisBridgeResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1127,6 +1253,9 @@ func (*UnimplementedQueryServer) RegisteredDenoms(ctx context.Context, req *Quer func (*UnimplementedQueryServer) ObsoleteDRSVersions(ctx context.Context, req *QueryObsoleteDRSVersionsRequest) (*QueryObsoleteDRSVersionsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ObsoleteDRSVersions not implemented") } +func (*UnimplementedQueryServer) ValidateGenesisBridge(ctx context.Context, req *QueryValidateGenesisBridgeRequest) (*QueryValidateGenesisBridgeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ValidateGenesisBridge not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1294,6 +1423,24 @@ func _Query_ObsoleteDRSVersions_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _Query_ValidateGenesisBridge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryValidateGenesisBridgeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ValidateGenesisBridge(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dymensionxyz.dymension.rollapp.Query/ValidateGenesisBridge", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ValidateGenesisBridge(ctx, req.(*QueryValidateGenesisBridgeRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "dymensionxyz.dymension.rollapp.Query", HandlerType: (*QueryServer)(nil), @@ -1334,6 +1481,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ObsoleteDRSVersions", Handler: _Query_ObsoleteDRSVersions_Handler, }, + { + MethodName: "ValidateGenesisBridge", + Handler: _Query_ValidateGenesisBridge_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "dymensionxyz/dymension/rollapp/query.proto", @@ -1974,6 +2125,86 @@ func (m *QueryObsoleteDRSVersionsResponse) MarshalToSizedBuffer(dAtA []byte) (in return len(dAtA) - i, nil } +func (m *QueryValidateGenesisBridgeRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryValidateGenesisBridgeRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryValidateGenesisBridgeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Data.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.RollappId) > 0 { + i -= len(m.RollappId) + copy(dAtA[i:], m.RollappId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RollappId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryValidateGenesisBridgeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryValidateGenesisBridgeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryValidateGenesisBridgeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Err) > 0 { + i -= len(m.Err) + copy(dAtA[i:], m.Err) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Err))) + i-- + dAtA[i] = 0x12 + } + if m.Valid { + i-- + if m.Valid { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2231,6 +2462,37 @@ func (m *QueryObsoleteDRSVersionsResponse) Size() (n int) { return n } +func (m *QueryValidateGenesisBridgeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RollappId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.Data.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryValidateGenesisBridgeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Valid { + n += 2 + } + l = len(m.Err) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3856,6 +4118,223 @@ func (m *QueryObsoleteDRSVersionsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryValidateGenesisBridgeRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryValidateGenesisBridgeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryValidateGenesisBridgeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RollappId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RollappId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryValidateGenesisBridgeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryValidateGenesisBridgeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryValidateGenesisBridgeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Valid", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Valid = bool(v != 0) + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Err", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Err = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0