From 2af624b6d0fdab5365e9ce2e737d85c922b6e476 Mon Sep 17 00:00:00 2001 From: ffranr Date: Thu, 5 Oct 2023 16:22:42 +0100 Subject: [PATCH] WIP --- rpcserver.go | 6 +- tapdb/universe_federation.go | 58 ++++- taprpc/universerpc/universe.pb.go | 260 +++++++++++++---------- taprpc/universerpc/universe.proto | 29 ++- taprpc/universerpc/universe.swagger.json | 34 ++- universe/interface.go | 10 +- 6 files changed, 255 insertions(+), 142 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 3c497b810..b65093287 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -3299,15 +3299,15 @@ func (r *rpcServer) SetFederationSyncConfig(ctx context.Context, // Unmarshal general sync config. var syncGeneralConfig *universe.FedGlobalSyncConfig if req.GeneralSyncConfig != nil { - proofTypes, err := universe.ParseProofType( - req.GeneralSyncConfig.ProofTypes, + proofType, err := universe.ParseProofType( + req.GlobalSyncConfig.ProofType, ) if err != nil { return nil, fmt.Errorf("unable to parse proof "+ "types: %w", err) } syncGeneralConfig = &universe.FedGlobalSyncConfig{ - ProofTypes: proofTypes, + ProofType: proofType, } } diff --git a/tapdb/universe_federation.go b/tapdb/universe_federation.go index 4eecfd604..b094f980c 100644 --- a/tapdb/universe_federation.go +++ b/tapdb/universe_federation.go @@ -223,9 +223,12 @@ func (u *UniverseFederationDB) UpsertFederationSyncConfig( var writeTx UniverseFederationOptions return u.db.ExecTx(ctx, &writeTx, func(db UniverseServerStore) error { // Upsert general federation sync config. - err := db.SetFederationGlobalSyncConfig( - ctx, globalSyncConfig.ProofTypes.String(), - ) + params := SetFedGlobalSyncConfigParams{ + ProofType: globalSyncConfig.ProofType.String(), + AllowSyncInsert: globalSyncConfig.AllowSyncInsert, + AllowSyncExport: globalSyncConfig.AllowSyncExport, + } + err := db.SetFederationGlobalSyncConfig(ctx, params) if err != nil { return err } @@ -251,14 +254,47 @@ func (u *UniverseFederationDB) UpsertFederationSyncConfig( assetIDBytes = uniID.AssetID[:] } - params := UpsertFedUniSyncConfigParams{ - AssetID: assetIDBytes, - GroupKey: groupPubKey, - ProofType: config.ProofTypes.String(), - } - err := db.UpsertFederationUniSyncConfig(ctx, params) - if err != nil { - return err + // If the proof type is unspecified, then we'll set + // the config for both issuance and transfer proof + // type universes. + if config.UniverseID.ProofType == universe.ProofTypeUnspecified { + // Set config for issuance proof type universe. + proofType := universe.ProofTypeIssuance + err := db.UpsertFederationUniSyncConfig( + ctx, UpsertFedUniSyncConfigParams{ + AssetID: assetIDBytes, + GroupKey: groupPubKey, + ProofType: proofType.String(), + }, + ) + if err != nil { + return err + } + + // Set config for transfer proof type universe. + proofType = universe.ProofTypeTransfer + err = db.UpsertFederationUniSyncConfig( + ctx, UpsertFedUniSyncConfigParams{ + AssetID: assetIDBytes, + GroupKey: groupPubKey, + ProofType: proofType.String(), + }, + ) + if err != nil { + return err + } + } else { + proofType := config.UniverseID.ProofType + err := db.UpsertFederationUniSyncConfig( + ctx, UpsertFedUniSyncConfigParams{ + AssetID: assetIDBytes, + GroupKey: groupPubKey, + ProofType: proofType.String(), + }, + ) + if err != nil { + return err + } } } diff --git a/taprpc/universerpc/universe.pb.go b/taprpc/universerpc/universe.pb.go index 876204082..794f0bd21 100644 --- a/taprpc/universerpc/universe.pb.go +++ b/taprpc/universerpc/universe.pb.go @@ -2529,8 +2529,8 @@ type SetFederationSyncConfigRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GeneralSyncConfig *GeneralFederationSyncConfig `protobuf:"bytes,1,opt,name=general_sync_config,json=generalSyncConfig,proto3" json:"general_sync_config,omitempty"` - AssetSyncConfig []*AssetFederationSyncConfig `protobuf:"bytes,2,rep,name=asset_sync_config,json=assetSyncConfig,proto3" json:"asset_sync_config,omitempty"` + GlobalSyncConfig *GlobalFederationSyncConfig `protobuf:"bytes,1,opt,name=global_sync_config,json=globalSyncConfig,proto3" json:"global_sync_config,omitempty"` + AssetSyncConfig []*AssetFederationSyncConfig `protobuf:"bytes,2,rep,name=asset_sync_config,json=assetSyncConfig,proto3" json:"asset_sync_config,omitempty"` } func (x *SetFederationSyncConfigRequest) Reset() { @@ -2565,9 +2565,9 @@ func (*SetFederationSyncConfigRequest) Descriptor() ([]byte, []int) { return file_universerpc_universe_proto_rawDescGZIP(), []int{38} } -func (x *SetFederationSyncConfigRequest) GetGeneralSyncConfig() *GeneralFederationSyncConfig { +func (x *SetFederationSyncConfigRequest) GetGlobalSyncConfig() *GlobalFederationSyncConfig { if x != nil { - return x.GeneralSyncConfig + return x.GlobalSyncConfig } return nil } @@ -2617,18 +2617,25 @@ func (*SetFederationSyncConfigResponse) Descriptor() ([]byte, []int) { return file_universerpc_universe_proto_rawDescGZIP(), []int{39} } -// GeneralFederationSyncConfig is a general configuration for universe -// federation syncing. -type GeneralFederationSyncConfig struct { +// GlobalFederationSyncConfig is a global configuration for universe federation +// syncing. +type GlobalFederationSyncConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ProofTypes string `protobuf:"bytes,1,opt,name=proof_types,json=proofTypes,proto3" json:"proof_types,omitempty"` + // This field is the target universe proof type. + ProofType ProofType `protobuf:"varint,1,opt,name=proof_type,json=proofType,proto3,enum=universerpc.ProofType" json:"proof_type,omitempty"` + // This boolean is a flag which indicates whether leaves from the given + // universe proof type have may be inserted via federation sync. + AllowSyncInsert bool `protobuf:"varint,2,opt,name=allow_sync_insert,json=allowSyncInsert,proto3" json:"allow_sync_insert,omitempty"` + // This boolean is a flag which indicates whether leaves from the given + // universe proof type have may be exported via federation sync. + AllowSyncExport bool `protobuf:"varint,3,opt,name=allow_sync_export,json=allowSyncExport,proto3" json:"allow_sync_export,omitempty"` } -func (x *GeneralFederationSyncConfig) Reset() { - *x = GeneralFederationSyncConfig{} +func (x *GlobalFederationSyncConfig) Reset() { + *x = GlobalFederationSyncConfig{} if protoimpl.UnsafeEnabled { mi := &file_universerpc_universe_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -2636,13 +2643,13 @@ func (x *GeneralFederationSyncConfig) Reset() { } } -func (x *GeneralFederationSyncConfig) String() string { +func (x *GlobalFederationSyncConfig) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GeneralFederationSyncConfig) ProtoMessage() {} +func (*GlobalFederationSyncConfig) ProtoMessage() {} -func (x *GeneralFederationSyncConfig) ProtoReflect() protoreflect.Message { +func (x *GlobalFederationSyncConfig) ProtoReflect() protoreflect.Message { mi := &file_universerpc_universe_proto_msgTypes[40] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -2654,16 +2661,30 @@ func (x *GeneralFederationSyncConfig) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GeneralFederationSyncConfig.ProtoReflect.Descriptor instead. -func (*GeneralFederationSyncConfig) Descriptor() ([]byte, []int) { +// Deprecated: Use GlobalFederationSyncConfig.ProtoReflect.Descriptor instead. +func (*GlobalFederationSyncConfig) Descriptor() ([]byte, []int) { return file_universerpc_universe_proto_rawDescGZIP(), []int{40} } -func (x *GeneralFederationSyncConfig) GetProofTypes() string { +func (x *GlobalFederationSyncConfig) GetProofType() ProofType { if x != nil { - return x.ProofTypes + return x.ProofType } - return "" + return ProofType_UNSPECIFIED +} + +func (x *GlobalFederationSyncConfig) GetAllowSyncInsert() bool { + if x != nil { + return x.AllowSyncInsert + } + return false +} + +func (x *GlobalFederationSyncConfig) GetAllowSyncExport() bool { + if x != nil { + return x.AllowSyncExport + } + return false } // AssetFederationSyncConfig is an asset universe specific configuration for @@ -2674,8 +2695,13 @@ type AssetFederationSyncConfig struct { unknownFields protoimpl.UnknownFields // The ID of the universe to configure. - Id *ID `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - ProofTypes string `protobuf:"bytes,2,opt,name=proof_types,json=proofTypes,proto3" json:"proof_types,omitempty"` + Id *ID `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // This boolean is a flag which indicates whether leaves from the given + // universe have may be inserted via federation sync. + AllowSyncInsert bool `protobuf:"varint,2,opt,name=allow_sync_insert,json=allowSyncInsert,proto3" json:"allow_sync_insert,omitempty"` + // This boolean is a flag which indicates whether leaves from the given + // universe have may be exported via federation sync. + AllowSyncExport bool `protobuf:"varint,3,opt,name=allow_sync_export,json=allowSyncExport,proto3" json:"allow_sync_export,omitempty"` } func (x *AssetFederationSyncConfig) Reset() { @@ -2717,11 +2743,18 @@ func (x *AssetFederationSyncConfig) GetId() *ID { return nil } -func (x *AssetFederationSyncConfig) GetProofTypes() string { +func (x *AssetFederationSyncConfig) GetAllowSyncInsert() bool { if x != nil { - return x.ProofTypes + return x.AllowSyncInsert } - return "" + return false +} + +func (x *AssetFederationSyncConfig) GetAllowSyncExport() bool { + if x != nil { + return x.AllowSyncExport + } + return false } type QueryFederationSyncConfigRequest struct { @@ -2777,8 +2810,8 @@ type QueryFederationSyncConfigResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GeneralSyncConfig *GeneralFederationSyncConfig `protobuf:"bytes,1,opt,name=general_sync_config,json=generalSyncConfig,proto3" json:"general_sync_config,omitempty"` - AssetSyncConfigs []*AssetFederationSyncConfig `protobuf:"bytes,2,rep,name=asset_sync_configs,json=assetSyncConfigs,proto3" json:"asset_sync_configs,omitempty"` + GlobalSyncConfig *GlobalFederationSyncConfig `protobuf:"bytes,1,opt,name=global_sync_config,json=globalSyncConfig,proto3" json:"global_sync_config,omitempty"` + AssetSyncConfigs []*AssetFederationSyncConfig `protobuf:"bytes,2,rep,name=asset_sync_configs,json=assetSyncConfigs,proto3" json:"asset_sync_configs,omitempty"` } func (x *QueryFederationSyncConfigResponse) Reset() { @@ -2813,9 +2846,9 @@ func (*QueryFederationSyncConfigResponse) Descriptor() ([]byte, []int) { return file_universerpc_universe_proto_rawDescGZIP(), []int{43} } -func (x *QueryFederationSyncConfigResponse) GetGeneralSyncConfig() *GeneralFederationSyncConfig { +func (x *QueryFederationSyncConfigResponse) GetGlobalSyncConfig() *GlobalFederationSyncConfig { if x != nil { - return x.GeneralSyncConfig + return x.GlobalSyncConfig } return nil } @@ -3110,43 +3143,53 @@ var file_universerpc_universe_proto_rawDesc = []byte{ 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x10, 0x6e, 0x65, 0x77, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x6e, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, - 0x22, 0xce, 0x01, 0x0a, 0x1e, 0x53, 0x65, 0x74, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x22, 0xcb, 0x01, 0x0a, 0x1e, 0x53, 0x65, 0x74, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x58, 0x0a, 0x13, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x5f, 0x73, - 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x28, 0x2e, 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, 0x65, 0x72, 0x70, 0x63, 0x2e, 0x47, - 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x67, 0x65, 0x6e, 0x65, - 0x72, 0x61, 0x6c, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, - 0x11, 0x61, 0x73, 0x73, 0x65, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x75, 0x6e, 0x69, 0x76, 0x65, - 0x72, 0x73, 0x65, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x73, 0x73, 0x65, 0x74, 0x46, 0x65, 0x64, 0x65, + 0x65, 0x73, 0x74, 0x12, 0x55, 0x0a, 0x12, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x73, 0x79, + 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x27, 0x2e, 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, 0x65, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x6c, + 0x6f, 0x62, 0x61, 0x6c, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x79, + 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, + 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x11, 0x61, 0x73, + 0x73, 0x65, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, 0x65, + 0x72, 0x70, 0x63, 0x2e, 0x41, 0x73, 0x73, 0x65, 0x74, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0f, 0x61, + 0x73, 0x73, 0x65, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x21, + 0x0a, 0x1f, 0x53, 0x65, 0x74, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0xab, 0x01, 0x0a, 0x1a, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x0f, 0x61, 0x73, 0x73, 0x65, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x22, 0x21, 0x0a, 0x1f, 0x53, 0x65, 0x74, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3e, 0x0a, 0x1b, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x46, + 0x12, 0x35, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, 0x65, 0x72, + 0x70, 0x63, 0x2e, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x70, 0x72, + 0x6f, 0x6f, 0x66, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x61, 0x6c, 0x6c, 0x6f, 0x77, + 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0f, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x73, + 0x65, 0x72, 0x74, 0x12, 0x2a, 0x0a, 0x11, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x73, 0x79, 0x6e, + 0x63, 0x5f, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, + 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x53, 0x79, 0x6e, 0x63, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x22, + 0x94, 0x01, 0x0a, 0x19, 0x41, 0x73, 0x73, 0x65, 0x74, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x75, 0x6e, 0x69, 0x76, + 0x65, 0x72, 0x73, 0x65, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x44, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2a, + 0x0a, 0x11, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x69, 0x6e, 0x73, + 0x65, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x61, 0x6c, 0x6c, 0x6f, 0x77, + 0x53, 0x79, 0x6e, 0x63, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x12, 0x2a, 0x0a, 0x11, 0x61, 0x6c, + 0x6c, 0x6f, 0x77, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x53, 0x79, 0x6e, 0x63, + 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x43, 0x0a, 0x20, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x54, - 0x79, 0x70, 0x65, 0x73, 0x22, 0x5d, 0x0a, 0x19, 0x41, 0x73, 0x73, 0x65, 0x74, 0x46, 0x65, 0x64, - 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x1f, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, - 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, 0x65, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x44, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x74, 0x79, 0x70, 0x65, - 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x54, 0x79, - 0x70, 0x65, 0x73, 0x22, 0x43, 0x0a, 0x20, 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x65, 0x64, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, 0x65, 0x72, 0x70, - 0x63, 0x2e, 0x49, 0x44, 0x52, 0x02, 0x69, 0x64, 0x22, 0xd3, 0x01, 0x0a, 0x21, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x79, 0x6e, 0x63, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x58, - 0x0a, 0x13, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x75, 0x6e, - 0x69, 0x76, 0x65, 0x72, 0x73, 0x65, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, - 0x6c, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x79, 0x6e, 0x63, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x53, 0x79, + 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, + 0x65, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x44, 0x52, 0x02, 0x69, 0x64, 0x22, 0xd0, 0x01, 0x0a, 0x21, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x55, 0x0a, 0x12, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x73, 0x79, 0x6e, 0x63, + 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, + 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, 0x65, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x6c, 0x6f, 0x62, + 0x61, 0x6c, 0x46, 0x65, 0x64, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x79, 0x6e, 0x63, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x54, 0x0a, 0x12, 0x61, 0x73, 0x73, 0x65, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, 0x65, 0x72, @@ -3342,7 +3385,7 @@ var file_universerpc_universe_proto_goTypes = []interface{}{ (*GroupedUniverseEvents)(nil), // 42: universerpc.GroupedUniverseEvents (*SetFederationSyncConfigRequest)(nil), // 43: universerpc.SetFederationSyncConfigRequest (*SetFederationSyncConfigResponse)(nil), // 44: universerpc.SetFederationSyncConfigResponse - (*GeneralFederationSyncConfig)(nil), // 45: universerpc.GeneralFederationSyncConfig + (*GlobalFederationSyncConfig)(nil), // 45: universerpc.GlobalFederationSyncConfig (*AssetFederationSyncConfig)(nil), // 46: universerpc.AssetFederationSyncConfig (*QueryFederationSyncConfigRequest)(nil), // 47: universerpc.QueryFederationSyncConfigRequest (*QueryFederationSyncConfigResponse)(nil), // 48: universerpc.QueryFederationSyncConfigResponse @@ -3388,52 +3431,53 @@ var file_universerpc_universe_proto_depIdxs = []int32{ 52, // 33: universerpc.AssetStatsSnapshot.asset_type:type_name -> taprpc.AssetType 38, // 34: universerpc.UniverseAssetStats.asset_stats:type_name -> universerpc.AssetStatsSnapshot 42, // 35: universerpc.QueryEventsResponse.events:type_name -> universerpc.GroupedUniverseEvents - 45, // 36: universerpc.SetFederationSyncConfigRequest.general_sync_config:type_name -> universerpc.GeneralFederationSyncConfig + 45, // 36: universerpc.SetFederationSyncConfigRequest.global_sync_config:type_name -> universerpc.GlobalFederationSyncConfig 46, // 37: universerpc.SetFederationSyncConfigRequest.asset_sync_config:type_name -> universerpc.AssetFederationSyncConfig - 7, // 38: universerpc.AssetFederationSyncConfig.id:type_name -> universerpc.ID - 7, // 39: universerpc.QueryFederationSyncConfigRequest.id:type_name -> universerpc.ID - 45, // 40: universerpc.QueryFederationSyncConfigResponse.general_sync_config:type_name -> universerpc.GeneralFederationSyncConfig - 46, // 41: universerpc.QueryFederationSyncConfigResponse.asset_sync_configs:type_name -> universerpc.AssetFederationSyncConfig - 8, // 42: universerpc.AssetRootResponse.UniverseRootsEntry.value:type_name -> universerpc.UniverseRoot - 5, // 43: universerpc.Universe.AssetRoots:input_type -> universerpc.AssetRootRequest - 10, // 44: universerpc.Universe.QueryAssetRoots:input_type -> universerpc.AssetRootQuery - 12, // 45: universerpc.Universe.DeleteAssetRoot:input_type -> universerpc.DeleteRootQuery - 7, // 46: universerpc.Universe.AssetLeafKeys:input_type -> universerpc.ID - 7, // 47: universerpc.Universe.AssetLeaves:input_type -> universerpc.ID - 19, // 48: universerpc.Universe.QueryProof:input_type -> universerpc.UniverseKey - 21, // 49: universerpc.Universe.InsertProof:input_type -> universerpc.AssetProof - 22, // 50: universerpc.Universe.Info:input_type -> universerpc.InfoRequest - 25, // 51: universerpc.Universe.SyncUniverse:input_type -> universerpc.SyncRequest - 30, // 52: universerpc.Universe.ListFederationServers:input_type -> universerpc.ListFederationServersRequest - 32, // 53: universerpc.Universe.AddFederationServer:input_type -> universerpc.AddFederationServerRequest - 34, // 54: universerpc.Universe.DeleteFederationServer:input_type -> universerpc.DeleteFederationServerRequest - 27, // 55: universerpc.Universe.UniverseStats:input_type -> universerpc.StatsRequest - 37, // 56: universerpc.Universe.QueryAssetStats:input_type -> universerpc.AssetStatsQuery - 40, // 57: universerpc.Universe.QueryEvents:input_type -> universerpc.QueryEventsRequest - 43, // 58: universerpc.Universe.SetFederationSyncConfig:input_type -> universerpc.SetFederationSyncConfigRequest - 47, // 59: universerpc.Universe.QueryFederationSyncConfig:input_type -> universerpc.QueryFederationSyncConfigRequest - 9, // 60: universerpc.Universe.AssetRoots:output_type -> universerpc.AssetRootResponse - 11, // 61: universerpc.Universe.QueryAssetRoots:output_type -> universerpc.QueryRootResponse - 13, // 62: universerpc.Universe.DeleteAssetRoot:output_type -> universerpc.DeleteRootResponse - 16, // 63: universerpc.Universe.AssetLeafKeys:output_type -> universerpc.AssetLeafKeyResponse - 18, // 64: universerpc.Universe.AssetLeaves:output_type -> universerpc.AssetLeafResponse - 20, // 65: universerpc.Universe.QueryProof:output_type -> universerpc.AssetProofResponse - 20, // 66: universerpc.Universe.InsertProof:output_type -> universerpc.AssetProofResponse - 23, // 67: universerpc.Universe.Info:output_type -> universerpc.InfoResponse - 28, // 68: universerpc.Universe.SyncUniverse:output_type -> universerpc.SyncResponse - 31, // 69: universerpc.Universe.ListFederationServers:output_type -> universerpc.ListFederationServersResponse - 33, // 70: universerpc.Universe.AddFederationServer:output_type -> universerpc.AddFederationServerResponse - 35, // 71: universerpc.Universe.DeleteFederationServer:output_type -> universerpc.DeleteFederationServerResponse - 36, // 72: universerpc.Universe.UniverseStats:output_type -> universerpc.StatsResponse - 39, // 73: universerpc.Universe.QueryAssetStats:output_type -> universerpc.UniverseAssetStats - 41, // 74: universerpc.Universe.QueryEvents:output_type -> universerpc.QueryEventsResponse - 44, // 75: universerpc.Universe.SetFederationSyncConfig:output_type -> universerpc.SetFederationSyncConfigResponse - 48, // 76: universerpc.Universe.QueryFederationSyncConfig:output_type -> universerpc.QueryFederationSyncConfigResponse - 60, // [60:77] is the sub-list for method output_type - 43, // [43:60] is the sub-list for method input_type - 43, // [43:43] is the sub-list for extension type_name - 43, // [43:43] is the sub-list for extension extendee - 0, // [0:43] is the sub-list for field type_name + 0, // 38: universerpc.GlobalFederationSyncConfig.proof_type:type_name -> universerpc.ProofType + 7, // 39: universerpc.AssetFederationSyncConfig.id:type_name -> universerpc.ID + 7, // 40: universerpc.QueryFederationSyncConfigRequest.id:type_name -> universerpc.ID + 45, // 41: universerpc.QueryFederationSyncConfigResponse.global_sync_config:type_name -> universerpc.GlobalFederationSyncConfig + 46, // 42: universerpc.QueryFederationSyncConfigResponse.asset_sync_configs:type_name -> universerpc.AssetFederationSyncConfig + 8, // 43: universerpc.AssetRootResponse.UniverseRootsEntry.value:type_name -> universerpc.UniverseRoot + 5, // 44: universerpc.Universe.AssetRoots:input_type -> universerpc.AssetRootRequest + 10, // 45: universerpc.Universe.QueryAssetRoots:input_type -> universerpc.AssetRootQuery + 12, // 46: universerpc.Universe.DeleteAssetRoot:input_type -> universerpc.DeleteRootQuery + 7, // 47: universerpc.Universe.AssetLeafKeys:input_type -> universerpc.ID + 7, // 48: universerpc.Universe.AssetLeaves:input_type -> universerpc.ID + 19, // 49: universerpc.Universe.QueryProof:input_type -> universerpc.UniverseKey + 21, // 50: universerpc.Universe.InsertProof:input_type -> universerpc.AssetProof + 22, // 51: universerpc.Universe.Info:input_type -> universerpc.InfoRequest + 25, // 52: universerpc.Universe.SyncUniverse:input_type -> universerpc.SyncRequest + 30, // 53: universerpc.Universe.ListFederationServers:input_type -> universerpc.ListFederationServersRequest + 32, // 54: universerpc.Universe.AddFederationServer:input_type -> universerpc.AddFederationServerRequest + 34, // 55: universerpc.Universe.DeleteFederationServer:input_type -> universerpc.DeleteFederationServerRequest + 27, // 56: universerpc.Universe.UniverseStats:input_type -> universerpc.StatsRequest + 37, // 57: universerpc.Universe.QueryAssetStats:input_type -> universerpc.AssetStatsQuery + 40, // 58: universerpc.Universe.QueryEvents:input_type -> universerpc.QueryEventsRequest + 43, // 59: universerpc.Universe.SetFederationSyncConfig:input_type -> universerpc.SetFederationSyncConfigRequest + 47, // 60: universerpc.Universe.QueryFederationSyncConfig:input_type -> universerpc.QueryFederationSyncConfigRequest + 9, // 61: universerpc.Universe.AssetRoots:output_type -> universerpc.AssetRootResponse + 11, // 62: universerpc.Universe.QueryAssetRoots:output_type -> universerpc.QueryRootResponse + 13, // 63: universerpc.Universe.DeleteAssetRoot:output_type -> universerpc.DeleteRootResponse + 16, // 64: universerpc.Universe.AssetLeafKeys:output_type -> universerpc.AssetLeafKeyResponse + 18, // 65: universerpc.Universe.AssetLeaves:output_type -> universerpc.AssetLeafResponse + 20, // 66: universerpc.Universe.QueryProof:output_type -> universerpc.AssetProofResponse + 20, // 67: universerpc.Universe.InsertProof:output_type -> universerpc.AssetProofResponse + 23, // 68: universerpc.Universe.Info:output_type -> universerpc.InfoResponse + 28, // 69: universerpc.Universe.SyncUniverse:output_type -> universerpc.SyncResponse + 31, // 70: universerpc.Universe.ListFederationServers:output_type -> universerpc.ListFederationServersResponse + 33, // 71: universerpc.Universe.AddFederationServer:output_type -> universerpc.AddFederationServerResponse + 35, // 72: universerpc.Universe.DeleteFederationServer:output_type -> universerpc.DeleteFederationServerResponse + 36, // 73: universerpc.Universe.UniverseStats:output_type -> universerpc.StatsResponse + 39, // 74: universerpc.Universe.QueryAssetStats:output_type -> universerpc.UniverseAssetStats + 41, // 75: universerpc.Universe.QueryEvents:output_type -> universerpc.QueryEventsResponse + 44, // 76: universerpc.Universe.SetFederationSyncConfig:output_type -> universerpc.SetFederationSyncConfigResponse + 48, // 77: universerpc.Universe.QueryFederationSyncConfig:output_type -> universerpc.QueryFederationSyncConfigResponse + 61, // [61:78] is the sub-list for method output_type + 44, // [44:61] is the sub-list for method input_type + 44, // [44:44] is the sub-list for extension type_name + 44, // [44:44] is the sub-list for extension extendee + 0, // [0:44] is the sub-list for field type_name } func init() { file_universerpc_universe_proto_init() } @@ -3923,7 +3967,7 @@ func file_universerpc_universe_proto_init() { } } file_universerpc_universe_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GeneralFederationSyncConfig); i { + switch v := v.(*GlobalFederationSyncConfig); i { case 0: return &v.state case 1: diff --git a/taprpc/universerpc/universe.proto b/taprpc/universerpc/universe.proto index 5388d8cd2..8cf1cf0c1 100644 --- a/taprpc/universerpc/universe.proto +++ b/taprpc/universerpc/universe.proto @@ -499,7 +499,7 @@ message GroupedUniverseEvents { } message SetFederationSyncConfigRequest { - GeneralFederationSyncConfig general_sync_config = 1; + GlobalFederationSyncConfig global_sync_config = 1; repeated AssetFederationSyncConfig asset_sync_config = 2; } @@ -507,10 +507,19 @@ message SetFederationSyncConfigRequest { message SetFederationSyncConfigResponse { } -// GeneralFederationSyncConfig is a general configuration for universe -// federation syncing. -message GeneralFederationSyncConfig { - string proof_types = 1; +// GlobalFederationSyncConfig is a global configuration for universe federation +// syncing. +message GlobalFederationSyncConfig { + // This field is the target universe proof type. + ProofType proof_type = 1; + + // This boolean is a flag which indicates whether leaves from the given + // universe proof type have may be inserted via federation sync. + bool allow_sync_insert = 2; + + // This boolean is a flag which indicates whether leaves from the given + // universe proof type have may be exported via federation sync. + bool allow_sync_export = 3; } // AssetFederationSyncConfig is an asset universe specific configuration for @@ -519,7 +528,13 @@ message AssetFederationSyncConfig { // The ID of the universe to configure. ID id = 1; - string proof_types = 2; + // This boolean is a flag which indicates whether leaves from the given + // universe have may be inserted via federation sync. + bool allow_sync_insert = 2; + + // This boolean is a flag which indicates whether leaves from the given + // universe have may be exported via federation sync. + bool allow_sync_export = 3; } message QueryFederationSyncConfigRequest { @@ -528,7 +543,7 @@ message QueryFederationSyncConfigRequest { } message QueryFederationSyncConfigResponse { - GeneralFederationSyncConfig general_sync_config = 1; + GlobalFederationSyncConfig global_sync_config = 1; repeated AssetFederationSyncConfig asset_sync_configs = 2; } diff --git a/taprpc/universerpc/universe.swagger.json b/taprpc/universerpc/universe.swagger.json index 74fb3c13a..7f9f21010 100644 --- a/taprpc/universerpc/universe.swagger.json +++ b/taprpc/universerpc/universe.swagger.json @@ -1453,8 +1453,13 @@ "$ref": "#/definitions/universerpcID", "description": "The ID of the universe to configure." }, - "proof_types": { - "type": "string" + "allow_sync_insert": { + "type": "boolean", + "description": "This boolean is a flag which indicates whether leaves from the given\nuniverse have may be inserted via federation sync." + }, + "allow_sync_export": { + "type": "boolean", + "description": "This boolean is a flag which indicates whether leaves from the given\nuniverse have may be exported via federation sync." } }, "description": "AssetFederationSyncConfig is an asset universe specific configuration for\nfederation syncing." @@ -1642,14 +1647,23 @@ "universerpcDeleteRootResponse": { "type": "object" }, - "universerpcGeneralFederationSyncConfig": { + "universerpcGlobalFederationSyncConfig": { "type": "object", "properties": { - "proof_types": { - "type": "string" + "proof_type": { + "$ref": "#/definitions/universerpcProofType", + "description": "This field is the target universe proof type." + }, + "allow_sync_insert": { + "type": "boolean", + "description": "This boolean is a flag which indicates whether leaves from the given\nuniverse proof type have may be inserted via federation sync." + }, + "allow_sync_export": { + "type": "boolean", + "description": "This boolean is a flag which indicates whether leaves from the given\nuniverse proof type have may be exported via federation sync." } }, - "description": "GeneralFederationSyncConfig is a general configuration for universe\nfederation syncing." + "description": "GlobalFederationSyncConfig is a global configuration for universe federation\nsyncing." }, "universerpcGroupedUniverseEvents": { "type": "object", @@ -1772,8 +1786,8 @@ "universerpcQueryFederationSyncConfigResponse": { "type": "object", "properties": { - "general_sync_config": { - "$ref": "#/definitions/universerpcGeneralFederationSyncConfig" + "global_sync_config": { + "$ref": "#/definitions/universerpcGlobalFederationSyncConfig" }, "asset_sync_configs": { "type": "array", @@ -1795,8 +1809,8 @@ "universerpcSetFederationSyncConfigRequest": { "type": "object", "properties": { - "general_sync_config": { - "$ref": "#/definitions/universerpcGeneralFederationSyncConfig" + "global_sync_config": { + "$ref": "#/definitions/universerpcGlobalFederationSyncConfig" }, "asset_sync_config": { "type": "array", diff --git a/universe/interface.go b/universe/interface.go index 139c8be41..c535f5899 100644 --- a/universe/interface.go +++ b/universe/interface.go @@ -654,9 +654,13 @@ type FedUniSyncConfig struct { // UniverseID is the ID of the Universe that the config is for. UniverseID Identifier - // ProofTypes represents the proof types that should be synced for the - // target Universe. - ProofTypes ProofType + // AllowSyncInsert is a boolean that indicates whether leaves from the + // given universe have may be inserted via federation sync. + AllowSyncInsert bool + + // AllowSyncExport is a boolean that indicates whether leaves from the + // given universe have may be exported via federation sync. + AllowSyncExport bool } // FederationSyncConfigDB is used to manage the set of Universe servers as part