storacha-network / specs

🏅 Technical specifications for the w3up protocol stack
17 stars 0 forks source link

Embrace new UCAN representation and invocation Spec #65

Open vasco-santos opened 1 year ago

vasco-santos commented 1 year ago

We need to swap this all over the place in the specs repo.

we should embrace new UCAN representation and also embrace upcoming invocation spec

vasco-santos commented 1 year ago

@Gozala already did a draft for aggregation spec in https://github.com/web3-storage/specs/pull/62#issuecomment-1601552810

# Agency namespaces aggregate APIs by DID of the aggregator
type AgencyAPI {[AggregatorDID] AggregateAPI }

type AggregateAPI union {
  AggregateOffer      "aggregate/offer"
  AggregateGet         "aggregate/get"
  DealArrange            "deal/arrange" 
} representation representation inline {
  discriminantKey "op"
}

type AggregateOffer struct {
   # in
   rsc        AggregatorDID
   input     Offer
   # out
   out        OfferState
   # kicks off "deal/arrange" and makes aggregate state "queued"
   join        &DealArrange
}

type OfferState union {
  Unit "ok"
  Any  "error"
} type keyed

type Offer struct {
   offer &AggregateInfo
   # delegation allowing to `publish/piece` contained pieces and `deal/sign` offered aggregate
   ucan &UCAN
}

type AggregateInfo struct {
   link        &CommP
   size        Int
   pieces   [PieceInfo]
}

type AggregateGet struct {
    # in
   rsc        AggregatorDID
   input     AggregateRef
   # out
   out        AggregateGetResult
}

type DealArrange struct {
   # in
   rsc        AgencyDID
   input     DealInfo
   # out
   out         DealResult
}

type DealInfo struct {
  aggregate   &CommP
}

type DealResult union {
   | Unit   "ok"
   | Any    "error"
} representation keyed

type AggregateGetResult union {
  AggregateState  "ok"
} keyed

type AggregateState union {
  | &QueuedAggregate     "queued"
  | &AcceptedAggregate   "accepted"
  | &RejectedAggregate    "rejected"
} representation keyed

type AggregatorAPI union {
  | PublishPiece            "piece/publish"
  | DealSign                   "deal/offer"
}

type PiecePublish {
   # in
   rsc      AggregatorDID
   input   ContentPieceInfo      
   # out
   out      ContentLocation
}

type ContentPieceInfo {
  piece         &CommP
  content     &CAR 
}

type ContentLocation {
  url URL
}

type DealOffer {
   rsc      AggregatorDID
   input   DealInfo
   # out
   out      DealResult
}

type Deal {
   aggregate      &CommP
   // .... not sure what else goes in here
}

type DealResult union {
  | DealSignature   "ok"
  | Any                     "error"
} representation keyed

type DealSignature {
   iss         AggregatorDID
   sig         bytes
}

type URL string
type CAR bytes
type CommP bytes

type # https://github.com/filecoin-project/go-state-types/blob/1e6cf0d47cdda75383ef036fc2725d1cf51dbde8/abi/piece.go#L47-L50
type PieceInfo {
  # Size in nodes. For BLS12-381 (capacity 254 bits), must be >= 16. (16 * 8 = 128)
  size Int
  link Link
}