@@ -2960,6 +2960,56 @@ func marshalUniverseRoot(node universe.Root) (*unirpc.UniverseRoot, error) {
29602960 }, nil
29612961}
29622962
2963+ // MultiverseRoot returns the root of the multiverse tree. This is useful to
2964+ // determine the equality of two multiverse trees, since the root can directly
2965+ // be compared to another multiverse root to find out if a sync is required.
2966+ func (r * rpcServer ) MultiverseRoot (ctx context.Context ,
2967+ req * unirpc.MultiverseRootRequest ) (* unirpc.MultiverseRootResponse ,
2968+ error ) {
2969+
2970+ proofType , err := UnmarshalUniProofType (req .ProofType )
2971+ if err != nil {
2972+ return nil , fmt .Errorf ("invalid proof type: %w" , err )
2973+ }
2974+
2975+ if proofType == universe .ProofTypeUnspecified {
2976+ return nil , fmt .Errorf ("proof type must be specified" )
2977+ }
2978+
2979+ filterByIDs := make ([]universe.Identifier , len (req .SpecificIds ))
2980+ for idx , rpcID := range req .SpecificIds {
2981+ filterByIDs [idx ], err = UnmarshalUniID (rpcID )
2982+ if err != nil {
2983+ return nil , fmt .Errorf ("unable to parse universe id: " +
2984+ "%w" , err )
2985+ }
2986+
2987+ // Allow the RPC user to not specify the proof type for each ID
2988+ // individually since the outer one is mandatory.
2989+ if filterByIDs [idx ].ProofType == universe .ProofTypeUnspecified {
2990+ filterByIDs [idx ].ProofType = proofType
2991+ }
2992+
2993+ if filterByIDs [idx ].ProofType != proofType {
2994+ return nil , fmt .Errorf ("proof type mismatch in ID " +
2995+ "%d: %v != %v" , idx , filterByIDs [idx ].ProofType ,
2996+ proofType )
2997+ }
2998+ }
2999+
3000+ rootNode , err := r .cfg .UniverseArchive .MultiverseRoot (
3001+ ctx , proofType , filterByIDs ,
3002+ )
3003+ if err != nil {
3004+ return nil , fmt .Errorf ("unable to fetch multiverse root: %w" ,
3005+ err )
3006+ }
3007+
3008+ return & unirpc.MultiverseRootResponse {
3009+ MultiverseRoot : marshalMssmtNode (rootNode ),
3010+ }, nil
3011+ }
3012+
29633013// AssetRoots queries for the known Universe roots associated with each known
29643014// asset. These roots represent the supply/audit state for each known asset.
29653015func (r * rpcServer ) AssetRoots (ctx context.Context ,
0 commit comments