Skip to content

Commit

Permalink
feat: implement cross-chain mechanism between op and greenfield (#413)
Browse files Browse the repository at this point in the history
* feat: implement cross-chain mechanism between op and greenfield

* fix unit tests

* fix swagger
  • Loading branch information
yutianwu authored Aug 14, 2023
1 parent e973e3b commit 7869d8e
Show file tree
Hide file tree
Showing 26 changed files with 1,231 additions and 351 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ func (app *App) initModules(ctx sdk.Context) {

func (app *App) initCrossChain() {
app.CrossChainKeeper.SetSrcChainID(sdk.ChainID(app.appConfig.CrossChain.SrcChainId))
app.CrossChainKeeper.SetDestChainID(sdk.ChainID(app.appConfig.CrossChain.DestBscChainId))
app.CrossChainKeeper.SetDestBscChainID(sdk.ChainID(app.appConfig.CrossChain.DestBscChainId))
}

func (app *App) initBridge() {
Expand Down
12 changes: 6 additions & 6 deletions e2e/tests/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func (s *StorageTestSuite) TestMirrorBucket() {
s.Require().Equal(queryHeadBucketResponse.BucketInfo.SourceType, storagetypes.SOURCE_TYPE_ORIGIN)

// MirrorBucket using id
msgMirrorBucket := storagetypes.NewMsgMirrorBucket(user.GetAddr(), queryHeadBucketResponse.BucketInfo.Id, "")
msgMirrorBucket := storagetypes.NewMsgMirrorBucket(user.GetAddr(), sdk.ChainID(714), queryHeadBucketResponse.BucketInfo.Id, "")
s.SendTxBlock(user, msgMirrorBucket)

// CreateBucket
Expand All @@ -548,7 +548,7 @@ func (s *StorageTestSuite) TestMirrorBucket() {
s.SendTxBlock(user, msgCreateBucket)

// MirrorBucket using name
msgMirrorBucket = storagetypes.NewMsgMirrorBucket(user.GetAddr(), sdk.NewUint(0), bucketName)
msgMirrorBucket = storagetypes.NewMsgMirrorBucket(user.GetAddr(), sdk.ChainID(714), sdk.NewUint(0), bucketName)
s.SendTxBlock(user, msgMirrorBucket)
}

Expand Down Expand Up @@ -653,7 +653,7 @@ func (s *StorageTestSuite) TestMirrorObject() {
s.Require().Equal(queryListObjectsResponse.ObjectInfos[0].ObjectName, objectName)

// MirrorObject using id
msgMirrorObject := storagetypes.NewMsgMirrorObject(user.GetAddr(), queryHeadObjectResponse.ObjectInfo.Id, "", "")
msgMirrorObject := storagetypes.NewMsgMirrorObject(user.GetAddr(), sdk.ChainID(714), queryHeadObjectResponse.ObjectInfo.Id, "", "")
s.SendTxBlock(user, msgMirrorObject)

// CreateObject
Expand Down Expand Up @@ -691,7 +691,7 @@ func (s *StorageTestSuite) TestMirrorObject() {
s.SendTxBlock(sp.SealKey, msgSealObject)

// MirrorObject using names
msgMirrorObject = storagetypes.NewMsgMirrorObject(user.GetAddr(), sdk.NewUint(0), bucketName, objectName)
msgMirrorObject = storagetypes.NewMsgMirrorObject(user.GetAddr(), sdk.ChainID(714), sdk.NewUint(0), bucketName, objectName)
s.SendTxBlock(user, msgMirrorObject)
}

Expand All @@ -714,7 +714,7 @@ func (s *StorageTestSuite) TestMirrorGroup() {
s.Require().Equal(queryHeadGroupResp.GroupInfo.Owner, owner.GetAddr().String())

// MirrorGroup using id
msgMirrorGroup := storagetypes.NewMsgMirrorGroup(owner.GetAddr(), queryHeadGroupResp.GroupInfo.Id, "")
msgMirrorGroup := storagetypes.NewMsgMirrorGroup(owner.GetAddr(), sdk.ChainID(714), queryHeadGroupResp.GroupInfo.Id, "")
s.SendTxBlock(owner, msgMirrorGroup)

// CreateGroup
Expand All @@ -723,7 +723,7 @@ func (s *StorageTestSuite) TestMirrorGroup() {
s.SendTxBlock(owner, msgCreateGroup)

// MirrorGroup using name
msgMirrorGroup = storagetypes.NewMsgMirrorGroup(owner.GetAddr(), sdk.NewUint(0), groupName)
msgMirrorGroup = storagetypes.NewMsgMirrorGroup(owner.GetAddr(), sdk.ChainID(714), sdk.NewUint(0), groupName)
s.SendTxBlock(owner, msgMirrorGroup)
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ replace (
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.2
github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.1
github.com/cosmos/cosmos-sdk => github.com/yutianwu/greenfield-cosmos-sdk v0.0.0-20230810000415-718b1f26fd54
github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ github.com/bnb-chain/greenfield-cometbft v0.0.2 h1:bRamS8Lq1lA3ttRLZBha22uiNG5tq
github.com/bnb-chain/greenfield-cometbft v0.0.2/go.mod h1:EBmwmUdaNbGPyGjf1cMuoN3pAeM2tQu7Lfg95813EAw=
github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 h1:XcWulGacHVRiSCx90Q8Y//ajOrLNBQWR/KDB89dy3cU=
github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1/go.mod h1:ey1CiK4bYo1RBNJLRiVbYr5CMdSxci9S/AZRINLtppI=
github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.1 h1:SpkwHzAjIllIQG8av7MybFjJ8mhW1ZZ+P9JqJIsENxI=
github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.1/go.mod h1:vyZi5fr4gZBVbhV/TLxbm6T8vylHXbfqQmDCUCUPPfo=
github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9 h1:6fLpmmI0EZvDTfPvI0zy5dBaaTUboHnEkoC5/p/w8TQ=
github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9/go.mod h1:rbc4o84RSEvhf09o2+4Qiazsv0snRJLiEZdk17HeIDw=
github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9 h1:1ZdK+iR1Up02bOa2YTZCml7PBpP//kcdamOcK6aWO/s=
Expand Down Expand Up @@ -1425,6 +1423,8 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yutianwu/greenfield-cosmos-sdk v0.0.0-20230810000415-718b1f26fd54 h1:J6UL48UJAANjch7euMvJDh6z1wYtNGa/f+SX7DDExgQ=
github.com/yutianwu/greenfield-cosmos-sdk v0.0.0-20230810000415-718b1f26fd54/go.mod h1:hpvg93+VGXHAcv/pVVdp24Ik/9miw4uRh8+tD0DDYas=
github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo=
github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c=
Expand Down
5 changes: 3 additions & 2 deletions proto/greenfield/storage/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ enum SourceType {
option (gogoproto.goproto_enum_prefix) = false;

SOURCE_TYPE_ORIGIN = 0;
SOURCE_TYPE_BSC_CROSS_CHAIN = 1;
SOURCE_TYPE_MIRROR_PENDING = 2;
SOURCE_TYPE_MIRROR_PENDING = 1;
SOURCE_TYPE_BSC_CROSS_CHAIN = 2;
SOURCE_TYPE_OP_CROSS_CHAIN = 3;
}

// BucketStatus represents the status of a bucket. After a user successfully
Expand Down
12 changes: 12 additions & 0 deletions proto/greenfield/storage/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ message Params {
uint64 min_quota_update_interval = 16;
// the max number of local virtual group per bucket
uint32 max_local_virtual_group_num_per_bucket = 17;
// relayer fee for the mirror bucket tx to op chain
string op_mirror_bucket_relayer_fee = 18;
// relayer fee for the ACK or FAIL_ACK package of the mirror bucket tx to op chain
string op_mirror_bucket_ack_relayer_fee = 19;
// relayer fee for the mirror object tx to op chain
string op_mirror_object_relayer_fee = 20;
// Relayer fee for the ACK or FAIL_ACK package of the mirror object tx to op chain
string op_mirror_object_ack_relayer_fee = 21;
// relayer fee for the mirror object tx to op chain
string op_mirror_group_relayer_fee = 22;
// Relayer fee for the ACK or FAIL_ACK package of the mirror object tx to op chain
string op_mirror_group_ack_relayer_fee = 23;
}

// VersionedParams defines the parameters for the storage module with multi version, each version store with different timestamp.
Expand Down
9 changes: 9 additions & 0 deletions proto/greenfield/storage/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@ message MsgMirrorObject {

// object_name defines the name of object
string object_name = 4;

// destination chain id
uint32 dest_chain_id = 5;
}

message MsgMirrorObjectResponse {}
Expand All @@ -509,6 +512,9 @@ message MsgMirrorBucket {

// bucket_name defines a globally unique name of bucket
string bucket_name = 3;

// destination chain id
uint32 dest_chain_id = 4;
}

message MsgUpdateObjectInfoResponse {}
Expand Down Expand Up @@ -547,6 +553,9 @@ message MsgMirrorGroup {

// group_name defines the name of the group
string group_name = 3;

// destination chain id
uint32 dest_chain_id = 4;
}

message MsgMirrorGroupResponse {}
Expand Down
Loading

0 comments on commit 7869d8e

Please sign in to comment.