diff --git a/CHANGELOG.md b/CHANGELOG.md index 040943c9..ebe1fce2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,17 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +## [v1.5.0] - 2023-07-20 + +### Improvements + +* (iritamod/sidechain) [\#90](https://github.com/bianjieai/iritamod/pull/90) enhance side-chain module query +* (iritamod/perm) [\#90](https://github.com/bianjieai/iritamod/pull/90) correct name for side-chain user role + +### Bug Fixes + +* (iritamod/perm) [\#90](https://github.com/bianjieai/iritamod/pull/90) multiple transfer space msgs should fail + ## [v1.4.0] - 2023-07-18 ### Application diff --git a/modules/perm/alias.go b/modules/perm/alias.go index f1806468..1e4f6d72 100644 --- a/modules/perm/alias.go +++ b/modules/perm/alias.go @@ -27,7 +27,7 @@ const ( RoleRelayerUser = types.RoleRelayerUser RolePlatformUser = types.RolePlatformUser RolePowerUserAdmin = types.RolePowerUserAdmin - RoleLayer2User = types.RoleLayer2User + RoleSideChainUser = types.RoleSideChainUser ) var ( diff --git a/modules/perm/client/cli/tx.go b/modules/perm/client/cli/tx.go index 89081f5e..61703c9b 100644 --- a/modules/perm/client/cli/tx.go +++ b/modules/perm/client/cli/tx.go @@ -50,7 +50,7 @@ func NewAssignRolesCmd() *cobra.Command { types.RoleRelayerUser, types.RolePlatformUser, types.RolePowerUserAdmin, - types.RoleLayer2User, + types.RoleSideChainUser, )), Args: cobra.MinimumNArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -105,7 +105,7 @@ func NewUnassignRolesCmd() *cobra.Command { types.RoleRelayerUser, types.RolePlatformUser, types.RolePowerUserAdmin, - types.RoleLayer2User, + types.RoleSideChainUser, )), Args: cobra.MinimumNArgs(2), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/modules/perm/keeper/keeper_test.go b/modules/perm/keeper/keeper_test.go index 2d1e9c7f..8c52d7a1 100644 --- a/modules/perm/keeper/keeper_test.go +++ b/modules/perm/keeper/keeper_test.go @@ -210,7 +210,7 @@ func (suite *KeeperTestSuite) TestPowerAdmin() { types.RoleBaseM1Admin, types.RolePlatformUser, types.RolePowerUserAdmin, - types.RoleLayer2User, + types.RoleSideChainUser, } for _, role := range roles { err = suite.keeper.Authorize(suite.ctx, accountPowerUser, accountPowerUserAdmin, role) diff --git a/modules/perm/types/auth.go b/modules/perm/types/auth.go index e9519e88..af30b0f4 100644 --- a/modules/perm/types/auth.go +++ b/modules/perm/types/auth.go @@ -40,8 +40,8 @@ func (a Auth) Roles() (rs []Role) { if a.Access(RolePowerUserAdmin.Auth()) { rs = append(rs, RolePowerUserAdmin) } - if a.Access(RoleLayer2User.Auth()) { - rs = append(rs, RoleLayer2User) + if a.Access(RoleSideChainUser.Auth()) { + rs = append(rs, RoleSideChainUser) } return rs diff --git a/modules/perm/types/perm.pb.go b/modules/perm/types/perm.pb.go index a8876cc9..3d991321 100644 --- a/modules/perm/types/perm.pb.go +++ b/modules/perm/types/perm.pb.go @@ -50,8 +50,8 @@ const ( RolePlatformUser Role = 9 // POWER_USER_ADMIN defines the power admin role index. RolePowerUserAdmin Role = 10 - //LAYER2_USER defines the layer2 user role index. - RoleLayer2User Role = 11 + // SIDE_CHAIN_USER defines the side chain user role index. + RoleSideChainUser Role = 11 ) var Role_name = map[int32]string{ @@ -66,7 +66,7 @@ var Role_name = map[int32]string{ 8: "BASE_M1_ADMIN", 9: "PLATFORM_USER", 10: "POWER_USER_ADMIN", - 11: "LAYER2_USER", + 11: "SIDE_CHAIN_USER", } var Role_value = map[string]int32{ @@ -81,7 +81,7 @@ var Role_value = map[string]int32{ "BASE_M1_ADMIN": 8, "PLATFORM_USER": 9, "POWER_USER_ADMIN": 10, - "LAYER2_USER": 11, + "SIDE_CHAIN_USER": 11, } func (Role) EnumDescriptor() ([]byte, []int) { @@ -97,35 +97,36 @@ func init() { proto.RegisterFile("perm/perm.proto", fileDescriptor_bb77ba30a3a45 func init() { golang_proto.RegisterFile("perm/perm.proto", fileDescriptor_bb77ba30a3a45e51) } var fileDescriptor_bb77ba30a3a45e51 = []byte{ - // 440 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x92, 0xc1, 0x6e, 0xd3, 0x30, - 0x1c, 0xc6, 0x13, 0x36, 0xc6, 0x70, 0x57, 0x5a, 0xc2, 0xc4, 0xc1, 0x12, 0x56, 0x10, 0x02, 0x24, - 0x40, 0x0d, 0x1b, 0x4f, 0xe0, 0xd0, 0x20, 0x55, 0x24, 0x4d, 0xe5, 0x6e, 0x42, 0x70, 0xa9, 0xdc, - 0xd5, 0x14, 0x43, 0x3c, 0x57, 0x4e, 0x26, 0xb4, 0x37, 0x40, 0x39, 0xf1, 0x02, 0x39, 0xb1, 0x03, - 0x47, 0x1e, 0x81, 0xe3, 0x8e, 0x3b, 0x72, 0xe0, 0x00, 0xed, 0x8b, 0x20, 0x3b, 0x69, 0xcd, 0x25, - 0x8a, 0xfc, 0xff, 0xe9, 0xfb, 0xbe, 0xff, 0x5f, 0x1f, 0xe8, 0x2c, 0x98, 0x12, 0x81, 0xfe, 0xf4, - 0x16, 0x4a, 0x16, 0xd2, 0x6b, 0x73, 0xc5, 0x0b, 0x2a, 0xe4, 0xac, 0xa7, 0x1f, 0xe1, 0xfe, 0x5c, - 0xce, 0xa5, 0x99, 0x04, 0xfa, 0xaf, 0x86, 0x9e, 0xfc, 0xde, 0x02, 0xdb, 0x44, 0x66, 0xcc, 0xbb, - 0x0f, 0x00, 0x49, 0xd3, 0xa3, 0x09, 0xee, 0x27, 0x83, 0x61, 0xd7, 0x81, 0xb7, 0xcb, 0xca, 0x6f, - 0xeb, 0x09, 0x91, 0xb2, 0xc0, 0x33, 0xc1, 0x4f, 0x35, 0x32, 0x8a, 0x48, 0xd2, 0x20, 0xae, 0x45, - 0x46, 0x4c, 0x89, 0x1a, 0x79, 0x0a, 0x3a, 0x61, 0x8c, 0x5f, 0xbe, 0x8e, 0x07, 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xe3, 0x02, 0xb9, 0x21, 0xb9, 0xfc, 0x8b, 0x9c, 0xcb, 0x25, 0x72, 0xaf, - 0x96, 0xc8, 0xfd, 0xb3, 0x44, 0xee, 0xd7, 0x15, 0x72, 0x7e, 0xae, 0x90, 0x7b, 0xb5, 0x42, 0xce, - 0xaf, 0x15, 0x72, 0xde, 0x3d, 0x9f, 0xf3, 0xe2, 0xc3, 0xd9, 0xb4, 0x77, 0x22, 0x45, 0x30, 0xe5, - 0xf4, 0xf4, 0x23, 0x67, 0x94, 0x07, 0xeb, 0xea, 0x04, 0x42, 0xce, 0xce, 0x32, 0x96, 0x9b, 0x5e, - 0x05, 0xc5, 0xf9, 0x82, 0xe5, 0xd3, 0x1d, 0xd3, 0x9c, 0x17, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, - 0x56, 0xc1, 0x9a, 0x92, 0x71, 0x02, 0x00, 0x00, + // 452 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x92, 0xc1, 0x6e, 0x94, 0x40, + 0x18, 0xc7, 0xc1, 0xd6, 0x5a, 0x67, 0xbb, 0xb2, 0xc5, 0xea, 0x61, 0x12, 0x27, 0x18, 0xa3, 0x26, + 0xd5, 0x2c, 0x36, 0x3e, 0xc1, 0xb0, 0x60, 0x24, 0x2e, 0xcb, 0x66, 0x68, 0x63, 0xf4, 0xb2, 0x99, + 0x2d, 0xe3, 0x76, 0x14, 0x76, 0x36, 0x40, 0x63, 0xfa, 0x06, 0x86, 0x93, 0x2f, 0xc0, 0xc9, 0x1e, + 0x3c, 0xfa, 0x08, 0x1e, 0x7b, 0xec, 0xd1, 0xa3, 0x2e, 0x2f, 0x62, 0x86, 0x61, 0xc5, 0x0b, 0x21, + 0x7c, 0x3f, 0x7e, 0xff, 0xff, 0x4c, 0x3e, 0x60, 0xac, 0x58, 0x96, 0xda, 0xf2, 0x31, 0x5c, 0x65, + 0xa2, 0x10, 0x66, 0x9f, 0x67, 0xbc, 0xa0, 0xa9, 0x88, 0x87, 0xf2, 0x23, 0x3c, 0x58, 0x88, 0x85, + 0x68, 0x26, 0xb6, 0x7c, 0x53, 0xd0, 0x61, 0xbd, 0x05, 0xb6, 0x89, 0x48, 0x98, 0xf9, 0x10, 0x00, + 0x12, 0x86, 0xc7, 0x33, 0xec, 0x06, 0xfe, 0x64, 0xa0, 0xc1, 0xfd, 0xb2, 0xb2, 0xfa, 0x72, 0x42, + 0x84, 0x28, 0x70, 0x9c, 0xf2, 0xa5, 0x44, 0xa6, 0x1e, 0x09, 0x5a, 0x44, 0xef, 0x90, 0x29, 0xcb, + 0x52, 0x85, 0x3c, 0x03, 0x86, 0x33, 0xc6, 0xa3, 0x37, 0x63, 0x3f, 0xda, 0xa8, 0x6e, 0xc0, 0xfb, + 0x65, 0x65, 0x99, 0x92, 0x73, 0x12, 0x7a, 0xfa, 0x29, 0xe1, 0x79, 0xe7, 0x9b, 0x84, 0xae, 0xd7, + 0x72, 0x5b, 0x9d, 0x6f, 0x22, 0x62, 0xa6, 0x90, 0x47, 0xa0, 0x37, 0xc5, 0x04, 0x6f, 0x32, 0xb7, + 0xa1, 0x59, 0x56, 0xd6, 0x9d, 0x26, 0x93, 0x66, 0x34, 0xed, 0x7a, 0x85, 0x6f, 0x3d, 0x32, 0x3b, + 0x89, 0x3c, 0x32, 0xb8, 0xf9, 0x5f, 0x2f, 0xf1, 0x99, 0x65, 0x27, 0x39, 0xcb, 0xcc, 0xc7, 0x60, + 0x8f, 0x78, 0x63, 0xfc, 0x6e, 0x03, 0xed, 0xc0, 0xbb, 0x65, 0x65, 0x19, 0xcd, 0xf9, 0x58, 0x42, + 0x2f, 0x5a, 0xec, 0x01, 0xd8, 0xf5, 0xdd, 0x36, 0xeb, 0x16, 0x34, 0xca, 0xca, 0xea, 0x49, 0xc4, + 0x77, 0x55, 0xd0, 0x13, 0xd0, 0x77, 0x70, 0xe4, 0xcd, 0x82, 0xa3, 0x96, 0xd9, 0xed, 0x34, 0x0e, + 0xcd, 0x59, 0x70, 0xa4, 0xb8, 0xa7, 0xa0, 0x3f, 0x1d, 0xe3, 0xe3, 0x57, 0x21, 0x09, 0x54, 0xdc, + 0x6d, 0x78, 0x50, 0x56, 0xd6, 0xa0, 0xe9, 0x94, 0xd0, 0xe2, 0x83, 0xc8, 0xd2, 0x26, 0xef, 0x39, + 0x18, 0x74, 0xcd, 0x5b, 0x27, 0xe8, 0xee, 0xeb, 0x5f, 0x7f, 0xa5, 0x3d, 0x04, 0x46, 0xe4, 0xbb, + 0xde, 0x6c, 0xf4, 0x1a, 0xfb, 0x13, 0x25, 0xee, 0xc1, 0x7b, 0x65, 0x65, 0xed, 0x4b, 0x38, 0xe2, + 0x31, 0x1b, 0x9d, 0x51, 0xbe, 0x94, 0x3f, 0xc0, 0xbd, 0x2f, 0xdf, 0x90, 0xf6, 0xfd, 0x12, 0x69, + 0x3f, 0x2e, 0x91, 0xee, 0x90, 0xab, 0x3f, 0x48, 0xbb, 0x5a, 0x23, 0xfd, 0x7a, 0x8d, 0xf4, 0xdf, + 0x6b, 0xa4, 0x7f, 0xad, 0x91, 0xf6, 0xb3, 0x46, 0xfa, 0x75, 0x8d, 0xb4, 0x5f, 0x35, 0xd2, 0xde, + 0xbf, 0x58, 0xf0, 0xe2, 0xec, 0x7c, 0x3e, 0x3c, 0x15, 0xa9, 0x3d, 0xe7, 0x74, 0xf9, 0x91, 0x33, + 0xca, 0xed, 0xcd, 0x06, 0xd9, 0xa9, 0x88, 0xcf, 0x13, 0x96, 0x37, 0xeb, 0x65, 0x17, 0x17, 0x2b, + 0x96, 0xcf, 0x77, 0x9a, 0x05, 0x7a, 0xf9, 0x37, 0x00, 0x00, 0xff, 0xff, 0x2f, 0xb8, 0x86, 0xaf, + 0x78, 0x02, 0x00, 0x00, } func (x Role) String() string { diff --git a/modules/perm/types/role.go b/modules/perm/types/role.go index 373dab32..ce22af97 100644 --- a/modules/perm/types/role.go +++ b/modules/perm/types/role.go @@ -42,7 +42,7 @@ func ValidRole(role Role) bool { role == RoleRelayerUser || role == RolePlatformUser || role == RolePowerUserAdmin || - role == RoleLayer2User { + role == RoleSideChainUser { return true } return false diff --git a/modules/side-chain/client/cli/query.go b/modules/side-chain/client/cli/query.go index ee92f30a..869647f9 100644 --- a/modules/side-chain/client/cli/query.go +++ b/modules/side-chain/client/cli/query.go @@ -49,7 +49,7 @@ func GetCmdQuerySpaceInfo() *cobra.Command { cmd := &cobra.Command{ Use: "space [space-id]", Long: "query the space info of the given space-id", - Example: fmt.Sprintf("$ %s q layer2 space space [space-id]", version.AppName), + Example: fmt.Sprintf("$ %s q sidechain space space [space-id]", version.AppName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -84,7 +84,7 @@ func GetCmdQuerySpacesOfOwner() *cobra.Command { cmd := &cobra.Command{ Use: "owner [owner]", Long: "query the spaces of the given owner", - Example: fmt.Sprintf("$ %s q layer2 space owner [owner]", version.AppName), + Example: fmt.Sprintf("$ %s q sidechain space owner [owner]", version.AppName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -124,7 +124,7 @@ func GetCmdQueryBlockHeader() *cobra.Command { cmd := &cobra.Command{ Use: "blockheader [space-id] [height]", Long: "query the side chain block header", - Example: fmt.Sprintf("$ %s q layer2 blockheader [space-id] [height]", version.AppName), + Example: fmt.Sprintf("$ %s q sidechain blockheader [space-id] [height]", version.AppName), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) diff --git a/modules/side-chain/client/cli/tx.go b/modules/side-chain/client/cli/tx.go index 991a721a..c7df10fc 100644 --- a/modules/side-chain/client/cli/tx.go +++ b/modules/side-chain/client/cli/tx.go @@ -52,7 +52,7 @@ func GetCmdSpaceCreate() *cobra.Command { Use: "create", Long: "create a new side chain space", Example: fmt.Sprintf( - "$ %s tx side-chain space create "+ + "$ %s tx sidechain space create "+ "--name= "+ "--uri=", version.AppName), @@ -96,7 +96,7 @@ func GetCmdSpaceTransfer() *cobra.Command { Use: "transfer [space-id] [recipient]", Long: "transfer ownership of space from sender to recipient", Example: fmt.Sprintf( - "$ %s tx layer2 space transfer [space-id] [recipient]", + "$ %s tx sidechain space transfer [space-id] [recipient]", version.AppName), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -130,7 +130,7 @@ func GetCmdCreateBlockHeader() *cobra.Command { Use: "create-blockheader [space-id] [height] [header]", Long: "create a side chain block header record", Example: fmt.Sprintf( - "$ %s tx layer2 create-blockheader [space-id] [height] [header]", + "$ %s tx sidechain create-blockheader [space-id] [height] [header]", version.AppName), Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/modules/side-chain/keeper/ante.go b/modules/side-chain/keeper/ante.go index b7cf29e1..23ffb8f6 100644 --- a/modules/side-chain/keeper/ante.go +++ b/modules/side-chain/keeper/ante.go @@ -27,7 +27,7 @@ func (dlt ValidateSideChainDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim return ctx, err } case *types.MsgTransferSpace: - if err := dlt.validateSpaceOwnership(ctx, msg.Sender, msg.SpaceId); err != nil { + if err := dlt.validateOnlySpace(ctx, msg.SpaceId); err != nil { return ctx, err } if err := dlt.validateSideChainUserRole(ctx, msg.Sender); err != nil { @@ -37,7 +37,7 @@ func (dlt ValidateSideChainDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim return ctx, err } case *types.MsgCreateBlockHeader: - if err := dlt.validateSpaceOwnership(ctx, msg.Sender, msg.SpaceId); err != nil { + if err := dlt.validateOnlySpace(ctx, msg.SpaceId); err != nil { return ctx, err } if err := dlt.validateSideChainUserRole(ctx, msg.Sender); err != nil { @@ -56,22 +56,10 @@ func (dlt ValidateSideChainDecorator) validateOnlySpace(ctx sdk.Context, spaceId return nil } -func (dlt ValidateSideChainDecorator) validateSpaceOwnership(ctx sdk.Context, addr string, spaceId uint64) error { - accAddr, _ := sdk.AccAddressFromBech32(addr) - if !dlt.keeper.HasSpace(ctx, spaceId) { - return sdkerrors.Wrapf(types.ErrInvalidSpaceId, "space (%d) does not exist", spaceId) - } - - if !dlt.keeper.HasSpaceOfOwner(ctx, accAddr, spaceId) { - return sdkerrors.Wrapf(types.ErrInvalidSpaceOwner, "space (%d) is not owned by (%s)", spaceId, addr) - } - return nil -} - func (dlt ValidateSideChainDecorator) validateSideChainUserRole(ctx sdk.Context, addr string) error { accAddr, _ := sdk.AccAddressFromBech32(addr) if !dlt.permKeeper.HasSideChainUserRole(ctx, accAddr) { - return sdkerrors.Wrapf(types.ErrInvalidSideChainUser, "account (%s) does not have l2 user role", addr) + return sdkerrors.Wrapf(types.ErrInvalidSideChainUser, "account (%s) does not have side chain user role", addr) } return nil } diff --git a/modules/side-chain/keeper/genesis.go b/modules/side-chain/keeper/genesis.go index 742149fc..569ec92b 100644 --- a/modules/side-chain/keeper/genesis.go +++ b/modules/side-chain/keeper/genesis.go @@ -21,17 +21,23 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { for _, blockHeader := range data.BlockHeaders { k.setBlockHeader(ctx, blockHeader.SpaceId, blockHeader.Height, blockHeader.Header) } + + for _, spaceLatestHeight := range data.SpaceLatestHeights { + k.setSpaceLatestHeight(ctx, spaceLatestHeight.SpaceId, spaceLatestHeight.Height) + } } func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { data := types.GenesisState{ - SpaceSequence: 0, - Spaces: make([]types.Space, 0), - BlockHeaders: make([]types.BlockHeader, 0), + SpaceSequence: 0, + Spaces: make([]types.Space, 0), + BlockHeaders: make([]types.BlockHeader, 0), + SpaceLatestHeights: make([]types.SpaceLatestHeight, 0), } data.SpaceSequence = k.GetSpaceSequence(ctx) data.Spaces = k.GetSpaces(ctx) data.BlockHeaders = k.GetBlockHeaders(ctx) + data.SpaceLatestHeights = k.GetSpaceLatestHeights(ctx) return &data } diff --git a/modules/side-chain/keeper/grpc_query.go b/modules/side-chain/keeper/grpc_query.go index a0c827ca..cfa0a91b 100644 --- a/modules/side-chain/keeper/grpc_query.go +++ b/modules/side-chain/keeper/grpc_query.go @@ -18,8 +18,16 @@ func (k Keeper) Space(goCtx context.Context, request *types.QuerySpaceRequest) ( return nil, err } + // NOTE: history data didn't record latest height, so return 0 if not exist. + latestHeight := uint64(0) + lh, exist := k.GetSpaceLatestHeight(ctx, request.SpaceId) + if exist { + latestHeight = lh + } + return &types.QuerySpaceResponse{ - Space: &space, + Space: &space, + LatestHeight: latestHeight, }, nil } @@ -62,5 +70,19 @@ func (k Keeper) BlockHeader(goCtx context.Context, request *types.QueryBlockHead if err != nil { return nil, err } - return &types.QueryBlockHeaderResponse{Header: header}, nil + + // NOTE: history data didn't record create block header tx hash, so return empty if not exist. + txHash := "" + if k.HasBlockHeaderTxHash(ctx, request.SpaceId, request.Height) { + th, err := k.GetBlockHeaderTxHash(ctx, request.SpaceId, request.Height) + if err != nil { + return nil, err + } + txHash = th + } + + return &types.QueryBlockHeaderResponse{ + TxHash: txHash, + Header: header, + }, nil } diff --git a/modules/side-chain/keeper/keeper_test.go b/modules/side-chain/keeper/keeper_test.go index 0a5fea9d..ed5a24a7 100644 --- a/modules/side-chain/keeper/keeper_test.go +++ b/modules/side-chain/keeper/keeper_test.go @@ -9,14 +9,16 @@ import ( "github.com/tendermint/tendermint/crypto/tmhash" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/bianjieai/iritamod/modules/perm" + permtypes "github.com/bianjieai/iritamod/modules/perm/types" "github.com/bianjieai/iritamod/modules/side-chain/keeper" "github.com/bianjieai/iritamod/simapp" ) var ( rootAdmin = sdk.AccAddress(tmhash.SumTruncated([]byte("rootAdmin"))) - accAvata = sdk.AccAddress(tmhash.SumTruncated([]byte("acc_avata"))) // l2 user: cosmos1j0898zyz64cyxy2s2km99t2c3s6tn5tzfppw9h - accXvata = sdk.AccAddress(tmhash.SumTruncated([]byte("acc_xvata"))) // l2 user + accAvata = sdk.AccAddress(tmhash.SumTruncated([]byte("acc_avata"))) // side chain user: cosmos1j0898zyz64cyxy2s2km99t2c3s6tn5tzfppw9h + accXvata = sdk.AccAddress(tmhash.SumTruncated([]byte("acc_xvata"))) // side chain user accAlice = sdk.AccAddress(tmhash.SumTruncated([]byte("acc_alice"))) // cosmos16877jxzrdetmzsl3pntv4n402m8d0cpvwd74w7 accBob = sdk.AccAddress(tmhash.SumTruncated([]byte("acc_bob"))) // cosmos1a53v8ksyd6x47sju572t48s3ynmqyan0n2c6kx @@ -28,10 +30,11 @@ var ( type TestSuite struct { suite.Suite - ctx sdk.Context - cdc *codec.LegacyAmino - keeper keeper.Keeper - app *simapp.SimApp + ctx sdk.Context + cdc *codec.LegacyAmino + keeper keeper.Keeper + permKeeper perm.Keeper + app *simapp.SimApp } func TestTestSuite(t *testing.T) { @@ -48,8 +51,10 @@ func (s *TestSuite) SetupTest() { s.cdc = app.LegacyAmino() s.ctx = app.BaseApp.NewContext(false, tmproto.Header{}) s.app = app - s.keeper = app.Layer2Keeper + s.keeper = app.SideChainKeeper + s.permKeeper = app.PermKeeper + s.prepareRoles() s.prepareSideChain() } @@ -58,3 +63,14 @@ func (s *TestSuite) prepareSideChain() { s.Require().NoError(err) s.Require().Equal(avataSpaceId, id) } + +func (s *TestSuite) prepareRoles() { + err := s.permKeeper.Authorize(s.ctx, accAvata, rootAdmin, permtypes.RoleSideChainUser) + if err != nil { + panic("failed to authorize role") + } + err = s.permKeeper.Authorize(s.ctx, accXvata, rootAdmin, permtypes.RoleSideChainUser) + if err != nil { + panic("failed to authorize role") + } +} diff --git a/modules/side-chain/keeper/space.go b/modules/side-chain/keeper/space.go index cd1b3dac..f95e2acf 100644 --- a/modules/side-chain/keeper/space.go +++ b/modules/side-chain/keeper/space.go @@ -5,6 +5,8 @@ import ( "strconv" "github.com/cosmos/cosmos-sdk/store/prefix" + "github.com/tendermint/tendermint/crypto/tmhash" + tmbytes "github.com/tendermint/tendermint/libs/bytes" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -36,6 +38,11 @@ func (k Keeper) TransferSpace(ctx sdk.Context, spaceId uint64, from, to sdk.AccA if err != nil { return err } + + if !k.HasSpaceOfOwner(ctx, from, spaceId) { + return sdkerrors.Wrapf(types.ErrInvalidSpaceOwner, "space (%d) is not owned by (%s)", spaceId, from.String()) + } + space.Owner = to.String() k.setSpace(ctx, spaceId, space) @@ -47,11 +54,23 @@ func (k Keeper) TransferSpace(ctx sdk.Context, spaceId uint64, from, to sdk.AccA // CreateBlockHeader creates a layer2 block header record func (k Keeper) CreateBlockHeader(ctx sdk.Context, spaceId, height uint64, header string, sender sdk.AccAddress) error { + if !k.HasSpaceOfOwner(ctx, sender, spaceId) { + return sdkerrors.Wrapf(types.ErrInvalidSpaceOwner, "space (%d) is not owned by (%s)", spaceId, sender.String()) + } + if k.HasBlockHeader(ctx, spaceId, height) { return sdkerrors.Wrapf(types.ErrBlockHeader, "block header already exists at height (%d) in space (%d)", height, spaceId) } k.setBlockHeader(ctx, spaceId, height, header) + k.setBlockHeaderTxHash(ctx, spaceId, height, tmhash.Sum(ctx.TxBytes())) + + // update the latest side chain height + latestHeight, exist := k.GetSpaceLatestHeight(ctx, spaceId) + if !exist || latestHeight < height { + k.setSpaceLatestHeight(ctx, spaceId, height) + } + return nil } @@ -159,6 +178,16 @@ func (k Keeper) GetBlockHeaders(ctx sdk.Context) []types.BlockHeader { BlockHeader.Header = string(iterator.Value()) headers = append(headers, BlockHeader) } + + for i := 0; i < len(headers); i++ { + txHash, err := k.GetBlockHeaderTxHash(ctx, headers[i].SpaceId, headers[i].Height) + if err != nil { + panic("fail to get block header tx hash") + } + headers[i].TxHash = txHash + + } + return headers } @@ -181,6 +210,65 @@ func (k Keeper) setBlockHeader(ctx sdk.Context, spaceId, blockHeight uint64, hea store.Set(types.BlockHeaderStoreKey(spaceId, blockHeight), []byte(header)) } +func (k Keeper) HasBlockHeaderTxHash(ctx sdk.Context, spaceId, blockHeight uint64) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.BlockHeaderTxHashStoreKey(spaceId, blockHeight)) +} + +func (k Keeper) GetBlockHeaderTxHash(ctx sdk.Context, spaceId, blockHeight uint64) (string, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.BlockHeaderTxHashStoreKey(spaceId, blockHeight)) + if bz == nil { + return "", sdkerrors.Wrapf(types.ErrBlockHeader, "create block header tx hash does not exist at height (%d) in space (%d)", blockHeight, spaceId) + } + return string(bz), nil +} + +func (k Keeper) setBlockHeaderTxHash(ctx sdk.Context, spaceId, blockHeight uint64, txHash tmbytes.HexBytes) { + store := ctx.KVStore(k.storeKey) + store.Set(types.BlockHeaderTxHashStoreKey(spaceId, blockHeight), []byte(txHash.String())) +} + +func (k Keeper) GetSpaceLatestHeights(ctx sdk.Context) []types.SpaceLatestHeight { + latestHeights := make([]types.SpaceLatestHeight, 0) + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixSpaceLatestHeight) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + ret := bytes.TrimPrefix(iterator.Key(), types.KeyPrefixSpaceLatestHeight) + spaceId, err := strconv.ParseUint(string(ret), 10, 64) + if err != nil { + panic("fail to convert spaceId to uint64") + } + latestHeight := sdk.BigEndianToUint64(iterator.Value()) + latestHeights = append(latestHeights, types.SpaceLatestHeight{ + SpaceId: spaceId, + Height: latestHeight, + }) + } + return latestHeights +} + +func (k Keeper) HasSpaceLatestHeight(ctx sdk.Context, spaceId uint64) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.KeyPrefixSpaceLatestHeightStoreKey(spaceId)) +} + +func (k Keeper) GetSpaceLatestHeight(ctx sdk.Context, spaceId uint64) (uint64, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyPrefixSpaceLatestHeightStoreKey(spaceId)) + if bz == nil { + return 0, false + } + return sdk.BigEndianToUint64(bz), true +} + +func (k Keeper) setSpaceLatestHeight(ctx sdk.Context, spaceId, blockHeight uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyPrefixSpaceLatestHeightStoreKey(spaceId), sdk.Uint64ToBigEndian(blockHeight)) +} + func (k Keeper) getSpaceStore(ctx sdk.Context) prefix.Store { store := ctx.KVStore(k.storeKey) return prefix.NewStore(store, types.KeyPrefixSpace) diff --git a/modules/side-chain/keeper/space_test.go b/modules/side-chain/keeper/space_test.go index a545b70a..91e9db93 100644 --- a/modules/side-chain/keeper/space_test.go +++ b/modules/side-chain/keeper/space_test.go @@ -1,5 +1,12 @@ package keeper_test +import ( + "fmt" + + "github.com/tendermint/tendermint/crypto/tmhash" + tmbytes "github.com/tendermint/tendermint/libs/bytes" +) + func (s *TestSuite) TestCreateSpace() { spaceName := "NewSpace" spaceUri := "NewSpaceUri" @@ -28,7 +35,7 @@ func (s *TestSuite) TestTransferSpace() { s.Require().Equal(accXvata.String(), space.Owner) } -func (s *TestSuite) TestCreateL2BlockHeader() { +func (s *TestSuite) TestCreateBlockHeader() { height := uint64(1000) header := "block header" err := s.keeper.CreateBlockHeader(s.ctx, avataSpaceId, height, header, accAvata) @@ -37,4 +44,15 @@ func (s *TestSuite) TestCreateL2BlockHeader() { resHeader, err := s.keeper.GetBlockHeader(s.ctx, avataSpaceId, height) s.Require().NoErrorf(err, "failed to get block header") s.Require().Equal(header, resHeader) + + h, exist := s.keeper.GetSpaceLatestHeight(s.ctx, avataSpaceId) + s.Require().Equal(exist, true) + s.Require().Equal(height, h) + + var expected tmbytes.HexBytes = tmhash.Sum(s.ctx.TxBytes()) + txHash, err := s.keeper.GetBlockHeaderTxHash(s.ctx, avataSpaceId, height) + s.Require().NoErrorf(err, "failed to get block header tx hash") + s.Require().Equal(expected.String(), txHash) + + fmt.Println(txHash) } diff --git a/modules/side-chain/types/genesis.go b/modules/side-chain/types/genesis.go index f922be4b..d019d3e0 100644 --- a/modules/side-chain/types/genesis.go +++ b/modules/side-chain/types/genesis.go @@ -11,17 +11,19 @@ import ( // NewGenesisState creates a new GenesisState object func NewGenesisState(spaceSequence uint64, spaces []Space, - blockHeaders []BlockHeader) *GenesisState { + blockHeaders []BlockHeader, + spaceLatestHeights []SpaceLatestHeight) *GenesisState { return &GenesisState{ - SpaceSequence: spaceSequence, - Spaces: spaces, - BlockHeaders: blockHeaders, + SpaceSequence: spaceSequence, + Spaces: spaces, + BlockHeaders: blockHeaders, + SpaceLatestHeights: spaceLatestHeights, } } // DefaultGenesisState creates a default GenesisState object func DefaultGenesisState() *GenesisState { - return NewGenesisState(0, []Space{}, []BlockHeader{}) + return NewGenesisState(0, []Space{}, []BlockHeader{}, []SpaceLatestHeight{}) } // ValidateGenesis validates the provided genesis state to ensure the @@ -63,5 +65,17 @@ func ValidateGenesis(data GenesisState) error { seenBlockHeaderMap[seenBlockHeader] = true } + // validate SpaceLatestHeight + for _, latestHeight := range data.SpaceLatestHeights { + if !seenSpaceIds[latestHeight.SpaceId] { + return sdkerrors.Wrapf(ErrInvalidSpaceId, "unknown space (%d) during validation", latestHeight.SpaceId) + } + + seenBlockHeader := fmt.Sprintf("%d-%d", latestHeight.SpaceId, latestHeight.Height) + if !seenBlockHeaderMap[seenBlockHeader] { + return sdkerrors.Wrapf(ErrBlockHeader, "unknown block header (%s) during validation", seenBlockHeader) + } + } + return nil } diff --git a/modules/side-chain/types/genesis.pb.go b/modules/side-chain/types/genesis.pb.go index 52aaf614..c5a58409 100644 --- a/modules/side-chain/types/genesis.pb.go +++ b/modules/side-chain/types/genesis.pb.go @@ -24,9 +24,10 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { - SpaceSequence uint64 `protobuf:"varint,1,opt,name=space_sequence,json=spaceSequence,proto3" json:"space_sequence,omitempty"` - Spaces []Space `protobuf:"bytes,2,rep,name=spaces,proto3" json:"spaces"` - BlockHeaders []BlockHeader `protobuf:"bytes,3,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers"` + SpaceSequence uint64 `protobuf:"varint,1,opt,name=space_sequence,json=spaceSequence,proto3" json:"space_sequence,omitempty"` + Spaces []Space `protobuf:"bytes,2,rep,name=spaces,proto3" json:"spaces"` + BlockHeaders []BlockHeader `protobuf:"bytes,3,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers"` + SpaceLatestHeights []SpaceLatestHeight `protobuf:"bytes,4,rep,name=space_latest_heights,json=spaceLatestHeights,proto3" json:"space_latest_heights"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -83,6 +84,13 @@ func (m *GenesisState) GetBlockHeaders() []BlockHeader { return nil } +func (m *GenesisState) GetSpaceLatestHeights() []SpaceLatestHeight { + if m != nil { + return m.SpaceLatestHeights + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "iritamod.side_chain.v1.GenesisState") } @@ -90,25 +98,27 @@ func init() { func init() { proto.RegisterFile("side-chain/v1/genesis.proto", fileDescriptor_fe79f655ddf8c3a2) } var fileDescriptor_fe79f655ddf8c3a2 = []byte{ - // 280 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2e, 0xce, 0x4c, 0x49, - 0xd5, 0x4d, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, - 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xcb, 0x2c, 0xca, 0x2c, 0x49, 0xcc, 0xcd, - 0x4f, 0xd1, 0x03, 0xa9, 0x8a, 0x07, 0xab, 0xd2, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, - 0x07, 0x2b, 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0xe4, 0x50, 0x8d, 0x42, 0xf0, 0x20, 0xf2, 0x4a, - 0x87, 0x18, 0xb9, 0x78, 0xdc, 0x21, 0xe6, 0x07, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0xa9, 0x72, 0xf1, - 0x15, 0x17, 0x24, 0x26, 0xa7, 0xc6, 0x17, 0xa7, 0x16, 0x96, 0xa6, 0xe6, 0x25, 0xa7, 0x4a, 0x30, - 0x2a, 0x30, 0x6a, 0xb0, 0x04, 0xf1, 0x82, 0x45, 0x83, 0xa1, 0x82, 0x42, 0xd6, 0x5c, 0x6c, 0x60, - 0x81, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x59, 0x3d, 0xec, 0xce, 0xd2, 0x0b, 0x06, - 0xa9, 0x72, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, 0x08, 0xaa, 0x45, 0xc8, 0x8f, 0x8b, 0x37, 0x29, - 0x27, 0x3f, 0x39, 0x3b, 0x3e, 0x23, 0x35, 0x31, 0x25, 0xb5, 0xa8, 0x58, 0x82, 0x19, 0x6c, 0x86, - 0x32, 0x2e, 0x33, 0x9c, 0x40, 0x8a, 0x3d, 0xc0, 0x6a, 0xa1, 0x26, 0xf1, 0x24, 0x21, 0x84, 0x8a, - 0x9d, 0x02, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, - 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x2c, 0x3d, 0xb3, - 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x29, 0x33, 0x31, 0x2f, 0x2b, 0x33, 0x35, - 0x31, 0x53, 0x1f, 0x66, 0x8d, 0x7e, 0x6e, 0x7e, 0x4a, 0x69, 0x4e, 0x6a, 0x31, 0x52, 0xb0, 0xe8, - 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x43, 0xc7, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, - 0x2b, 0x55, 0x93, 0x39, 0x8a, 0x01, 0x00, 0x00, + // 319 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xc1, 0x4a, 0xeb, 0x40, + 0x14, 0x86, 0x93, 0xb6, 0x74, 0x31, 0xb7, 0xbd, 0x8b, 0xa1, 0x48, 0xa8, 0x38, 0x16, 0x45, 0xa8, + 0x0b, 0x67, 0xa8, 0x82, 0x1b, 0x77, 0xdd, 0xd8, 0x85, 0x88, 0xb4, 0x3b, 0x37, 0x61, 0x92, 0x1c, + 0x92, 0xd1, 0x36, 0x53, 0x7b, 0xa6, 0x05, 0xdf, 0xc2, 0x97, 0xf0, 0x5d, 0xba, 0xec, 0xd2, 0x95, + 0x48, 0xf2, 0x22, 0x92, 0x49, 0xa4, 0x2a, 0xea, 0x2e, 0xf9, 0xcf, 0x77, 0xbe, 0xf9, 0x99, 0x21, + 0xbb, 0xa8, 0x22, 0x38, 0x09, 0x13, 0xa9, 0x52, 0xb1, 0x1a, 0x88, 0x18, 0x52, 0x40, 0x85, 0x7c, + 0xbe, 0xd0, 0x46, 0xd3, 0x1d, 0xb5, 0x50, 0x46, 0xce, 0x74, 0xc4, 0x0b, 0xca, 0xb7, 0x14, 0x5f, + 0x0d, 0xba, 0x9d, 0x58, 0xc7, 0xda, 0x22, 0xa2, 0xf8, 0x2a, 0xe9, 0x2e, 0xfb, 0xaa, 0xda, 0xfe, + 0x95, 0xf3, 0x83, 0xe7, 0x1a, 0x69, 0x5d, 0x96, 0xfe, 0x89, 0x91, 0x06, 0xe8, 0x11, 0xf9, 0x8f, + 0x73, 0x19, 0x82, 0x8f, 0xf0, 0xb0, 0x84, 0x34, 0x04, 0xcf, 0xed, 0xb9, 0xfd, 0xc6, 0xb8, 0x6d, + 0xd3, 0x49, 0x15, 0xd2, 0x0b, 0xd2, 0xb4, 0x01, 0x7a, 0xb5, 0x5e, 0xbd, 0xff, 0xef, 0x74, 0x8f, + 0xff, 0x5c, 0x8b, 0x4f, 0x0a, 0x6a, 0xd8, 0x58, 0xbf, 0xee, 0x3b, 0xe3, 0x6a, 0x85, 0x5e, 0x93, + 0x76, 0x30, 0xd5, 0xe1, 0xbd, 0x9f, 0x80, 0x8c, 0x60, 0x81, 0x5e, 0xdd, 0x3a, 0x0e, 0x7f, 0x73, + 0x0c, 0x0b, 0x78, 0x64, 0xd9, 0xca, 0xd4, 0x0a, 0xb6, 0x11, 0x52, 0x49, 0x3a, 0x65, 0xe7, 0xa9, + 0x34, 0x80, 0xc6, 0x4f, 0x40, 0xc5, 0x89, 0x41, 0xaf, 0x61, 0xb5, 0xc7, 0x7f, 0x56, 0xbb, 0xb2, + 0x2b, 0x23, 0xbb, 0x51, 0xc9, 0x29, 0x7e, 0x1f, 0xe0, 0xf0, 0x66, 0x9d, 0x31, 0x77, 0x93, 0x31, + 0xf7, 0x2d, 0x63, 0xee, 0x53, 0xce, 0x9c, 0x4d, 0xce, 0x9c, 0x97, 0x9c, 0x39, 0xb7, 0xe7, 0xb1, + 0x32, 0xc9, 0x32, 0xe0, 0xa1, 0x9e, 0x89, 0x40, 0xc9, 0xf4, 0x4e, 0x81, 0x54, 0xe2, 0xe3, 0x48, + 0x31, 0xd3, 0xd1, 0x72, 0x0a, 0xf8, 0xe9, 0xe6, 0x85, 0x79, 0x9c, 0x03, 0x06, 0x4d, 0xfb, 0x00, + 0x67, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0xec, 0x95, 0x62, 0x53, 0xed, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -131,6 +141,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.SpaceLatestHeights) > 0 { + for iNdEx := len(m.SpaceLatestHeights) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SpaceLatestHeights[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } if len(m.BlockHeaders) > 0 { for iNdEx := len(m.BlockHeaders) - 1; iNdEx >= 0; iNdEx-- { { @@ -199,6 +223,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.SpaceLatestHeights) > 0 { + for _, e := range m.SpaceLatestHeights { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -324,6 +354,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceLatestHeights", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceLatestHeights = append(m.SpaceLatestHeights, SpaceLatestHeight{}) + if err := m.SpaceLatestHeights[len(m.SpaceLatestHeights)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/modules/side-chain/types/keys.go b/modules/side-chain/types/keys.go index fa048deb..bae60277 100644 --- a/modules/side-chain/types/keys.go +++ b/modules/side-chain/types/keys.go @@ -17,12 +17,14 @@ const ( var ( // Space storekey prefix - KeyPrefixSpaceSequence = []byte{0x01} - KeyPrefixSpace = []byte{0x02} - KeyPrefixSpaceOfOwner = []byte{0x03} + KeyPrefixSpaceSequence = []byte{0x01} + KeyPrefixSpace = []byte{0x02} + KeyPrefixSpaceOfOwner = []byte{0x03} + KeyPrefixSpaceLatestHeight = []byte{0x06} // BlockHeader storekey prefix - KeyPrefixBlockHeader = []byte{0x04} + KeyPrefixBlockHeader = []byte{0x04} + KeyPrefixBlockHeaderTxHash = []byte{0x05} Delimiter = []byte{0x00} Placeholder = []byte{0x01} @@ -72,7 +74,7 @@ func SpaceOfOwnerByOwnerStoreKey(owner sdk.AccAddress) []byte { // record mappings store key -// BlockHeaderStoreKey returns the byte representation of the record key +// BlockHeaderStoreKey returns the byte representation of the block header key // Items are stored with the following key: values // <0x04> func BlockHeaderStoreKey(spaceId, blockHeight uint64) []byte { @@ -85,3 +87,28 @@ func BlockHeaderStoreKey(spaceId, blockHeight uint64) []byte { copy(key[len(KeyPrefixBlockHeader)+len(spaceIdStr)+len(Delimiter):], blockHeightStr) return key } + +// BlockHeaderTxHashStoreKey returns the byte representation of the block header tx hash key +// Items are stored with the following key: values +// <0x05> +func BlockHeaderTxHashStoreKey(spaceId, blockHeight uint64) []byte { + spaceIdStr := strconv.FormatUint(spaceId, 10) + blockHeightStr := strconv.FormatUint(blockHeight, 10) + key := make([]byte, len(KeyPrefixBlockHeaderTxHash)+len(spaceIdStr)+len(Delimiter)+len(blockHeightStr)) + copy(key, KeyPrefixBlockHeaderTxHash) + copy(key[len(KeyPrefixBlockHeaderTxHash):], spaceIdStr) + copy(key[len(KeyPrefixBlockHeaderTxHash)+len(spaceIdStr):], Delimiter) + copy(key[len(KeyPrefixBlockHeaderTxHash)+len(spaceIdStr)+len(Delimiter):], blockHeightStr) + return key +} + +// KeyPrefixSpaceLatestHeightStoreKey returns the byte representation of the block header latest height key +// Items are stored with the following key: values +// <0x06> +func KeyPrefixSpaceLatestHeightStoreKey(spaceId uint64) []byte { + spaceIdStr := strconv.FormatUint(spaceId, 10) + key := make([]byte, len(KeyPrefixSpaceLatestHeight)+len(spaceIdStr)) + copy(key, KeyPrefixSpaceLatestHeight) + copy(key[len(KeyPrefixSpaceLatestHeight):], spaceIdStr) + return key +} diff --git a/modules/side-chain/types/query.pb.go b/modules/side-chain/types/query.pb.go index 141e5816..aa45e89e 100644 --- a/modules/side-chain/types/query.pb.go +++ b/modules/side-chain/types/query.pb.go @@ -77,7 +77,8 @@ func (m *QuerySpaceRequest) GetSpaceId() uint64 { // QuerySpaceResponse is the response type for the Query/Space RPC type QuerySpaceResponse struct { - Space *Space `protobuf:"bytes,1,opt,name=space,proto3" json:"space,omitempty"` + Space *Space `protobuf:"bytes,1,opt,name=space,proto3" json:"space,omitempty"` + LatestHeight uint64 `protobuf:"varint,2,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height,omitempty"` } func (m *QuerySpaceResponse) Reset() { *m = QuerySpaceResponse{} } @@ -120,6 +121,13 @@ func (m *QuerySpaceResponse) GetSpace() *Space { return nil } +func (m *QuerySpaceResponse) GetLatestHeight() uint64 { + if m != nil { + return m.LatestHeight + } + return 0 +} + // QuerySpaceOfOwnerRequest is the request type for the Query/SpaceOfOwner RPC type QuerySpaceOfOwnerRequest struct { Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` @@ -281,6 +289,7 @@ func (m *QueryBlockHeaderRequest) GetHeight() uint64 { // QueryBlockHeaderResponse is the response type for the Query/Record RPC type QueryBlockHeaderResponse struct { + TxHash string `protobuf:"bytes,1,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` Header string `protobuf:"bytes,2,opt,name=header,proto3" json:"header,omitempty"` } @@ -317,6 +326,13 @@ func (m *QueryBlockHeaderResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryBlockHeaderResponse proto.InternalMessageInfo +func (m *QueryBlockHeaderResponse) GetTxHash() string { + if m != nil { + return m.TxHash + } + return "" +} + func (m *QueryBlockHeaderResponse) GetHeader() string { if m != nil { return m.Header @@ -336,41 +352,43 @@ func init() { func init() { proto.RegisterFile("side-chain/v1/query.proto", fileDescriptor_14da640d0a011456) } var fileDescriptor_14da640d0a011456 = []byte{ - // 542 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xc1, 0x6e, 0xd3, 0x4a, - 0x14, 0xcd, 0xb4, 0x49, 0xde, 0xeb, 0x94, 0x0d, 0xa3, 0xaa, 0x24, 0x16, 0x35, 0x95, 0x17, 0xa8, - 0x05, 0x31, 0xd3, 0xa4, 0x12, 0x82, 0xb2, 0x41, 0x59, 0x51, 0x09, 0xa9, 0xc5, 0xec, 0xd8, 0x54, - 0x13, 0x7b, 0x70, 0x86, 0x26, 0x1e, 0x37, 0xe3, 0x14, 0x55, 0x55, 0x36, 0x7c, 0x01, 0x08, 0xfe, - 0x80, 0x3f, 0xe0, 0x2b, 0xba, 0xac, 0xc4, 0x86, 0x15, 0x42, 0x09, 0xdf, 0xc0, 0x1a, 0xf9, 0xce, - 0x44, 0x76, 0x68, 0x42, 0xca, 0x2e, 0x37, 0xf7, 0x9c, 0x39, 0xe7, 0xdc, 0x7b, 0x65, 0x5c, 0xd7, - 0x32, 0x14, 0x0f, 0x82, 0x0e, 0x97, 0x31, 0x3b, 0x6d, 0xb0, 0x93, 0x81, 0xe8, 0x9f, 0xd1, 0xa4, - 0xaf, 0x52, 0x45, 0xd6, 0x65, 0x5f, 0xa6, 0xbc, 0xa7, 0x42, 0x9a, 0x61, 0x8e, 0x00, 0x43, 0x4f, - 0x1b, 0xce, 0x5a, 0xa4, 0x22, 0x05, 0x10, 0x96, 0xfd, 0x32, 0x68, 0xe7, 0x76, 0xa4, 0x54, 0xd4, - 0x15, 0x8c, 0x27, 0x92, 0xf1, 0x38, 0x56, 0x29, 0x4f, 0xa5, 0x8a, 0xb5, 0xed, 0xba, 0xd3, 0x32, - 0x79, 0x65, 0xfb, 0x1b, 0x81, 0xd2, 0x3d, 0xa5, 0x8d, 0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 0xc7, 0xa5, 0x1e, 0x3e, 0xfa, 0x04, 0x00, 0x00, + // 576 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xc1, 0x6e, 0xd3, 0x4c, + 0x10, 0x8e, 0xdb, 0x26, 0xfd, 0xbb, 0xe9, 0x7f, 0x60, 0x55, 0xb5, 0x89, 0x45, 0x4d, 0x65, 0x24, + 0xd4, 0x82, 0xf0, 0x36, 0xa9, 0x84, 0xa0, 0x5c, 0x50, 0x4e, 0x41, 0x20, 0xb5, 0x98, 0x1b, 0x97, + 0x68, 0x13, 0x2f, 0xf6, 0xd2, 0xc4, 0xeb, 0x66, 0x37, 0xa5, 0x55, 0x95, 0x0b, 0x4f, 0x00, 0x82, + 0x37, 0xe0, 0x0d, 0x78, 0x8a, 0x1e, 0x2b, 0x71, 0xe1, 0x84, 0x50, 0xc2, 0x33, 0x70, 0x46, 0x9e, + 0xdd, 0x28, 0x0e, 0x4d, 0x48, 0xb9, 0x79, 0x76, 0xbe, 0x99, 0xef, 0x9b, 0x6f, 0x46, 0x46, 0x65, + 0xc9, 0x03, 0x76, 0xbf, 0x15, 0x51, 0x1e, 0x93, 0x93, 0x0a, 0x39, 0xee, 0xb1, 0xee, 0x99, 0x97, + 0x74, 0x85, 0x12, 0x78, 0x9d, 0x77, 0xb9, 0xa2, 0x1d, 0x11, 0x78, 0x29, 0xa6, 0x01, 0x18, 0xef, + 0xa4, 0x62, 0xaf, 0x85, 0x22, 0x14, 0x00, 0x21, 0xe9, 0x97, 0x46, 0xdb, 0x37, 0x43, 0x21, 0xc2, + 0x36, 0x23, 0x34, 0xe1, 0x84, 0xc6, 0xb1, 0x50, 0x54, 0x71, 0x11, 0x4b, 0x93, 0x75, 0x26, 0x69, + 0xc6, 0x91, 0xc9, 0x6f, 0xb6, 0x84, 0xec, 0x08, 0xa9, 0xf9, 0x49, 0x42, 0x43, 0x1e, 0x43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2, 0x43, 0x9a, 0x9c, 0xc6, 0x6f, 0x38, 0xa3, + 0x7c, 0xcc, 0xd3, 0x11, 0x41, 0xaf, 0xcd, 0x64, 0x96, 0x4f, 0x9d, 0x25, 0x4c, 0x36, 0x0b, 0xf0, + 0x43, 0xda, 0xfb, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x48, 0x8f, 0xa2, 0xf2, 0x38, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -579,6 +597,11 @@ func (m *QuerySpaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.LatestHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.LatestHeight)) + i-- + dAtA[i] = 0x10 + } if m.Space != nil { { size, err := m.Space.MarshalToSizedBuffer(dAtA[:i]) @@ -745,6 +768,13 @@ func (m *QueryBlockHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error i-- dAtA[i] = 0x12 } + if len(m.TxHash) > 0 { + i -= len(m.TxHash) + copy(dAtA[i:], m.TxHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.TxHash))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -781,6 +811,9 @@ func (m *QuerySpaceResponse) Size() (n int) { l = m.Space.Size() n += 1 + l + sovQuery(uint64(l)) } + if m.LatestHeight != 0 { + n += 1 + sovQuery(uint64(m.LatestHeight)) + } return n } @@ -841,6 +874,10 @@ func (m *QueryBlockHeaderResponse) Size() (n int) { } var l int _ = l + l = len(m.TxHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } l = len(m.Header) if l > 0 { n += 1 + l + sovQuery(uint64(l)) @@ -988,6 +1025,25 @@ func (m *QuerySpaceResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LatestHeight", wireType) + } + m.LatestHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LatestHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -1364,6 +1420,38 @@ func (m *QueryBlockHeaderResponse) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: QueryBlockHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxHash", 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.TxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) diff --git a/modules/side-chain/types/side-chain.pb.go b/modules/side-chain/types/side-chain.pb.go index e4c3582b..3ef9334c 100644 --- a/modules/side-chain/types/side-chain.pb.go +++ b/modules/side-chain/types/side-chain.pb.go @@ -92,17 +92,71 @@ func (m *Space) GetOwner() string { return "" } +// SpaceLatestHeight defines the latest height of the side-chain. +type SpaceLatestHeight struct { + SpaceId uint64 `protobuf:"varint,1,opt,name=space_id,json=spaceId,proto3" json:"space_id,omitempty"` + Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *SpaceLatestHeight) Reset() { *m = SpaceLatestHeight{} } +func (m *SpaceLatestHeight) String() string { return proto.CompactTextString(m) } +func (*SpaceLatestHeight) ProtoMessage() {} +func (*SpaceLatestHeight) Descriptor() ([]byte, []int) { + return fileDescriptor_7c92cc5eb9507ffe, []int{1} +} +func (m *SpaceLatestHeight) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpaceLatestHeight) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpaceLatestHeight.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 *SpaceLatestHeight) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpaceLatestHeight.Merge(m, src) +} +func (m *SpaceLatestHeight) XXX_Size() int { + return m.Size() +} +func (m *SpaceLatestHeight) XXX_DiscardUnknown() { + xxx_messageInfo_SpaceLatestHeight.DiscardUnknown(m) +} + +var xxx_messageInfo_SpaceLatestHeight proto.InternalMessageInfo + +func (m *SpaceLatestHeight) GetSpaceId() uint64 { + if m != nil { + return m.SpaceId + } + return 0 +} + +func (m *SpaceLatestHeight) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + type BlockHeader struct { SpaceId uint64 `protobuf:"varint,1,opt,name=space_id,json=spaceId,proto3" json:"space_id,omitempty"` Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` Header string `protobuf:"bytes,3,opt,name=header,proto3" json:"header,omitempty"` + TxHash string `protobuf:"bytes,4,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` } func (m *BlockHeader) Reset() { *m = BlockHeader{} } func (m *BlockHeader) String() string { return proto.CompactTextString(m) } func (*BlockHeader) ProtoMessage() {} func (*BlockHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_7c92cc5eb9507ffe, []int{1} + return fileDescriptor_7c92cc5eb9507ffe, []int{2} } func (m *BlockHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -152,32 +206,43 @@ func (m *BlockHeader) GetHeader() string { return "" } +func (m *BlockHeader) GetTxHash() string { + if m != nil { + return m.TxHash + } + return "" +} + func init() { proto.RegisterType((*Space)(nil), "iritamod.side_chain.v1.Space") + proto.RegisterType((*SpaceLatestHeight)(nil), "iritamod.side_chain.v1.SpaceLatestHeight") proto.RegisterType((*BlockHeader)(nil), "iritamod.side_chain.v1.BlockHeader") } func init() { proto.RegisterFile("side-chain/v1/side-chain.proto", fileDescriptor_7c92cc5eb9507ffe) } var fileDescriptor_7c92cc5eb9507ffe = []byte{ - // 272 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xcd, 0x4a, 0xc3, 0x40, - 0x14, 0x85, 0x33, 0x69, 0x5a, 0x75, 0x04, 0x91, 0xa1, 0x94, 0xe8, 0x62, 0x28, 0x5d, 0x75, 0x63, - 0x86, 0x22, 0xf8, 0x00, 0x5d, 0xe9, 0x4e, 0xd2, 0x8d, 0xb8, 0x29, 0x93, 0xcc, 0x25, 0xb9, 0xda, - 0x64, 0x42, 0x7e, 0x2a, 0xbe, 0x85, 0x8f, 0xe5, 0xb2, 0x4b, 0x97, 0x92, 0xbc, 0x88, 0xcc, 0x24, - 0x6a, 0x77, 0xe7, 0x3b, 0xf7, 0x5c, 0x0e, 0x1c, 0xca, 0x2b, 0x54, 0x70, 0x13, 0xa7, 0x12, 0x73, - 0xb1, 0x5f, 0x89, 0x7f, 0x0a, 0x8a, 0x52, 0xd7, 0x9a, 0xcd, 0xb0, 0xc4, 0x5a, 0x66, 0x5a, 0x05, - 0xe6, 0xb4, 0xed, 0x4f, 0xfb, 0xd5, 0xf5, 0x34, 0xd1, 0x89, 0xb6, 0x11, 0x61, 0x54, 0x9f, 0x5e, - 0x6c, 0xe8, 0x78, 0x53, 0xc8, 0x18, 0xd8, 0x05, 0x75, 0x51, 0xf9, 0x64, 0x4e, 0x96, 0x5e, 0xe8, - 0xa2, 0x62, 0x8c, 0x7a, 0xb9, 0xcc, 0xc0, 0x77, 0xe7, 0x64, 0x79, 0x16, 0x5a, 0xcd, 0x2e, 0xe9, - 0xa8, 0x29, 0xd1, 0x1f, 0x59, 0xcb, 0x48, 0x36, 0xa5, 0x63, 0xfd, 0x96, 0x43, 0xe9, 0x7b, 0xd6, - 0xeb, 0x61, 0xf1, 0x44, 0xcf, 0xd7, 0x3b, 0x1d, 0xbf, 0xde, 0x83, 0x54, 0x50, 0xb2, 0x2b, 0x7a, - 0x5a, 0x99, 0x8e, 0xed, 0x5f, 0xc1, 0x89, 0xe5, 0x07, 0xc5, 0x66, 0x74, 0x92, 0x02, 0x26, 0x69, - 0x6d, 0x7b, 0xbc, 0x70, 0xa0, 0xde, 0x37, 0xcf, 0x43, 0xd9, 0x40, 0xeb, 0xc7, 0xcf, 0x96, 0x93, - 0x43, 0xcb, 0xc9, 0x77, 0xcb, 0xc9, 0x47, 0xc7, 0x9d, 0x43, 0xc7, 0x9d, 0xaf, 0x8e, 0x3b, 0xcf, - 0x77, 0x09, 0xd6, 0x69, 0x13, 0x05, 0xb1, 0xce, 0x44, 0x84, 0x32, 0x7f, 0x41, 0x90, 0x28, 0x7e, - 0xb7, 0x10, 0x99, 0x56, 0xcd, 0x0e, 0xaa, 0xa3, 0xb9, 0x44, 0xfd, 0x5e, 0x40, 0x15, 0x4d, 0xec, - 0x0e, 0xb7, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x75, 0x48, 0xb6, 0xe7, 0x57, 0x01, 0x00, 0x00, + // 306 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xbf, 0x4e, 0xc3, 0x30, + 0x10, 0xc6, 0xeb, 0x36, 0x6d, 0xc1, 0x48, 0x08, 0xac, 0xaa, 0x04, 0x06, 0xab, 0xea, 0xd4, 0x85, + 0x5a, 0x15, 0x12, 0x0f, 0xd0, 0x01, 0x15, 0x89, 0x01, 0xb5, 0x1b, 0x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e, 0xdd, 0xad, 0x15, 0x37, 0xaa, 0xd9, 0xbc, 0x67, 0x77, 0x0b, 0x6e, 0xd4, 0xfc, 0xfe, 0xbd, + 0xa0, 0x68, 0x5f, 0x50, 0xf4, 0x59, 0x50, 0xf4, 0x56, 0xd2, 0xd6, 0xbe, 0xa4, 0xad, 0x8f, 0x92, + 0xb6, 0x1e, 0xae, 0x23, 0xb0, 0x2a, 0x0f, 0xa6, 0xa1, 0x8e, 0x59, 0x00, 0x3c, 0x79, 0x04, 0xc9, + 0x81, 0x7d, 0x1f, 0x9b, 0xc5, 0x5a, 0xe4, 0x1b, 0x69, 0xfe, 0xfc, 0x07, 0xb3, 0xaf, 0xa9, 0x34, + 0x41, 0xcf, 0x1d, 0xfa, 0xea, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xed, 0x35, 0x64, 0x3e, 0xb8, 0x01, + 0x00, 0x00, } func (m *Space) Marshal() (dAtA []byte, err error) { @@ -229,6 +294,39 @@ func (m *Space) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *SpaceLatestHeight) 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 *SpaceLatestHeight) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpaceLatestHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintSideChain(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + } + if m.SpaceId != 0 { + i = encodeVarintSideChain(dAtA, i, uint64(m.SpaceId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *BlockHeader) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -249,6 +347,13 @@ func (m *BlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.TxHash) > 0 { + i -= len(m.TxHash) + copy(dAtA[i:], m.TxHash) + i = encodeVarintSideChain(dAtA, i, uint64(len(m.TxHash))) + i-- + dAtA[i] = 0x22 + } if len(m.Header) > 0 { i -= len(m.Header) copy(dAtA[i:], m.Header) @@ -304,6 +409,21 @@ func (m *Space) Size() (n int) { return n } +func (m *SpaceLatestHeight) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SpaceId != 0 { + n += 1 + sovSideChain(uint64(m.SpaceId)) + } + if m.Height != 0 { + n += 1 + sovSideChain(uint64(m.Height)) + } + return n +} + func (m *BlockHeader) Size() (n int) { if m == nil { return 0 @@ -320,6 +440,10 @@ func (m *BlockHeader) Size() (n int) { if l > 0 { n += 1 + l + sovSideChain(uint64(l)) } + l = len(m.TxHash) + if l > 0 { + n += 1 + l + sovSideChain(uint64(l)) + } return n } @@ -494,6 +618,94 @@ func (m *Space) Unmarshal(dAtA []byte) error { } return nil } +func (m *SpaceLatestHeight) 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 ErrIntOverflowSideChain + } + 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: SpaceLatestHeight: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpaceLatestHeight: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + m.SpaceId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSideChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SpaceId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSideChain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSideChain(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSideChain + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *BlockHeader) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -593,6 +805,38 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { } m.Header = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSideChain + } + 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 ErrInvalidLengthSideChain + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSideChain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipSideChain(dAtA[iNdEx:]) diff --git a/proto/perm/perm.proto b/proto/perm/perm.proto index 7560888d..1a17c623 100644 --- a/proto/perm/perm.proto +++ b/proto/perm/perm.proto @@ -35,6 +35,6 @@ enum Role { PLATFORM_USER = 9 [(gogoproto.enumvalue_customname) = "RolePlatformUser"]; // POWER_USER_ADMIN defines the power admin role index. POWER_USER_ADMIN = 10 [(gogoproto.enumvalue_customname) = "RolePowerUserAdmin"]; - //LAYER2_USER defines the layer2 user role index. - LAYER2_USER = 11 [(gogoproto.enumvalue_customname) = "RoleLayer2User"]; + // SIDE_CHAIN_USER defines the side chain user role index. + SIDE_CHAIN_USER = 11 [(gogoproto.enumvalue_customname) = "RoleSideChainUser"]; } diff --git a/proto/side-chain/v1/genesis.proto b/proto/side-chain/v1/genesis.proto index 7633e75e..89f997ea 100644 --- a/proto/side-chain/v1/genesis.proto +++ b/proto/side-chain/v1/genesis.proto @@ -10,4 +10,5 @@ message GenesisState { uint64 space_sequence = 1; repeated Space spaces = 2 [ (gogoproto.nullable) = false ]; repeated BlockHeader block_headers = 3 [ (gogoproto.nullable) = false ]; + repeated SpaceLatestHeight space_latest_heights = 4 [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/proto/side-chain/v1/query.proto b/proto/side-chain/v1/query.proto index 37531cc5..4110fe65 100644 --- a/proto/side-chain/v1/query.proto +++ b/proto/side-chain/v1/query.proto @@ -35,6 +35,7 @@ message QuerySpaceRequest { // QuerySpaceResponse is the response type for the Query/Space RPC message QuerySpaceResponse { Space space = 1; + uint64 latest_height = 2; } // QuerySpaceOfOwnerRequest is the request type for the Query/SpaceOfOwner RPC @@ -57,5 +58,6 @@ message QueryBlockHeaderRequest { // QueryBlockHeaderResponse is the response type for the Query/Record RPC message QueryBlockHeaderResponse { + string tx_hash = 1; string header = 2; } \ No newline at end of file diff --git a/proto/side-chain/v1/side-chain.proto b/proto/side-chain/v1/side-chain.proto index efc914de..36f5299c 100644 --- a/proto/side-chain/v1/side-chain.proto +++ b/proto/side-chain/v1/side-chain.proto @@ -13,8 +13,15 @@ message Space { string owner = 4; } +// SpaceLatestHeight defines the latest height of the side-chain. +message SpaceLatestHeight { + uint64 space_id = 1; + uint64 height = 2; +} + message BlockHeader { uint64 space_id = 1; uint64 height = 2; string header = 3; + string tx_hash = 4; // TxHash for CreateBlockHeader message. } \ No newline at end of file diff --git a/simapp/app.go b/simapp/app.go index 0e1af017..07c5de5b 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -1,7 +1,6 @@ package simapp import ( - sidechain "github.com/bianjieai/iritamod/modules/side-chain" "io" "net/http" "os" @@ -74,10 +73,10 @@ import ( "github.com/bianjieai/iritamod/modules/perm" permkeeper "github.com/bianjieai/iritamod/modules/perm/keeper" permtypes "github.com/bianjieai/iritamod/modules/perm/types" - cslashing "github.com/bianjieai/iritamod/modules/slashing" - + sidechain "github.com/bianjieai/iritamod/modules/side-chain" sidechainkeeper "github.com/bianjieai/iritamod/modules/side-chain/keeper" sidechaintypes "github.com/bianjieai/iritamod/modules/side-chain/types" + cslashing "github.com/bianjieai/iritamod/modules/slashing" ) const appName = "SimApp" @@ -144,15 +143,15 @@ type SimApp struct { BankKeeper bankkeeper.Keeper SlashingKeeper slashingkeeper.Keeper //govKeeper gov.Keeper - CrisisKeeper crisiskeeper.Keeper - UpgradeKeeper upgradekeeper.Keeper - ParamsKeeper paramskeeper.Keeper - EvidenceKeeper evidencekeeper.Keeper - PermKeeper permkeeper.Keeper - IdentityKeeper identitykeeper.Keeper - NodeKeeper nodekeeper.Keeper - FeeGrantKeeper feegrantkeeper.Keeper - Layer2Keeper sidechainkeeper.Keeper + CrisisKeeper crisiskeeper.Keeper + UpgradeKeeper upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + EvidenceKeeper evidencekeeper.Keeper + PermKeeper permkeeper.Keeper + IdentityKeeper identitykeeper.Keeper + NodeKeeper nodekeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + SideChainKeeper sidechainkeeper.Keeper // the module manager mm *module.Manager @@ -253,7 +252,7 @@ func NewSimApp( app.PermKeeper = permkeeper.NewKeeper(appCodec, keys[permtypes.StoreKey]) app.IdentityKeeper = identitykeeper.NewKeeper(appCodec, keys[identitytypes.StoreKey]) - app.Layer2Keeper = sidechainkeeper.NewKeeper(appCodec, keys[sidechaintypes.StoreKey], app.AccountKeeper) + app.SideChainKeeper = sidechainkeeper.NewKeeper(appCodec, keys[sidechaintypes.StoreKey], app.AccountKeeper) /**** Module Options ****/ @@ -277,7 +276,7 @@ func NewSimApp( perm.NewAppModule(appCodec, app.PermKeeper), identity.NewAppModule(app.IdentityKeeper), node.NewAppModule(appCodec, app.NodeKeeper), - sidechain.NewAppModule(appCodec, app.Layer2Keeper), + sidechain.NewAppModule(appCodec, app.SideChainKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that