diff --git a/app/appmessage/message.go b/app/appmessage/message.go index 82504ad..f0f739b 100644 --- a/app/appmessage/message.go +++ b/app/appmessage/message.go @@ -167,6 +167,10 @@ const ( CmdGetFeeEstimateResponseMessage CmdSubmitTransactionReplacementRequestMessage CmdSubmitTransactionReplacementResponseMessage + CmdGetPruningWindowRootsRequestMessage + CmdGetPruningWindowRootsResponseMessage + CmdAddArchivalBlocksRequestMessage + CmdAddArchivalBlocksResponseMessage ) // ProtocolMessageCommandToString maps all MessageCommands to their string representation @@ -308,6 +312,10 @@ var RPCMessageCommandToString = map[MessageCommand]string{ CmdGetFeeEstimateResponseMessage: "GetFeeEstimateResponse", CmdSubmitTransactionReplacementRequestMessage: "SubmitTransactionReplacementRequest", CmdSubmitTransactionReplacementResponseMessage: "SubmitTransactionReplacementResponse", + CmdGetPruningWindowRootsRequestMessage: "GetPruningWindowRootsRequestMessage", + CmdGetPruningWindowRootsResponseMessage: "GetPruningWindowRootsResponseMessage", + CmdAddArchivalBlocksRequestMessage: "AddArchivalBlocksRequestMessage", + CmdAddArchivalBlocksResponseMessage: "AddArchivalBlocksResponseMessage", } // Message is an interface that describes a spectre message. A type that diff --git a/app/appmessage/rpc_add_archival_blocks.go b/app/appmessage/rpc_add_archival_blocks.go new file mode 100644 index 0000000..1e60b52 --- /dev/null +++ b/app/appmessage/rpc_add_archival_blocks.go @@ -0,0 +1,54 @@ +package appmessage + +type AcceptedTxEntry struct { + TransactionID string + IndexWithinBlock uint32 +} + +type MergesetBlockAcceptanceData struct { + BlockHash string + AcceptedTxs []*AcceptedTxEntry +} + +type ArchivalBlock struct { + Block *RPCBlock + Child string + AcceptanceData []*MergesetBlockAcceptanceData + SelectedParent string +} + +// AddArchivalBlocksRequestMessage represents a request to add archival blocks +type AddArchivalBlocksRequestMessage struct { + baseMessage + Blocks []*ArchivalBlock +} + +// Command returns the protocol command string for the message +func (msg *AddArchivalBlocksRequestMessage) Command() MessageCommand { + return CmdAddArchivalBlocksRequestMessage +} + +// NewAddArchivalBlocksRequestMessage returns a instance of the message +func NewAddArchivalBlocksRequestMessage(blocks []*ArchivalBlock) *AddArchivalBlocksRequestMessage { + return &AddArchivalBlocksRequestMessage{ + Blocks: blocks, + } +} + +// AddArchivalBlocksResponseMessage represents a response to the AddArchivalBlocks request +type AddArchivalBlocksResponseMessage struct { + baseMessage + Error *RPCError +} + +// Command returns the protocol command string for the message +func (msg *AddArchivalBlocksResponseMessage) Command() MessageCommand { + return CmdAddArchivalBlocksResponseMessage +} + +// NewAddArchivalBlocksResponseMessage returns a instance of the message +func NewAddArchivalBlocksResponseMessage(err *RPCError) *AddArchivalBlocksResponseMessage { + return &AddArchivalBlocksResponseMessage{ + Error: err, + } +} diff --git a/app/appmessage/rpc_get_pruning_window_roots.go b/app/appmessage/rpc_get_pruning_window_roots.go new file mode 100644 index 0000000..4722862 --- /dev/null +++ b/app/appmessage/rpc_get_pruning_window_roots.go @@ -0,0 +1,30 @@ +package appmessage + +// GetPruningWindowRootsRequestMessage is an appmessage corresponding to +// its respective RPC message +type GetPruningWindowRootsRequestMessage struct { + baseMessage +} + +// Command returns the protocol command string for the message +func (msg *GetPruningWindowRootsRequestMessage) Command() MessageCommand { + return CmdGetPruningWindowRootsRequestMessage +} + +type PruningWindowRoots struct { + PPRoots []string + PPIndex uint64 +} + +// GetPruningWindowRootsResponseMessage is an appmessage corresponding to +// its respective RPC message +type GetPruningWindowRootsResponseMessage struct { + baseMessage + Roots []*PruningWindowRoots + Error *RPCError +} + +// Command returns the protocol command string for the message +func (msg *GetPruningWindowRootsResponseMessage) Command() MessageCommand { + return CmdGetPruningWindowRootsResponseMessage +} diff --git a/cmd/archiveexport/config.go b/cmd/archiveexport/config.go new file mode 100644 index 0000000..fd9b732 --- /dev/null +++ b/cmd/archiveexport/config.go @@ -0,0 +1,76 @@ +package main + +import ( + "fmt" + "os" + "path/filepath" + "strconv" + "strings" + + "github.com/spectre-project/spectred/infrastructure/config" + + "github.com/pkg/errors" + "github.com/spectre-project/spectred/util" + + "github.com/jessevdk/go-flags" + "github.com/spectre-project/spectred/version" +) + +const ( + defaultLogFilename = "archiveexport.log" + defaultErrLogFilename = "archiveexport_err.log" +) + +var ( + // Default configuration options + defaultAppDir = util.AppDir("archiveexport", false) + defaultLogFile = filepath.Join(defaultAppDir, defaultLogFilename) + defaultErrLogFile = filepath.Join(defaultAppDir, defaultErrLogFilename) + defaultRPCServer = "localhost" + defaultDataDir = filepath.Join(config.DefaultAppDir) +) + +type configFlags struct { + ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"` + RPCServer string `short:"s" long:"rpcserver" description:"RPC server to connect to"` + Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"` + AppDir string `short:"b" long:"appdir" description:"Node datadir"` + config.NetworkFlags +} + +func parseConfig() (*configFlags, error) { + cfg := &configFlags{ + RPCServer: defaultRPCServer, + AppDir: defaultDataDir, + } + parser := flags.NewParser(cfg, flags.PrintErrors|flags.HelpFlag) + _, err := parser.Parse() + + // Show the version and exit if the version flag was specified. + if cfg.ShowVersion { + appName := filepath.Base(os.Args[0]) + appName = strings.TrimSuffix(appName, filepath.Ext(appName)) + fmt.Println(appName, "version", version.Version()) + os.Exit(0) + } + + if err != nil { + return nil, err + } + + err = cfg.ResolveNetwork(parser) + if err != nil { + return nil, err + } + + if cfg.Profile != "" { + profilePort, err := strconv.Atoi(cfg.Profile) + if err != nil || profilePort < 1024 || profilePort > 65535 { + return nil, errors.New("The profile port must be between 1024 and 65535") + } + } + + initLog(defaultLogFile, defaultErrLogFile) + + return cfg, nil +} diff --git a/cmd/archiveexport/log.go b/cmd/archiveexport/log.go new file mode 100644 index 0000000..fbaa571 --- /dev/null +++ b/cmd/archiveexport/log.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "github.com/spectre-project/spectred/infrastructure/logger" + "github.com/spectre-project/spectred/util/panics" + "os" +) + +var ( + backendLog = logger.NewBackend() + log = backendLog.Logger("ARCH") + spawn = panics.GoroutineWrapperFunc(log) +) + +func initLog(logFile, errLogFile string) { + log.SetLevel(logger.LevelDebug) + err := backendLog.AddLogFile(logFile, logger.LevelTrace) + if err != nil { + fmt.Fprintf(os.Stderr, "Error adding log file %s as log rotator for level %s: %s", logFile, logger.LevelTrace, err) + os.Exit(1) + } + err = backendLog.AddLogFile(errLogFile, logger.LevelWarn) + if err != nil { + fmt.Fprintf(os.Stderr, "Error adding log file %s as log rotator for level %s: %s", errLogFile, logger.LevelWarn, err) + os.Exit(1) + } + err = backendLog.AddLogWriter(os.Stdout, logger.LevelInfo) + if err != nil { + fmt.Fprintf(os.Stderr, "Error adding stdout to the loggerfor level %s: %s", logger.LevelWarn, err) + os.Exit(1) + } + err = backendLog.Run() + if err != nil { + fmt.Fprintf(os.Stderr, "Error starting the logger: %s ", err) + os.Exit(1) + } + +} diff --git a/cmd/archiveexport/main.go b/cmd/archiveexport/main.go new file mode 100644 index 0000000..f991f6a --- /dev/null +++ b/cmd/archiveexport/main.go @@ -0,0 +1,247 @@ +package main + +import ( + "fmt" + "os" + "path/filepath" + "time" + + "github.com/pkg/errors" + "github.com/spectre-project/spectred/app/appmessage" + "github.com/spectre-project/spectred/domain/consensus" + "github.com/spectre-project/spectred/domain/consensus/model" + "github.com/spectre-project/spectred/domain/consensus/model/externalapi" + "github.com/spectre-project/spectred/domain/consensus/utils/consensushashing" + "github.com/spectre-project/spectred/infrastructure/config" + "github.com/spectre-project/spectred/infrastructure/db/database" + "github.com/spectre-project/spectred/infrastructure/network/rpcclient" + "github.com/spectre-project/spectred/util/profiling" + "github.com/spectre-project/spectred/version" +) + +func main() { + // defer panics.HandlePanic(log, "MAIN", nil) + + cfg, err := parseConfig() + if err != nil { + printErrorAndExit(errors.Errorf("Error parsing command-line arguments: %s", err)) + } + defer backendLog.Close() + + // Show version at startup. + log.Infof("Version %s", version.Version()) + + // Enable http profiling server if requested. + if cfg.Profile != "" { + profiling.Start(cfg.Profile, log) + } + + err = mainImpl(cfg) + if err != nil { + printErrorAndExit(err) + } +} + +func mainImpl(cfg *configFlags) error { + appDir := config.CleanAndExpandPath(cfg.AppDir) + appDir = filepath.Join(appDir, cfg.NetParams().Name) + dataDir := filepath.Join(appDir, "datadir2") + + consensusConfig := &consensus.Config{Params: *cfg.NetParams()} + factory := consensus.NewFactory() + factory.SetTestDataDir(dataDir) + factory.AutoSetActivePrefix(true) + tc, tearDownFunc, err := factory.NewTestConsensus(consensusConfig, "archiveexport") + if err != nil { + return err + } + defer tearDownFunc(true) + + rpcAddress, err := cfg.NetParams().NormalizeRPCServerAddress(cfg.RPCServer) + if err != nil { + return err + } + rpcClient, err := rpcclient.NewRPCClient(rpcAddress) + if err != nil { + return err + } + + rootsResp, err := rpcClient.GetPruningWindowRoots() + if err != nil { + return err + } + + ppHeaders, err := tc.PruningPointHeaders() + if err != nil { + return err + } + + for _, root := range rootsResp.Roots { + log.Infof("Got root %s", root.PPRoots) + } + + counterStart := time.Now() + counter := 0 + for _, root := range rootsResp.Roots { + ppRoots, err := externalapi.NewDomainHashesFromStrings(root.PPRoots) + if err != nil { + return err + } + + log.Infof("Adding past of %s", ppRoots) + + if err != nil { + return err + } + + if int(root.PPIndex-1) >= len(ppHeaders) { + continue + } + + nextPP := ppHeaders[root.PPIndex-1] + + blockToChild := make(map[externalapi.DomainHash]externalapi.DomainHash) + + // TODO: Since GD data is not always available, we should extract the blue work from the header and use that for topological traversal + heap := tc.DAGTraversalManager().NewDownHeap(model.NewStagingArea()) + for _, ppRoot := range ppRoots { + heap.Push(ppRoot) + } + + visited := make(map[externalapi.DomainHash]struct{}) + chunk := make([]*appmessage.ArchivalBlock, 0, 1000) + for heap.Len() > 0 { + hash := heap.Pop() + + if _, ok := visited[*hash]; ok { + continue + } + visited[*hash] = struct{}{} + + // TODO: Use header data instead of GD data + blockGHOSTDAGData, err := tc.GHOSTDAGDataStore().Get(tc.DatabaseContext(), model.NewStagingArea(), hash, false) + if err != nil { + return err + } + + if blockGHOSTDAGData.BlueWork().Cmp(nextPP.BlueWork()) <= 0 { + break + } + + block, err := tc.BlockStore().Block(tc.DatabaseContext(), model.NewStagingArea(), hash) + if database.IsNotFoundError(err) { + continue + } + + if err != nil { + return err + } + + archivalBlock := &appmessage.ArchivalBlock{ + Block: appmessage.DomainBlockToRPCBlock(block), + } + if child, ok := blockToChild[*hash]; ok { + archivalBlock.Child = child.String() + } + + acceptanceData, err := tc.AcceptanceDataStore().Get(tc.DatabaseContext(), model.NewStagingArea(), hash) + isNotFoundErr := database.IsNotFoundError(err) + if !isNotFoundErr && err != nil { + return err + } + + if blockGHOSTDAGData.SelectedParent() != model.VirtualGenesisBlockHash && !isNotFoundErr && len(acceptanceData) > 0 { + acceptanceDataRPC := make([]*appmessage.MergesetBlockAcceptanceData, 0, len(acceptanceData)) + for _, data := range acceptanceData { + acceptedTxs := make([]*appmessage.AcceptedTxEntry, 0, len(data.TransactionAcceptanceData)) + for i, tx := range data.TransactionAcceptanceData { + if !tx.IsAccepted { + continue + } + + acceptedTxs = append(acceptedTxs, &appmessage.AcceptedTxEntry{ + TransactionID: consensushashing.TransactionID(tx.Transaction).String(), + IndexWithinBlock: uint32(i), + }) + } + + acceptanceDataRPC = append(acceptanceDataRPC, &appmessage.MergesetBlockAcceptanceData{ + BlockHash: data.BlockHash.String(), + AcceptedTxs: acceptedTxs, + }) + } + + archivalBlock.AcceptanceData = acceptanceDataRPC + archivalBlock.SelectedParent = blockGHOSTDAGData.SelectedParent().String() + } + + chunk = append(chunk, archivalBlock) + + if len(chunk) == 1 { + log.Infof("Added %s to chunk", consensushashing.BlockHash(block)) + } + + if len(chunk) == cap(chunk) { + err := sendChunk(rpcClient, chunk) + if err != nil { + return err + } + counter += len(chunk) + counterDuration := time.Since(counterStart) + if counterDuration > 10*time.Second { + rate := float64(counter) / counterDuration.Seconds() + log.Infof("Sent %d blocks in the last %.2f seconds (%.2f blocks/second)", counter, counterDuration.Seconds(), rate) + counterStart = time.Now() + counter = 0 + } + + chunk = chunk[:0] + } + + for _, parent := range block.Header.DirectParents() { + heap.Push(parent) + blockToChild[*parent] = *hash + } + } + + if len(chunk) > 0 { + sendChunk(rpcClient, chunk) + } + } + + return nil +} + +func sendChunk(rpcClient *rpcclient.RPCClient, chunk []*appmessage.ArchivalBlock) error { + log.Infof("Sending chunk") + _, err := rpcClient.AddArchivalBlocks(chunk) + if err != nil { + return err + } + log.Infof("Sent chunk") + + // Checking existence of first block for sanity + block := chunk[0] + domainBlock, err := appmessage.RPCBlockToDomainBlock(block.Block) + if err != nil { + return err + } + + blockHash := consensushashing.BlockHash(domainBlock) + log.Infof("Checking block %s", blockHash) + resp, err := rpcClient.GetBlock(blockHash.String(), true) + if err != nil { + return err + } + + if len(resp.Block.Transactions) == 0 { + return errors.Errorf("Block %s has no transactions on the server", blockHash) + } + + return nil +} + +func printErrorAndExit(err error) { + fmt.Fprintf(os.Stderr, "%+v\n", err) + os.Exit(1) +} diff --git a/cmd/spectrectl/commands.go b/cmd/spectrectl/commands.go index 7758d69..6e1634e 100644 --- a/cmd/spectrectl/commands.go +++ b/cmd/spectrectl/commands.go @@ -41,6 +41,9 @@ var commandTypes = []reflect.Type{ reflect.TypeOf(protowire.SpectredMessage_BanRequest{}), reflect.TypeOf(protowire.SpectredMessage_UnbanRequest{}), + + reflect.TypeOf(protowire.SpectredMessage_GetPruningWindowRootsRequest{}), + reflect.TypeOf(protowire.SpectredMessage_AddArchivalBlocksRequest{}), } type commandDescription struct { diff --git a/domain/consensus/factory.go b/domain/consensus/factory.go index 9e34367..2f6b466 100644 --- a/domain/consensus/factory.go +++ b/domain/consensus/factory.go @@ -13,6 +13,7 @@ import ( "github.com/spectre-project/spectred/domain/consensus/processes/blockparentbuilder" parentssanager "github.com/spectre-project/spectred/domain/consensus/processes/parentsmanager" "github.com/spectre-project/spectred/domain/consensus/processes/pruningproofmanager" + "github.com/spectre-project/spectred/domain/prefixmanager" "github.com/spectre-project/spectred/util/staging" "github.com/spectre-project/spectred/domain/prefixmanager/prefix" @@ -89,6 +90,8 @@ type Factory interface { SetTestPreAllocateCache(preallocateCaches bool) SetTestPastMedianTimeManager(medianTimeConstructor PastMedianTimeManagerConstructor) SetTestDifficultyManager(difficultyConstructor DifficultyManagerConstructor) + + AutoSetActivePrefix(value bool) } type factory struct { @@ -98,6 +101,7 @@ type factory struct { difficultyConstructor DifficultyManagerConstructor cacheSizeMiB *int preallocateCaches *bool + autoCheckActivePrefix bool } // NewFactory creates a new Consensus factory @@ -106,6 +110,7 @@ func NewFactory() Factory { ghostdagConstructor: ghostdagmanager.New, pastMedianTimeConsructor: pastmediantimemanager.New, difficultyConstructor: difficultymanager.New, + autoCheckActivePrefix: false, } } @@ -588,8 +593,19 @@ func (f *factory) NewTestConsensus(config *Config, testName string) ( return nil, nil, err } - testConsensusDBPrefix := &prefix.Prefix{} - consensusAsInterface, shouldMigrate, err := f.NewConsensus(config, db, testConsensusDBPrefix, nil) + prefix := &prefix.Prefix{} + if f.autoCheckActivePrefix { + activePrefix, exists, err := prefixmanager.ActivePrefix(db) + if err != nil { + return nil, nil, err + } + + if exists { + prefix = activePrefix + } + } + + consensusAsInterface, shouldMigrate, err := f.NewConsensus(config, db, prefix, nil) if err != nil { return nil, nil, err } @@ -648,6 +664,11 @@ func (f *factory) SetTestPreAllocateCache(preallocateCaches bool) { f.preallocateCaches = &preallocateCaches } +// AutoSetActivePrefix implements Factory. +func (f *factory) AutoSetActivePrefix(value bool) { + f.autoCheckActivePrefix = value +} + func dagStores(config *Config, prefixBucket model.DBBucket, pruningWindowSizePlusFinalityDepthForCache, pruningWindowSizeForCaches int, diff --git a/domain/consensus/model/externalapi/hash.go b/domain/consensus/model/externalapi/hash.go index 1ea8a90..2261c0a 100644 --- a/domain/consensus/model/externalapi/hash.go +++ b/domain/consensus/model/externalapi/hash.go @@ -59,6 +59,18 @@ func NewDomainHashFromString(hashString string) (*DomainHash, error) { return NewDomainHashFromByteSlice(hashBytes) } +func NewDomainHashesFromStrings(hashStrings []string) ([]*DomainHash, error) { + hashes := make([]*DomainHash, len(hashStrings)) + for i, hashString := range hashStrings { + hash, err := NewDomainHashFromString(hashString) + if err != nil { + return nil, err + } + hashes[i] = hash + } + return hashes, nil +} + // String returns the Hash as the hexadecimal string of the hash. func (hash DomainHash) String() string { return hex.EncodeToString(hash.hashArray[:]) diff --git a/infrastructure/config/config.go b/infrastructure/config/config.go index 830663f..efccd1d 100644 --- a/infrastructure/config/config.go +++ b/infrastructure/config/config.go @@ -149,9 +149,9 @@ type ServiceOptions struct { ServiceCommand string `short:"s" long:"service" description:"Service command {install, remove, start, stop}"` } -// cleanAndExpandPath expands environment variables and leading ~ in the +// CleanAndExpandPath expands environment variables and leading ~ in the // passed path, cleans the result, and returns it. -func cleanAndExpandPath(path string) string { +func CleanAndExpandPath(path string) string { // Expand initial ~ to OS specific home directory. if strings.HasPrefix(path, "~") { homeDir := filepath.Dir(DefaultAppDir) @@ -320,7 +320,7 @@ func LoadConfig() (*Config, error) { } cfg.RelayNonStd = relayNonStd - cfg.AppDir = cleanAndExpandPath(cfg.AppDir) + cfg.AppDir = CleanAndExpandPath(cfg.AppDir) // Append the network type to the app directory so it is "namespaced" // per network. // All data is specific to a network, so namespacing the data directory @@ -332,7 +332,7 @@ func LoadConfig() (*Config, error) { if cfg.LogDir == "" { cfg.LogDir = filepath.Join(cfg.AppDir, defaultLogDirname) } - cfg.LogDir = cleanAndExpandPath(cfg.LogDir) + cfg.LogDir = CleanAndExpandPath(cfg.LogDir) // Special show command to list supported subsystems and exit. if cfg.LogLevel == "show" { diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/messages.pb.go b/infrastructure/network/netadapter/server/grpcserver/protowire/messages.pb.go index f416d35..f56c1dd 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/messages.pb.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/messages.pb.go @@ -179,6 +179,10 @@ type SpectredMessage struct { // *SpectredMessage_GetFeeEstimateResponse // *SpectredMessage_GetFeeEstimateExperimentalResponse // *SpectredMessage_GetCurrentBlockColorResponse + // *SpectredMessage_GetPruningWindowRootsRequest + // *SpectredMessage_GetPruningWindowRootsResponse + // *SpectredMessage_AddArchivalBlocksRequest + // *SpectredMessage_AddArchivalBlocksResponse Payload isSpectredMessage_Payload `protobuf_oneof:"payload"` } @@ -1285,6 +1289,34 @@ func (x *SpectredMessage) GetGetCurrentBlockColorResponse() *GetCurrentBlockColo return nil } +func (x *SpectredMessage) GetGetPruningWindowRootsRequest() *GetPruningWindowRootsRequestMessage { + if x, ok := x.GetPayload().(*SpectredMessage_GetPruningWindowRootsRequest); ok { + return x.GetPruningWindowRootsRequest + } + return nil +} + +func (x *SpectredMessage) GetGetPruningWindowRootsResponse() *GetPruningWindowRootsResponseMessage { + if x, ok := x.GetPayload().(*SpectredMessage_GetPruningWindowRootsResponse); ok { + return x.GetPruningWindowRootsResponse + } + return nil +} + +func (x *SpectredMessage) GetAddArchivalBlocksRequest() *AddArchivalBlocksRequestMessage { + if x, ok := x.GetPayload().(*SpectredMessage_AddArchivalBlocksRequest); ok { + return x.AddArchivalBlocksRequest + } + return nil +} + +func (x *SpectredMessage) GetAddArchivalBlocksResponse() *AddArchivalBlocksResponseMessage { + if x, ok := x.GetPayload().(*SpectredMessage_AddArchivalBlocksResponse); ok { + return x.AddArchivalBlocksResponse + } + return nil +} + type isSpectredMessage_Payload interface { isSpectredMessage_Payload() } @@ -1897,6 +1929,22 @@ type SpectredMessage_GetCurrentBlockColorResponse struct { GetCurrentBlockColorResponse *GetCurrentBlockColorResponseMessage `protobuf:"bytes,1111,opt,name=getCurrentBlockColorResponse,proto3,oneof"` } +type SpectredMessage_GetPruningWindowRootsRequest struct { + GetPruningWindowRootsRequest *GetPruningWindowRootsRequestMessage `protobuf:"bytes,1113,opt,name=getPruningWindowRootsRequest,proto3,oneof"` +} + +type SpectredMessage_GetPruningWindowRootsResponse struct { + GetPruningWindowRootsResponse *GetPruningWindowRootsResponseMessage `protobuf:"bytes,1114,opt,name=getPruningWindowRootsResponse,proto3,oneof"` +} + +type SpectredMessage_AddArchivalBlocksRequest struct { + AddArchivalBlocksRequest *AddArchivalBlocksRequestMessage `protobuf:"bytes,1115,opt,name=addArchivalBlocksRequest,proto3,oneof"` +} + +type SpectredMessage_AddArchivalBlocksResponse struct { + AddArchivalBlocksResponse *AddArchivalBlocksResponseMessage `protobuf:"bytes,1116,opt,name=addArchivalBlocksResponse,proto3,oneof"` +} + func (*SpectredMessage_Addresses) isSpectredMessage_Payload() {} func (*SpectredMessage_Block) isSpectredMessage_Payload() {} @@ -2205,13 +2253,21 @@ func (*SpectredMessage_GetFeeEstimateExperimentalResponse) isSpectredMessage_Pay func (*SpectredMessage_GetCurrentBlockColorResponse) isSpectredMessage_Payload() {} +func (*SpectredMessage_GetPruningWindowRootsRequest) isSpectredMessage_Payload() {} + +func (*SpectredMessage_GetPruningWindowRootsResponse) isSpectredMessage_Payload() {} + +func (*SpectredMessage_AddArchivalBlocksRequest) isSpectredMessage_Payload() {} + +func (*SpectredMessage_AddArchivalBlocksResponse) isSpectredMessage_Payload() {} + var File_messages_proto protoreflect.FileDescriptor var file_messages_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x1a, 0x09, 0x70, 0x32, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x09, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x82, 0x80, 0x01, 0x0a, 0x0f, 0x53, 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x64, 0x4d, + 0x6f, 0x22, 0xcc, 0x83, 0x01, 0x0a, 0x0f, 0x53, 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3b, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x4d, @@ -3234,22 +3290,51 @@ var file_messages_proto_rawDesc = []byte{ 0x65, 0x6e, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x1c, 0x67, 0x65, 0x74, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x43, - 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x09, 0x0a, 0x07, - 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x32, 0x54, 0x0a, 0x03, 0x50, 0x32, 0x50, 0x12, 0x4d, + 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x75, 0x0a, 0x1c, + 0x67, 0x65, 0x74, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, + 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0xd9, 0x08, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, + 0x47, 0x65, 0x74, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, + 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x1c, 0x67, 0x65, 0x74, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, + 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x78, 0x0a, 0x1d, 0x67, 0x65, 0x74, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, + 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x18, 0xda, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x75, 0x6e, 0x69, + 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x1d, + 0x67, 0x65, 0x74, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, + 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x69, 0x0a, + 0x18, 0x61, 0x64, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0xdb, 0x08, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x41, 0x64, 0x64, + 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x18, + 0x61, 0x64, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x6c, 0x0a, 0x19, 0x61, 0x64, 0x64, 0x41, + 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0xdc, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x41, 0x72, 0x63, 0x68, + 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x19, 0x61, 0x64, 0x64, + 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x32, 0x54, 0x0a, 0x03, 0x50, 0x32, 0x50, 0x12, 0x4d, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x53, 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x64, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, + 0x65, 0x2e, 0x53, 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x54, 0x0a, 0x03, 0x52, 0x50, 0x43, 0x12, 0x4d, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x53, 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x53, 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x64, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x54, 0x0a, - 0x03, 0x52, 0x50, 0x43, 0x12, 0x4d, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, - 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, - 0x65, 0x2e, 0x53, 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x53, 0x70, - 0x65, 0x63, 0x74, 0x72, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, - 0x01, 0x30, 0x01, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, - 0x74, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x2f, 0x5a, + 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x70, 0x65, 0x63, + 0x74, 0x72, 0x65, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x73, 0x70, 0x65, 0x63, + 0x74, 0x72, 0x65, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -3418,6 +3503,10 @@ var file_messages_proto_goTypes = []any{ (*GetFeeEstimateResponseMessage)(nil), // 149: protowire.GetFeeEstimateResponseMessage (*GetFeeEstimateExperimentalResponseMessage)(nil), // 150: protowire.GetFeeEstimateExperimentalResponseMessage (*GetCurrentBlockColorResponseMessage)(nil), // 151: protowire.GetCurrentBlockColorResponseMessage + (*GetPruningWindowRootsRequestMessage)(nil), // 152: protowire.GetPruningWindowRootsRequestMessage + (*GetPruningWindowRootsResponseMessage)(nil), // 153: protowire.GetPruningWindowRootsResponseMessage + (*AddArchivalBlocksRequestMessage)(nil), // 154: protowire.AddArchivalBlocksRequestMessage + (*AddArchivalBlocksResponseMessage)(nil), // 155: protowire.AddArchivalBlocksResponseMessage } var file_messages_proto_depIdxs = []int32{ 1, // 0: protowire.SpectredMessage.addresses:type_name -> protowire.AddressesMessage @@ -3572,15 +3661,19 @@ var file_messages_proto_depIdxs = []int32{ 149, // 149: protowire.SpectredMessage.getFeeEstimateResponse:type_name -> protowire.GetFeeEstimateResponseMessage 150, // 150: protowire.SpectredMessage.getFeeEstimateExperimentalResponse:type_name -> protowire.GetFeeEstimateExperimentalResponseMessage 151, // 151: protowire.SpectredMessage.getCurrentBlockColorResponse:type_name -> protowire.GetCurrentBlockColorResponseMessage - 0, // 152: protowire.P2P.MessageStream:input_type -> protowire.SpectredMessage - 0, // 153: protowire.RPC.MessageStream:input_type -> protowire.SpectredMessage - 0, // 154: protowire.P2P.MessageStream:output_type -> protowire.SpectredMessage - 0, // 155: protowire.RPC.MessageStream:output_type -> protowire.SpectredMessage - 154, // [154:156] is the sub-list for method output_type - 152, // [152:154] is the sub-list for method input_type - 152, // [152:152] is the sub-list for extension type_name - 152, // [152:152] is the sub-list for extension extendee - 0, // [0:152] is the sub-list for field type_name + 152, // 152: protowire.SpectredMessage.getPruningWindowRootsRequest:type_name -> protowire.GetPruningWindowRootsRequestMessage + 153, // 153: protowire.SpectredMessage.getPruningWindowRootsResponse:type_name -> protowire.GetPruningWindowRootsResponseMessage + 154, // 154: protowire.SpectredMessage.addArchivalBlocksRequest:type_name -> protowire.AddArchivalBlocksRequestMessage + 155, // 155: protowire.SpectredMessage.addArchivalBlocksResponse:type_name -> protowire.AddArchivalBlocksResponseMessage + 0, // 156: protowire.P2P.MessageStream:input_type -> protowire.SpectredMessage + 0, // 157: protowire.RPC.MessageStream:input_type -> protowire.SpectredMessage + 0, // 158: protowire.P2P.MessageStream:output_type -> protowire.SpectredMessage + 0, // 159: protowire.RPC.MessageStream:output_type -> protowire.SpectredMessage + 158, // [158:160] is the sub-list for method output_type + 156, // [156:158] is the sub-list for method input_type + 156, // [156:156] is the sub-list for extension type_name + 156, // [156:156] is the sub-list for extension extendee + 0, // [0:156] is the sub-list for field type_name } func init() { file_messages_proto_init() } @@ -3757,6 +3850,10 @@ func file_messages_proto_init() { (*SpectredMessage_GetFeeEstimateResponse)(nil), (*SpectredMessage_GetFeeEstimateExperimentalResponse)(nil), (*SpectredMessage_GetCurrentBlockColorResponse)(nil), + (*SpectredMessage_GetPruningWindowRootsRequest)(nil), + (*SpectredMessage_GetPruningWindowRootsResponse)(nil), + (*SpectredMessage_AddArchivalBlocksRequest)(nil), + (*SpectredMessage_AddArchivalBlocksResponse)(nil), } type x struct{} out := protoimpl.TypeBuilder{ diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/messages.proto b/infrastructure/network/netadapter/server/grpcserver/protowire/messages.proto index 1ea84b1..7b83e80 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/messages.proto +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/messages.proto @@ -29,12 +29,15 @@ message SpectredMessage { UnexpectedPruningPointMessage unexpectedPruningPoint = 27; IbdBlockLocatorMessage ibdBlockLocator = 30; IbdBlockLocatorHighestHashMessage ibdBlockLocatorHighestHash = 31; - RequestNextPruningPointUtxoSetChunkMessage requestNextPruningPointUtxoSetChunk = 33; + RequestNextPruningPointUtxoSetChunkMessage + requestNextPruningPointUtxoSetChunk = 33; DonePruningPointUtxoSetChunksMessage donePruningPointUtxoSetChunks = 34; - IbdBlockLocatorHighestHashNotFoundMessage ibdBlockLocatorHighestHashNotFound = 35; + IbdBlockLocatorHighestHashNotFoundMessage + ibdBlockLocatorHighestHashNotFound = 35; BlockWithTrustedDataMessage blockWithTrustedData = 36; DoneBlocksWithTrustedDataMessage doneBlocksWithTrustedData = 37; - RequestPruningPointAndItsAnticoneMessage requestPruningPointAndItsAnticone = 40; + RequestPruningPointAndItsAnticoneMessage requestPruningPointAndItsAnticone = + 40; BlockHeadersMessage blockHeaders = 41; RequestNextHeadersMessage requestNextHeaders = 42; DoneHeadersMessage DoneHeaders = 43; @@ -50,7 +53,8 @@ message SpectredMessage { RequestIBDChainBlockLocatorMessage requestIBDChainBlockLocator = 53; IbdChainBlockLocatorMessage ibdChainBlockLocator = 54; RequestAnticoneMessage requestAnticone = 55; - RequestNextPruningPointAndItsAnticoneBlocksMessage requestNextPruningPointAndItsAnticoneBlocks = 56; + RequestNextPruningPointAndItsAnticoneBlocksMessage + requestNextPruningPointAndItsAnticoneBlocks = 56; GetCurrentNetworkRequestMessage getCurrentNetworkRequest = 1001; GetCurrentNetworkResponseMessage getCurrentNetworkResponse = 1002; @@ -73,15 +77,20 @@ message SpectredMessage { AddPeerResponseMessage addPeerResponse = 1019; SubmitTransactionRequestMessage submitTransactionRequest = 1020; SubmitTransactionResponseMessage submitTransactionResponse = 1021; - NotifyVirtualSelectedParentChainChangedRequestMessage notifyVirtualSelectedParentChainChangedRequest = 1022; - NotifyVirtualSelectedParentChainChangedResponseMessage notifyVirtualSelectedParentChainChangedResponse = 1023; - VirtualSelectedParentChainChangedNotificationMessage virtualSelectedParentChainChangedNotification = 1024; + NotifyVirtualSelectedParentChainChangedRequestMessage + notifyVirtualSelectedParentChainChangedRequest = 1022; + NotifyVirtualSelectedParentChainChangedResponseMessage + notifyVirtualSelectedParentChainChangedResponse = 1023; + VirtualSelectedParentChainChangedNotificationMessage + virtualSelectedParentChainChangedNotification = 1024; GetBlockRequestMessage getBlockRequest = 1025; GetBlockResponseMessage getBlockResponse = 1026; GetSubnetworkRequestMessage getSubnetworkRequest = 1027; GetSubnetworkResponseMessage getSubnetworkResponse = 1028; - GetVirtualSelectedParentChainFromBlockRequestMessage getVirtualSelectedParentChainFromBlockRequest = 1029; - GetVirtualSelectedParentChainFromBlockResponseMessage getVirtualSelectedParentChainFromBlockResponse = 1030; + GetVirtualSelectedParentChainFromBlockRequestMessage + getVirtualSelectedParentChainFromBlockRequest = 1029; + GetVirtualSelectedParentChainFromBlockResponseMessage + getVirtualSelectedParentChainFromBlockResponse = 1030; GetBlocksRequestMessage getBlocksRequest = 1031; GetBlocksResponseMessage getBlocksResponse = 1032; GetBlockCountRequestMessage getBlockCountRequest = 1033; @@ -89,11 +98,14 @@ message SpectredMessage { GetBlockDagInfoRequestMessage getBlockDagInfoRequest = 1035; GetBlockDagInfoResponseMessage getBlockDagInfoResponse = 1036; ResolveFinalityConflictRequestMessage resolveFinalityConflictRequest = 1037; - ResolveFinalityConflictResponseMessage resolveFinalityConflictResponse = 1038; + ResolveFinalityConflictResponseMessage resolveFinalityConflictResponse = + 1038; NotifyFinalityConflictsRequestMessage notifyFinalityConflictsRequest = 1039; - NotifyFinalityConflictsResponseMessage notifyFinalityConflictsResponse = 1040; + NotifyFinalityConflictsResponseMessage notifyFinalityConflictsResponse = + 1040; FinalityConflictNotificationMessage finalityConflictNotification = 1041; - FinalityConflictResolvedNotificationMessage finalityConflictResolvedNotification = 1042; + FinalityConflictResolvedNotificationMessage + finalityConflictResolvedNotification = 1042; GetMempoolEntriesRequestMessage getMempoolEntriesRequest = 1043; GetMempoolEntriesResponseMessage getMempoolEntriesResponse = 1044; ShutDownRequestMessage shutDownRequest = 1045; @@ -105,29 +117,46 @@ message SpectredMessage { UtxosChangedNotificationMessage utxosChangedNotification = 1051; GetUtxosByAddressesRequestMessage getUtxosByAddressesRequest = 1052; GetUtxosByAddressesResponseMessage getUtxosByAddressesResponse = 1053; - GetVirtualSelectedParentBlueScoreRequestMessage getVirtualSelectedParentBlueScoreRequest = 1054; - GetVirtualSelectedParentBlueScoreResponseMessage getVirtualSelectedParentBlueScoreResponse = 1055; - NotifyVirtualSelectedParentBlueScoreChangedRequestMessage notifyVirtualSelectedParentBlueScoreChangedRequest = 1056; - NotifyVirtualSelectedParentBlueScoreChangedResponseMessage notifyVirtualSelectedParentBlueScoreChangedResponse = 1057; - VirtualSelectedParentBlueScoreChangedNotificationMessage virtualSelectedParentBlueScoreChangedNotification = 1058; + GetVirtualSelectedParentBlueScoreRequestMessage + getVirtualSelectedParentBlueScoreRequest = 1054; + GetVirtualSelectedParentBlueScoreResponseMessage + getVirtualSelectedParentBlueScoreResponse = 1055; + NotifyVirtualSelectedParentBlueScoreChangedRequestMessage + notifyVirtualSelectedParentBlueScoreChangedRequest = 1056; + NotifyVirtualSelectedParentBlueScoreChangedResponseMessage + notifyVirtualSelectedParentBlueScoreChangedResponse = 1057; + VirtualSelectedParentBlueScoreChangedNotificationMessage + virtualSelectedParentBlueScoreChangedNotification = 1058; BanRequestMessage banRequest = 1059; BanResponseMessage banResponse = 1060; UnbanRequestMessage unbanRequest = 1061; UnbanResponseMessage unbanResponse = 1062; GetInfoRequestMessage getInfoRequest = 1063; GetInfoResponseMessage getInfoResponse = 1064; - StopNotifyingUtxosChangedRequestMessage stopNotifyingUtxosChangedRequest = 1065; - StopNotifyingUtxosChangedResponseMessage stopNotifyingUtxosChangedResponse = 1066; - NotifyPruningPointUTXOSetOverrideRequestMessage notifyPruningPointUTXOSetOverrideRequest = 1067; - NotifyPruningPointUTXOSetOverrideResponseMessage notifyPruningPointUTXOSetOverrideResponse = 1068; - PruningPointUTXOSetOverrideNotificationMessage pruningPointUTXOSetOverrideNotification = 1069; - StopNotifyingPruningPointUTXOSetOverrideRequestMessage stopNotifyingPruningPointUTXOSetOverrideRequest = 1070; - StopNotifyingPruningPointUTXOSetOverrideResponseMessage stopNotifyingPruningPointUTXOSetOverrideResponse = 1071; - EstimateNetworkHashesPerSecondRequestMessage estimateNetworkHashesPerSecondRequest = 1072; - EstimateNetworkHashesPerSecondResponseMessage estimateNetworkHashesPerSecondResponse = 1073; - NotifyVirtualDaaScoreChangedRequestMessage notifyVirtualDaaScoreChangedRequest = 1074; - NotifyVirtualDaaScoreChangedResponseMessage notifyVirtualDaaScoreChangedResponse = 1075; - VirtualDaaScoreChangedNotificationMessage virtualDaaScoreChangedNotification = 1076; + StopNotifyingUtxosChangedRequestMessage stopNotifyingUtxosChangedRequest = + 1065; + StopNotifyingUtxosChangedResponseMessage stopNotifyingUtxosChangedResponse = + 1066; + NotifyPruningPointUTXOSetOverrideRequestMessage + notifyPruningPointUTXOSetOverrideRequest = 1067; + NotifyPruningPointUTXOSetOverrideResponseMessage + notifyPruningPointUTXOSetOverrideResponse = 1068; + PruningPointUTXOSetOverrideNotificationMessage + pruningPointUTXOSetOverrideNotification = 1069; + StopNotifyingPruningPointUTXOSetOverrideRequestMessage + stopNotifyingPruningPointUTXOSetOverrideRequest = 1070; + StopNotifyingPruningPointUTXOSetOverrideResponseMessage + stopNotifyingPruningPointUTXOSetOverrideResponse = 1071; + EstimateNetworkHashesPerSecondRequestMessage + estimateNetworkHashesPerSecondRequest = 1072; + EstimateNetworkHashesPerSecondResponseMessage + estimateNetworkHashesPerSecondResponse = 1073; + NotifyVirtualDaaScoreChangedRequestMessage + notifyVirtualDaaScoreChangedRequest = 1074; + NotifyVirtualDaaScoreChangedResponseMessage + notifyVirtualDaaScoreChangedResponse = 1075; + VirtualDaaScoreChangedNotificationMessage + virtualDaaScoreChangedNotification = 1076; GetBalanceByAddressRequestMessage getBalanceByAddressRequest = 1077; GetBalanceByAddressResponseMessage getBalanceByAddressResponse = 1078; GetBalancesByAddressesRequestMessage getBalancesByAddressesRequest = 1079; @@ -135,39 +164,51 @@ message SpectredMessage { NotifyNewBlockTemplateRequestMessage notifyNewBlockTemplateRequest = 1081; NotifyNewBlockTemplateResponseMessage notifyNewBlockTemplateResponse = 1082; NewBlockTemplateNotificationMessage newBlockTemplateNotification = 1083; - GetMempoolEntriesByAddressesRequestMessage getMempoolEntriesByAddressesRequest = 1084; - GetMempoolEntriesByAddressesResponseMessage getMempoolEntriesByAddressesResponse = 1085; + GetMempoolEntriesByAddressesRequestMessage + getMempoolEntriesByAddressesRequest = 1084; + GetMempoolEntriesByAddressesResponseMessage + getMempoolEntriesByAddressesResponse = 1085; GetCoinSupplyRequestMessage getCoinSupplyRequest = 1086; - GetCoinSupplyResponseMessage getCoinSupplyResponse= 1087; + GetCoinSupplyResponseMessage getCoinSupplyResponse = 1087; PingRequestMessage pingRequest = 1088; GetMetricsRequestMessage getMetricsRequest = 1090; GetServerInfoRequestMessage getServerInfoRequest = 1092; GetSyncStatusRequestMessage getSyncStatusRequest = 1094; - GetDaaScoreTimestampEstimateRequestMessage getDaaScoreTimestampEstimateRequest = 1096; - SubmitTransactionReplacementRequestMessage submitTransactionReplacementRequest = 1100; + GetDaaScoreTimestampEstimateRequestMessage + getDaaScoreTimestampEstimateRequest = 1096; + SubmitTransactionReplacementRequestMessage + submitTransactionReplacementRequest = 1100; GetConnectionsRequestMessage getConnectionsRequest = 1102; GetSystemInfoRequestMessage getSystemInfoRequest = 1104; GetFeeEstimateRequestMessage getFeeEstimateRequest = 1106; - GetFeeEstimateExperimentalRequestMessage getFeeEstimateExperimentalRequest = 1108; + GetFeeEstimateExperimentalRequestMessage getFeeEstimateExperimentalRequest = + 1108; GetCurrentBlockColorRequestMessage getCurrentBlockColorRequest = 1110; - PingResponseMessage pingResponse= 1089; - GetMetricsResponseMessage getMetricsResponse= 1091; + PingResponseMessage pingResponse = 1089; + GetMetricsResponseMessage getMetricsResponse = 1091; GetServerInfoResponseMessage getServerInfoResponse = 1093; GetSyncStatusResponseMessage getSyncStatusResponse = 1095; - GetDaaScoreTimestampEstimateResponseMessage getDaaScoreTimestampEstimateResponse = 1097; - SubmitTransactionReplacementResponseMessage submitTransactionReplacementResponse = 1101; - GetConnectionsResponseMessage getConnectionsResponse= 1103; - GetSystemInfoResponseMessage getSystemInfoResponse= 1105; + GetDaaScoreTimestampEstimateResponseMessage + getDaaScoreTimestampEstimateResponse = 1097; + SubmitTransactionReplacementResponseMessage + submitTransactionReplacementResponse = 1101; + GetConnectionsResponseMessage getConnectionsResponse = 1103; + GetSystemInfoResponseMessage getSystemInfoResponse = 1105; GetFeeEstimateResponseMessage getFeeEstimateResponse = 1107; - GetFeeEstimateExperimentalResponseMessage getFeeEstimateExperimentalResponse = 1109; + GetFeeEstimateExperimentalResponseMessage + getFeeEstimateExperimentalResponse = 1109; GetCurrentBlockColorResponseMessage getCurrentBlockColorResponse = 1111; + GetPruningWindowRootsRequestMessage getPruningWindowRootsRequest = 1113; + GetPruningWindowRootsResponseMessage getPruningWindowRootsResponse = 1114; + AddArchivalBlocksRequestMessage addArchivalBlocksRequest = 1115; + AddArchivalBlocksResponseMessage addArchivalBlocksResponse = 1116; } } service P2P { - rpc MessageStream (stream SpectredMessage) returns (stream SpectredMessage) {} + rpc MessageStream(stream SpectredMessage) returns (stream SpectredMessage) {} } service RPC { - rpc MessageStream (stream SpectredMessage) returns (stream SpectredMessage) {} + rpc MessageStream(stream SpectredMessage) returns (stream SpectredMessage) {} } diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go index 965583f..8ea8957 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.pb.go @@ -8203,6 +8203,429 @@ func (x *SubmitTransactionReplacementResponseMessage) GetError() *RPCError { return nil } +type GetPruningWindowRootsRequestMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GetPruningWindowRootsRequestMessage) Reset() { + *x = GetPruningWindowRootsRequestMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_proto_msgTypes[139] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetPruningWindowRootsRequestMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPruningWindowRootsRequestMessage) ProtoMessage() {} + +func (x *GetPruningWindowRootsRequestMessage) ProtoReflect() protoreflect.Message { + mi := &file_rpc_proto_msgTypes[139] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPruningWindowRootsRequestMessage.ProtoReflect.Descriptor instead. +func (*GetPruningWindowRootsRequestMessage) Descriptor() ([]byte, []int) { + return file_rpc_proto_rawDescGZIP(), []int{139} +} + +type PruningWindowRoots struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PpRoots []string `protobuf:"bytes,1,rep,name=pp_roots,json=ppRoots,proto3" json:"pp_roots,omitempty"` + PpIndex uint64 `protobuf:"varint,2,opt,name=pp_index,json=ppIndex,proto3" json:"pp_index,omitempty"` +} + +func (x *PruningWindowRoots) Reset() { + *x = PruningWindowRoots{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_proto_msgTypes[140] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PruningWindowRoots) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PruningWindowRoots) ProtoMessage() {} + +func (x *PruningWindowRoots) ProtoReflect() protoreflect.Message { + mi := &file_rpc_proto_msgTypes[140] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PruningWindowRoots.ProtoReflect.Descriptor instead. +func (*PruningWindowRoots) Descriptor() ([]byte, []int) { + return file_rpc_proto_rawDescGZIP(), []int{140} +} + +func (x *PruningWindowRoots) GetPpRoots() []string { + if x != nil { + return x.PpRoots + } + return nil +} + +func (x *PruningWindowRoots) GetPpIndex() uint64 { + if x != nil { + return x.PpIndex + } + return 0 +} + +type GetPruningWindowRootsResponseMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Roots []*PruningWindowRoots `protobuf:"bytes,1,rep,name=roots,proto3" json:"roots,omitempty"` + Error *RPCError `protobuf:"bytes,1000,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *GetPruningWindowRootsResponseMessage) Reset() { + *x = GetPruningWindowRootsResponseMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_proto_msgTypes[141] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetPruningWindowRootsResponseMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPruningWindowRootsResponseMessage) ProtoMessage() {} + +func (x *GetPruningWindowRootsResponseMessage) ProtoReflect() protoreflect.Message { + mi := &file_rpc_proto_msgTypes[141] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPruningWindowRootsResponseMessage.ProtoReflect.Descriptor instead. +func (*GetPruningWindowRootsResponseMessage) Descriptor() ([]byte, []int) { + return file_rpc_proto_rawDescGZIP(), []int{141} +} + +func (x *GetPruningWindowRootsResponseMessage) GetRoots() []*PruningWindowRoots { + if x != nil { + return x.Roots + } + return nil +} + +func (x *GetPruningWindowRootsResponseMessage) GetError() *RPCError { + if x != nil { + return x.Error + } + return nil +} + +type AcceptedTxEntry struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TransactionId string `protobuf:"bytes,1,opt,name=transactionId,proto3" json:"transactionId,omitempty"` + IndexWithinBlock uint32 `protobuf:"varint,2,opt,name=index_within_block,json=indexWithinBlock,proto3" json:"index_within_block,omitempty"` +} + +func (x *AcceptedTxEntry) Reset() { + *x = AcceptedTxEntry{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_proto_msgTypes[142] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AcceptedTxEntry) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AcceptedTxEntry) ProtoMessage() {} + +func (x *AcceptedTxEntry) ProtoReflect() protoreflect.Message { + mi := &file_rpc_proto_msgTypes[142] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AcceptedTxEntry.ProtoReflect.Descriptor instead. +func (*AcceptedTxEntry) Descriptor() ([]byte, []int) { + return file_rpc_proto_rawDescGZIP(), []int{142} +} + +func (x *AcceptedTxEntry) GetTransactionId() string { + if x != nil { + return x.TransactionId + } + return "" +} + +func (x *AcceptedTxEntry) GetIndexWithinBlock() uint32 { + if x != nil { + return x.IndexWithinBlock + } + return 0 +} + +type MergesetBlockAcceptanceData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BlockHash string `protobuf:"bytes,1,opt,name=blockHash,proto3" json:"blockHash,omitempty"` + AcceptedTxs []*AcceptedTxEntry `protobuf:"bytes,3,rep,name=acceptedTxs,proto3" json:"acceptedTxs,omitempty"` +} + +func (x *MergesetBlockAcceptanceData) Reset() { + *x = MergesetBlockAcceptanceData{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_proto_msgTypes[143] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MergesetBlockAcceptanceData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MergesetBlockAcceptanceData) ProtoMessage() {} + +func (x *MergesetBlockAcceptanceData) ProtoReflect() protoreflect.Message { + mi := &file_rpc_proto_msgTypes[143] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MergesetBlockAcceptanceData.ProtoReflect.Descriptor instead. +func (*MergesetBlockAcceptanceData) Descriptor() ([]byte, []int) { + return file_rpc_proto_rawDescGZIP(), []int{143} +} + +func (x *MergesetBlockAcceptanceData) GetBlockHash() string { + if x != nil { + return x.BlockHash + } + return "" +} + +func (x *MergesetBlockAcceptanceData) GetAcceptedTxs() []*AcceptedTxEntry { + if x != nil { + return x.AcceptedTxs + } + return nil +} + +type ArchivalBlock struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Child string `protobuf:"bytes,1,opt,name=child,proto3" json:"child,omitempty"` + Block *RpcBlock `protobuf:"bytes,2,opt,name=block,proto3" json:"block,omitempty"` + AcceptanceData []*MergesetBlockAcceptanceData `protobuf:"bytes,3,rep,name=acceptanceData,proto3" json:"acceptanceData,omitempty"` + SelectedParent string `protobuf:"bytes,4,opt,name=selectedParent,proto3" json:"selectedParent,omitempty"` +} + +func (x *ArchivalBlock) Reset() { + *x = ArchivalBlock{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_proto_msgTypes[144] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ArchivalBlock) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ArchivalBlock) ProtoMessage() {} + +func (x *ArchivalBlock) ProtoReflect() protoreflect.Message { + mi := &file_rpc_proto_msgTypes[144] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ArchivalBlock.ProtoReflect.Descriptor instead. +func (*ArchivalBlock) Descriptor() ([]byte, []int) { + return file_rpc_proto_rawDescGZIP(), []int{144} +} + +func (x *ArchivalBlock) GetChild() string { + if x != nil { + return x.Child + } + return "" +} + +func (x *ArchivalBlock) GetBlock() *RpcBlock { + if x != nil { + return x.Block + } + return nil +} + +func (x *ArchivalBlock) GetAcceptanceData() []*MergesetBlockAcceptanceData { + if x != nil { + return x.AcceptanceData + } + return nil +} + +func (x *ArchivalBlock) GetSelectedParent() string { + if x != nil { + return x.SelectedParent + } + return "" +} + +type AddArchivalBlocksRequestMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Blocks []*ArchivalBlock `protobuf:"bytes,1,rep,name=blocks,proto3" json:"blocks,omitempty"` +} + +func (x *AddArchivalBlocksRequestMessage) Reset() { + *x = AddArchivalBlocksRequestMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_proto_msgTypes[145] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddArchivalBlocksRequestMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddArchivalBlocksRequestMessage) ProtoMessage() {} + +func (x *AddArchivalBlocksRequestMessage) ProtoReflect() protoreflect.Message { + mi := &file_rpc_proto_msgTypes[145] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddArchivalBlocksRequestMessage.ProtoReflect.Descriptor instead. +func (*AddArchivalBlocksRequestMessage) Descriptor() ([]byte, []int) { + return file_rpc_proto_rawDescGZIP(), []int{145} +} + +func (x *AddArchivalBlocksRequestMessage) GetBlocks() []*ArchivalBlock { + if x != nil { + return x.Blocks + } + return nil +} + +type AddArchivalBlocksResponseMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Error *RPCError `protobuf:"bytes,1000,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *AddArchivalBlocksResponseMessage) Reset() { + *x = AddArchivalBlocksResponseMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_proto_msgTypes[146] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddArchivalBlocksResponseMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddArchivalBlocksResponseMessage) ProtoMessage() {} + +func (x *AddArchivalBlocksResponseMessage) ProtoReflect() protoreflect.Message { + mi := &file_rpc_proto_msgTypes[146] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddArchivalBlocksResponseMessage.ProtoReflect.Descriptor instead. +func (*AddArchivalBlocksResponseMessage) Descriptor() ([]byte, []int) { + return file_rpc_proto_rawDescGZIP(), []int{146} +} + +func (x *AddArchivalBlocksResponseMessage) GetError() *RPCError { + if x != nil { + return x.Error + } + return nil +} + var File_rpc_proto protoreflect.FileDescriptor var file_rpc_proto_rawDesc = []byte{ @@ -9355,10 +9778,63 @@ var file_rpc_proto_rawDesc = []byte{ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x73, 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, - 0x73, 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, - 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x22, 0x25, 0x0a, 0x23, 0x47, 0x65, 0x74, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, 0x57, + 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x4a, 0x0a, 0x12, 0x50, 0x72, 0x75, 0x6e, + 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x19, + 0x0a, 0x08, 0x70, 0x70, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x07, 0x70, 0x70, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x70, 0x5f, + 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x70, 0x70, 0x49, + 0x6e, 0x64, 0x65, 0x78, 0x22, 0x87, 0x01, 0x0a, 0x24, 0x47, 0x65, 0x74, 0x50, 0x72, 0x75, 0x6e, + 0x69, 0x6e, 0x67, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x33, 0x0a, + 0x05, 0x72, 0x6f, 0x6f, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x50, 0x72, 0x75, 0x6e, 0x69, 0x6e, 0x67, + 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x52, 0x6f, 0x6f, 0x74, 0x73, 0x52, 0x05, 0x72, 0x6f, 0x6f, + 0x74, 0x73, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, + 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x65, + 0x0a, 0x0f, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x54, 0x78, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x24, 0x0a, 0x0d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x12, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x5f, 0x77, 0x69, 0x74, 0x68, 0x69, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x10, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x57, 0x69, 0x74, 0x68, 0x69, 0x6e, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x79, 0x0a, 0x1b, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x73, 0x65, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, + 0x44, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, + 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, + 0x73, 0x68, 0x12, 0x3c, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x54, 0x78, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, + 0x69, 0x72, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x54, 0x78, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x54, 0x78, 0x73, + 0x22, 0xc8, 0x01, 0x0a, 0x0d, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x12, 0x29, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, + 0x69, 0x72, 0x65, 0x2e, 0x52, 0x70, 0x63, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x12, 0x4e, 0x0a, 0x0e, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x73, 0x65, 0x74, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, + 0x61, 0x74, 0x61, 0x52, 0x0e, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x44, + 0x61, 0x74, 0x61, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x65, 0x6c, + 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x22, 0x53, 0x0a, 0x1f, 0x41, + 0x64, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x30, + 0x0a, 0x06, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x41, 0x72, 0x63, 0x68, 0x69, + 0x76, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x06, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, + 0x22, 0x4e, 0x0a, 0x20, 0x41, 0x64, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x61, 0x6c, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, + 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, + 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x2d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x73, + 0x70, 0x65, 0x63, 0x74, 0x72, 0x65, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, + 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -9374,7 +9850,7 @@ func file_rpc_proto_rawDescGZIP() []byte { } var file_rpc_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_rpc_proto_msgTypes = make([]protoimpl.MessageInfo, 139) +var file_rpc_proto_msgTypes = make([]protoimpl.MessageInfo, 147) var file_rpc_proto_goTypes = []any{ (SubmitBlockResponseMessage_RejectReason)(0), // 0: protowire.SubmitBlockResponseMessage.RejectReason (*RPCError)(nil), // 1: protowire.RPCError @@ -9516,6 +9992,14 @@ var file_rpc_proto_goTypes = []any{ (*GetCurrentBlockColorResponseMessage)(nil), // 137: protowire.GetCurrentBlockColorResponseMessage (*SubmitTransactionReplacementRequestMessage)(nil), // 138: protowire.SubmitTransactionReplacementRequestMessage (*SubmitTransactionReplacementResponseMessage)(nil), // 139: protowire.SubmitTransactionReplacementResponseMessage + (*GetPruningWindowRootsRequestMessage)(nil), // 140: protowire.GetPruningWindowRootsRequestMessage + (*PruningWindowRoots)(nil), // 141: protowire.PruningWindowRoots + (*GetPruningWindowRootsResponseMessage)(nil), // 142: protowire.GetPruningWindowRootsResponseMessage + (*AcceptedTxEntry)(nil), // 143: protowire.AcceptedTxEntry + (*MergesetBlockAcceptanceData)(nil), // 144: protowire.MergesetBlockAcceptanceData + (*ArchivalBlock)(nil), // 145: protowire.ArchivalBlock + (*AddArchivalBlocksRequestMessage)(nil), // 146: protowire.AddArchivalBlocksRequestMessage + (*AddArchivalBlocksResponseMessage)(nil), // 147: protowire.AddArchivalBlocksResponseMessage } var file_rpc_proto_depIdxs = []int32{ 3, // 0: protowire.RpcBlock.header:type_name -> protowire.RpcBlockHeader @@ -9619,11 +10103,18 @@ var file_rpc_proto_depIdxs = []int32{ 6, // 98: protowire.SubmitTransactionReplacementRequestMessage.transaction:type_name -> protowire.RpcTransaction 6, // 99: protowire.SubmitTransactionReplacementResponseMessage.replacedTransaction:type_name -> protowire.RpcTransaction 1, // 100: protowire.SubmitTransactionReplacementResponseMessage.error:type_name -> protowire.RPCError - 101, // [101:101] is the sub-list for method output_type - 101, // [101:101] is the sub-list for method input_type - 101, // [101:101] is the sub-list for extension type_name - 101, // [101:101] is the sub-list for extension extendee - 0, // [0:101] is the sub-list for field type_name + 141, // 101: protowire.GetPruningWindowRootsResponseMessage.roots:type_name -> protowire.PruningWindowRoots + 1, // 102: protowire.GetPruningWindowRootsResponseMessage.error:type_name -> protowire.RPCError + 143, // 103: protowire.MergesetBlockAcceptanceData.acceptedTxs:type_name -> protowire.AcceptedTxEntry + 2, // 104: protowire.ArchivalBlock.block:type_name -> protowire.RpcBlock + 144, // 105: protowire.ArchivalBlock.acceptanceData:type_name -> protowire.MergesetBlockAcceptanceData + 145, // 106: protowire.AddArchivalBlocksRequestMessage.blocks:type_name -> protowire.ArchivalBlock + 1, // 107: protowire.AddArchivalBlocksResponseMessage.error:type_name -> protowire.RPCError + 108, // [108:108] is the sub-list for method output_type + 108, // [108:108] is the sub-list for method input_type + 108, // [108:108] is the sub-list for extension type_name + 108, // [108:108] is the sub-list for extension extendee + 0, // [0:108] is the sub-list for field type_name } func init() { file_rpc_proto_init() } @@ -11300,6 +11791,102 @@ func file_rpc_proto_init() { return nil } } + file_rpc_proto_msgTypes[139].Exporter = func(v any, i int) any { + switch v := v.(*GetPruningWindowRootsRequestMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_proto_msgTypes[140].Exporter = func(v any, i int) any { + switch v := v.(*PruningWindowRoots); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_proto_msgTypes[141].Exporter = func(v any, i int) any { + switch v := v.(*GetPruningWindowRootsResponseMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_proto_msgTypes[142].Exporter = func(v any, i int) any { + switch v := v.(*AcceptedTxEntry); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_proto_msgTypes[143].Exporter = func(v any, i int) any { + switch v := v.(*MergesetBlockAcceptanceData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_proto_msgTypes[144].Exporter = func(v any, i int) any { + switch v := v.(*ArchivalBlock); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_proto_msgTypes[145].Exporter = func(v any, i int) any { + switch v := v.(*AddArchivalBlocksRequestMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_proto_msgTypes[146].Exporter = func(v any, i int) any { + switch v := v.(*AddArchivalBlocksResponseMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -11307,7 +11894,7 @@ func file_rpc_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_rpc_proto_rawDesc, NumEnums: 1, - NumMessages: 139, + NumMessages: 147, NumExtensions: 0, NumServices: 0, }, diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto index 4938aaf..cdcda42 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc.proto @@ -888,4 +888,38 @@ message SubmitTransactionReplacementResponseMessage { RpcTransaction replacedTransaction = 2; RPCError error = 1000; -} \ No newline at end of file +} + +message GetPruningWindowRootsRequestMessage {} + +message PruningWindowRoots { + repeated string pp_roots = 1; + uint64 pp_index = 2; +} + +message GetPruningWindowRootsResponseMessage { + repeated PruningWindowRoots roots = 1; + RPCError error = 1000; +} + +message AcceptedTxEntry{ + string transactionId = 1; + uint32 index_within_block = 2; +} + + +message MergesetBlockAcceptanceData{ + string blockHash = 1; + repeated AcceptedTxEntry acceptedTxs = 3; +} + +message ArchivalBlock{ + string child = 1; + RpcBlock block = 2; + repeated MergesetBlockAcceptanceData acceptanceData = 3; + string selectedParent = 4; +} + +message AddArchivalBlocksRequestMessage { repeated ArchivalBlock blocks = 1; } + +message AddArchivalBlocksResponseMessage { RPCError error = 1000; } \ No newline at end of file diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_add_archival_blocks.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_add_archival_blocks.go new file mode 100644 index 0000000..18f7273 --- /dev/null +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_add_archival_blocks.go @@ -0,0 +1,113 @@ +package protowire + +import ( + "github.com/pkg/errors" + "github.com/spectre-project/spectred/app/appmessage" +) + +func (x *SpectredMessage_AddArchivalBlocksRequest) toAppMessage() (appmessage.Message, error) { + panic("we need to implement acceptance data conversion") + if x == nil { + return nil, errors.Wrapf(errorNil, "SpectredMessage_AddArchivalBlocksRequest is nil") + } + + blocks := make([]*appmessage.ArchivalBlock, len(x.AddArchivalBlocksRequest.Blocks)) + for i, block := range x.AddArchivalBlocksRequest.Blocks { + rpcBlock, err := block.Block.toAppMessage() + if err != nil { + return nil, err + } + + blocks[i] = &appmessage.ArchivalBlock{ + Block: rpcBlock, + Child: block.Child, + } + } + + return &appmessage.AddArchivalBlocksRequestMessage{ + Blocks: blocks, + }, nil +} + +func (x *SpectredMessage_AddArchivalBlocksRequest) fromAppMessage(message *appmessage.AddArchivalBlocksRequestMessage) error { + blocks := make([]*ArchivalBlock, len(message.Blocks)) + for i, block := range message.Blocks { + protoBlock := &ArchivalBlock{ + Child: block.Child, + SelectedParent: block.SelectedParent, + } + + if block.Block != nil { + protoBlock.Block = &RpcBlock{} + err := protoBlock.Block.fromAppMessage(block.Block) + if err != nil { + return err + } + } + + protoBlock.AcceptanceData = make([]*MergesetBlockAcceptanceData, len(block.AcceptanceData)) + for j, acceptanceData := range block.AcceptanceData { + protoBlock.AcceptanceData[j] = &MergesetBlockAcceptanceData{} + protoBlock.AcceptanceData[j].fromAppMessage(acceptanceData) + } + + blocks[i] = protoBlock + } + + x.AddArchivalBlocksRequest = &AddArchivalBlocksRequestMessage{ + Blocks: blocks, + } + return nil +} + +func (x *MergesetBlockAcceptanceData) fromAppMessage(message *appmessage.MergesetBlockAcceptanceData) error { + if message == nil { + return errors.Wrapf(errorNil, "MergesetBlockAcceptanceData is nil") + } + + x.BlockHash = message.BlockHash + x.AcceptedTxs = make([]*AcceptedTxEntry, len(message.AcceptedTxs)) + for i, tx := range message.AcceptedTxs { + x.AcceptedTxs[i] = &AcceptedTxEntry{ + TransactionId: tx.TransactionID, + IndexWithinBlock: tx.IndexWithinBlock, + } + } + + return nil +} + +func (x *SpectredMessage_AddArchivalBlocksResponse) toAppMessage() (appmessage.Message, error) { + if x == nil { + return nil, errors.Wrapf(errorNil, "SpectredMessage_AddArchivalBlocksResponse is nil") + } + return x.AddArchivalBlocksResponse.toAppMessage() +} + +func (x *SpectredMessage_AddArchivalBlocksResponse) fromAppMessage(message *appmessage.AddArchivalBlocksResponseMessage) error { + var err *RPCError + if message.Error != nil { + err = &RPCError{Message: message.Error.Message} + } + + x.AddArchivalBlocksResponse = &AddArchivalBlocksResponseMessage{ + Error: err, + } + + return nil +} + +func (x *AddArchivalBlocksResponseMessage) toAppMessage() (appmessage.Message, error) { + if x == nil { + return nil, errors.Wrapf(errorNil, "AddArchivalBlocksResponseMessage is nil") + } + rpcErr, err := x.Error.toAppMessage() + // Error is an optional field + if err != nil && !errors.Is(err, errorNil) { + return nil, err + } + + return &appmessage.AddArchivalBlocksResponseMessage{ + Error: rpcErr, + }, nil +} diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_pruning_window_roots.go b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_pruning_window_roots.go new file mode 100644 index 0000000..2c90018 --- /dev/null +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/rpc_get_pruning_window_roots.go @@ -0,0 +1,70 @@ +package protowire + +import ( + "github.com/pkg/errors" + "github.com/spectre-project/spectred/app/appmessage" +) + +func (x *SpectredMessage_GetPruningWindowRootsRequest) toAppMessage() (appmessage.Message, error) { + if x == nil { + return nil, errors.Wrapf(errorNil, "SpectredMessage_GetPruningWindowRootsRequest is nil") + } + return &appmessage.GetPeerAddressesRequestMessage{}, nil +} + +func (x *SpectredMessage_GetPruningWindowRootsRequest) fromAppMessage(_ *appmessage.GetPruningWindowRootsRequestMessage) error { + return nil +} + +func (x *SpectredMessage_GetPruningWindowRootsResponse) toAppMessage() (appmessage.Message, error) { + if x == nil { + return nil, errors.Wrapf(errorNil, "SpectredMessage_GetPruningWindowRootsResponse is nil") + } + return x.GetPruningWindowRootsResponse.toAppMessage() +} + +func (x *SpectredMessage_GetPruningWindowRootsResponse) fromAppMessage(message *appmessage.GetPruningWindowRootsResponseMessage) error { + var err *RPCError + if message.Error != nil { + err = &RPCError{Message: message.Error.Message} + } + + roots := make([]*PruningWindowRoots, len(message.Roots)) + for i, root := range message.Roots { + roots[i] = &PruningWindowRoots{ + PpRoots: root.PPRoots, + PpIndex: root.PPIndex, + } + } + + x.GetPruningWindowRootsResponse = &GetPruningWindowRootsResponseMessage{ + Roots: roots, + Error: err, + } + + return nil +} + +func (x *GetPruningWindowRootsResponseMessage) toAppMessage() (appmessage.Message, error) { + if x == nil { + return nil, errors.Wrapf(errorNil, "GetPeerAddressesResponseMessage is nil") + } + rpcErr, err := x.Error.toAppMessage() + // Error is an optional field + if err != nil && !errors.Is(err, errorNil) { + return nil, err + } + + roots := make([]*appmessage.PruningWindowRoots, len(x.Roots)) + for i, root := range x.Roots { + roots[i] = &appmessage.PruningWindowRoots{ + PPRoots: root.PpRoots, + PPIndex: root.PpIndex, + } + } + + return &appmessage.GetPruningWindowRootsResponseMessage{ + Roots: roots, + Error: rpcErr, + }, nil +} diff --git a/infrastructure/network/netadapter/server/grpcserver/protowire/wire.go b/infrastructure/network/netadapter/server/grpcserver/protowire/wire.go index 2d5d0fa..9ea0832 100644 --- a/infrastructure/network/netadapter/server/grpcserver/protowire/wire.go +++ b/infrastructure/network/netadapter/server/grpcserver/protowire/wire.go @@ -989,6 +989,34 @@ func toRPCPayload(message appmessage.Message) (isSpectredMessage_Payload, error) return nil, err } return payload, nil + case *appmessage.GetPruningWindowRootsRequestMessage: + payload := new(SpectredMessage_GetPruningWindowRootsRequest) + err := payload.fromAppMessage(message) + if err != nil { + return nil, err + } + return payload, nil + case *appmessage.GetPruningWindowRootsResponseMessage: + payload := new(SpectredMessage_GetPruningWindowRootsResponse) + err := payload.fromAppMessage(message) + if err != nil { + return nil, err + } + return payload, nil + case *appmessage.AddArchivalBlocksRequestMessage: + payload := new(SpectredMessage_AddArchivalBlocksRequest) + err := payload.fromAppMessage(message) + if err != nil { + return nil, err + } + return payload, nil + case *appmessage.AddArchivalBlocksResponseMessage: + payload := new(SpectredMessage_AddArchivalBlocksResponse) + err := payload.fromAppMessage(message) + if err != nil { + return nil, err + } + return payload, nil default: return nil, nil } diff --git a/infrastructure/network/rpcclient/rpc_add_archival_blocks.go b/infrastructure/network/rpcclient/rpc_add_archival_blocks.go new file mode 100644 index 0000000..d001f21 --- /dev/null +++ b/infrastructure/network/rpcclient/rpc_add_archival_blocks.go @@ -0,0 +1,19 @@ +package rpcclient + +import "github.com/spectre-project/spectred/app/appmessage" + +func (c *RPCClient) AddArchivalBlocks(blocks []*appmessage.ArchivalBlock) (*appmessage.AddArchivalBlocksResponseMessage, error) { + err := c.rpcRouter.outgoingRoute().Enqueue(appmessage.NewAddArchivalBlocksRequestMessage(blocks)) + if err != nil { + return nil, err + } + response, err := c.route(appmessage.CmdAddArchivalBlocksResponseMessage).DequeueWithTimeout(c.timeout) + if err != nil { + return nil, err + } + convertedResp := response.(*appmessage.AddArchivalBlocksResponseMessage) + if convertedResp.Error != nil { + return nil, c.convertRPCError(convertedResp.Error) + } + return convertedResp, nil +} diff --git a/infrastructure/network/rpcclient/rpc_get_pruning_window_roots.go b/infrastructure/network/rpcclient/rpc_get_pruning_window_roots.go new file mode 100644 index 0000000..7784cad --- /dev/null +++ b/infrastructure/network/rpcclient/rpc_get_pruning_window_roots.go @@ -0,0 +1,19 @@ +package rpcclient + +import "github.com/spectre-project/spectred/app/appmessage" + +func (c *RPCClient) GetPruningWindowRoots() (*appmessage.GetPruningWindowRootsResponseMessage, error) { + err := c.rpcRouter.outgoingRoute().Enqueue(&appmessage.GetPruningWindowRootsRequestMessage{}) + if err != nil { + return nil, err + } + response, err := c.route(appmessage.CmdGetPruningWindowRootsResponseMessage).DequeueWithTimeout(c.timeout) + if err != nil { + return nil, err + } + convertedResp := response.(*appmessage.GetPruningWindowRootsResponseMessage) + if convertedResp.Error != nil { + return nil, c.convertRPCError(convertedResp.Error) + } + return convertedResp, nil +}