Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

PoC: Link Deal Proposal to IPNI Context ID #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

bajtos
Copy link
Member

@bajtos bajtos commented Dec 5, 2023

No description provided.

}

func main() {
jsonString := `{"Proposal":{"PieceCID":{"/":"baga6ea4seaqmh37khqbfmvt3phtfsxuz2ok3koypajjxn7gwml26uojmub54kny"},"PieceSize":34359738368,"VerifiedDeal":true,"Client":"f01880278","Provider":"f02118066","Label":"bafybeiadnyv6t65hnwx4as467n4p7k4u6bwsh3dhw24xrahfdwcmpddyo4","StartEpoch":2867966,"EndEpoch":4359806,"StoragePricePerEpoch":"0","ProviderCollateral":"11361143711469027","ClientCollateral":"0"},"State":{"SectorStartEpoch":2856167,"LastUpdatedEpoch":3106586,"SlashEpoch":-1,"VerifiedClaim":18771683}}`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string is coming from the following deal:

{
  "Proposal": {
    "PieceCID": {
      "/": "baga6ea4seaqmh37khqbfmvt3phtfsxuz2ok3koypajjxn7gwml26uojmub54kny"
    },
    "PieceSize": 34359738368,
    "VerifiedDeal": true,
    "Client": "f01880278",
    "Provider": "f02118066",
    "Label": "bafybeiadnyv6t65hnwx4as467n4p7k4u6bwsh3dhw24xrahfdwcmpddyo4",
    "StartEpoch": 2867966,
    "EndEpoch": 4359806,
    "StoragePricePerEpoch": "0",
    "ProviderCollateral": "11361143711469027",
    "ClientCollateral": "0"
  },
  "State": {
    "SectorStartEpoch": 2856167,
    "LastUpdatedEpoch": 3106586,
    "SlashEpoch": -1,
    "VerifiedClaim": 18771683
  }
}

When I query https://cid.contact/ with the payload CID from the Label (bafybeiadnyv6t65hnwx4as467n4p7k4u6bwsh3dhw24xrahfdwcmpddyo4), there is exactly one advertisement and it matches the PieceCID.

https://cid.contact/cid/bafybeiadnyv6t65hnwx4as467n4p7k4u6bwsh3dhw24xrahfdwcmpddyo4

{
  "MultihashResults": [
    {
      "Multihash": "EiADbivp+6dtr8BLnvt4/6uU8G0j7Ge2uXiA5R2Ex4x4dw==",
      "ProviderResults": [
        {
          "ContextID": "AXESIDEKHzzod/XJVEkdEUc1sh9BK3iGFoBtCW75KTCcSF/y",
          "Metadata": "kBKjaFBpZWNlQ0lE2CpYKAABgeIDkiAgw+/qPAJWVnt55llemdOVtTsPAlN2/NZi9eo5LKB7xTdsVmVyaWZpZWREZWFs9W1GYXN0UmV0cmlldmFs9Q==",
          "Provider": {
            "ID": "12D3KooWKBMzvWLW4BV1ruPuAXxU1uoutRjxioz9iCWyKzdggvnS",
            "Addrs": [
              "/ip4/154.42.3.144/tcp/24001"
            ]
          }
        }
      ]
    }
  ]
}
Screenshot 2023-12-05 at 13 50 47

However, when I run my Go program calculating Context ID for this deal, I get back a different string - CID bytes are AXESILJcQ2s6OzbQon44jRsuurFgFsXLjRVMpKREU1f0rOwu.

DealProposal: market.DealProposal{PieceCID:cid.Cid{str:"\x01\x81\xe2\x03\x92  \xc3\xef\xea<\x02VV{y\xe6Y^\x99ӕ\xb5;\x0f\x02Sv\xfc\xd6b\xf5\xea9,\xa0{\xc57"}, PieceSize:0x800000000, VerifiedDeal:true, Client:address.Address{str:"\x00\xd6\xe1r"}, Provider:address.Address{str:"\x00\xb2\xa3\x81\x01"}, Label:market.DealLabel{bs:[]uint8{0x62, 0x61, 0x66, 0x79, 0x62, 0x65, 0x69, 0x61, 0x64, 0x6e, 0x79, 0x76, 0x36, 0x74, 0x36, 0x35, 0x68, 0x6e, 0x77, 0x78, 0x34, 0x61, 0x73, 0x34, 0x36, 0x37, 0x6e, 0x34, 0x70, 0x37, 0x6b, 0x34, 0x75, 0x36, 0x62, 0x77, 0x73, 0x68, 0x33, 0x64, 0x68, 0x77, 0x32, 0x34, 0x78, 0x72, 0x61, 0x68, 0x66, 0x64, 0x77, 0x63, 0x6d, 0x70, 0x64, 0x64, 0x79, 0x6f, 0x34}, notString:false}, StartEpoch:2867966, EndEpoch:4359806, StoragePricePerEpoch:0, ProviderCollateral:11361143711469027, ClientCollateral:0}
DAG-CBOR: 8bd82a5828000181e203922020c3efea3c0256567b79e6595e99d395b53b0f025376fcd662f5ea392ca07bc5371b0000000800000000f54400d6e1724500b2a38101783b6261667962656961646e797636743635686e77783461733436376e3470376b3475366277736833646877323478726168666477636d706464796f341a002bc2fe1a0042867e404800285ce6672a0de340
CID bytes: AXESILJcQ2s6OzbQon44jRsuurFgFsXLjRVMpKREU1f0rOwu

FWIW, this is the DAG-CBOR structure as shown by https://cbor.me:

8B                                      # array(11)
   D8 2A                                # tag(42)
      58 28                             # bytes(40)
         000181E203922020C3EFEA3C0256567B79E6595E99D395B53B0F025376FCD662F5EA392CA07BC537 # "\u0000\u0001\x81\xE2\u0003\x92  \xC3\xEF\xEA<\u0002VV{y\xE6Y^\x99ӕ\xB5;\u000F\u0002Sv\xFC\xD6b\xF5\xEA9,\xA0{\xC57"
   1B 0000000800000000                  # unsigned(34359738368)
   F5                                   # primitive(21)
   44                                   # bytes(4)
      00D6E172                          # "\u0000\xD6\xE1r"
   45                                   # bytes(5)
      00B2A38101                        # "\u0000\xB2\xA3\x81\u0001"
   78 3B                                # text(59)
      6261667962656961646E797636743635686E77783461733436376E3470376B3475366277736833646877323478726168666477636D706464796F34 # "bafybeiadnyv6t65hnwx4as467n4p7k4u6bwsh3dhw24xrahfdwcmpddyo4"
   1A 002BC2FE                          # unsigned(2867966)
   1A 0042867E                          # unsigned(4359806)
   40                                   # bytes(0)
                                        # ""
   48                                   # bytes(8)
      00285CE6672A0DE3                  # "\u0000(\\\xE6g*\r\xE3"
   40                                   # bytes(0)
                                        # ""

What am I doing wrong?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that Boost computes the Context ID from market.ClientDealProposal containing two fields: Proposal and ClientSignature (source code, see also the screenshot below).

Unfortunately, the data provided in StateMarketDeals.json.zst by Glif (presumably a snapshot of Lotus’ method StateMarketDeals) contains only the Proposal but not the ClientSignature.

Screenshot 2024-02-14 at 15 36 29

@bajtos bajtos changed the title Initial implementation PoC: Link Deal Proposal to IPNI Context ID Feb 14, 2024
@bajtos bajtos closed this Apr 26, 2024
@bajtos bajtos reopened this Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant