autonomys / subspace

Subspace Network reference implementation
https://subspace.network
380 stars 243 forks source link

Implement gateway RPC launch and piece getting #3148

Closed teor2345 closed 1 week ago

teor2345 commented 2 weeks ago

This PR makes the gateway get pieces from the DSN, validate them, and reconstruct them into objects.

It also:

Code contributor checklist:

teor2345 commented 2 weeks ago

I tested the gateway on devnet, and I get an error that says the DSN is not currently working (or my connection isn't working):

$ target/release/subspace-gateway run --dsn-bootstrap-nodes <dev node address from Slack>
$ websocat --jsonrpc ws://127.0.0.1:9955
subspace_fetchObject [{"v0": { "objects": [["0000000000000000000000000000000000000000000000000000000000000000",0,0]]}}]
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": 9001,
    "message": "ObjectFetcherError(PieceNotFound { piece_index: PieceIndex(0) })"
  }
}
nazar-pc commented 2 weeks ago

What devnet node did you use specifically?

teor2345 commented 2 weeks ago

What devnet node did you use specifically?

--dsn-bootstrap-nodes /dns/bootstrap-0.devnet.subspace.foundation/tcp/30333/p2p/12D3KooWKd4qisMjuBXU4YvpbJgepiX278iumqMjCC3GiUjjZEZS

Is that the right one?

nazar-pc commented 2 weeks ago

Yes, I think you didn't call node.bootstrap() to actually discover the network first.

teor2345 commented 2 weeks ago

This should work too, I implemented validation because it was pretty easy.

teor2345 commented 1 week ago

This PR conflicted with #3156, so I merged that PR into it, and implemented the minor suggestions from #3137.

(I'll do the significant refactors in other PRs based on this one.)

nazar-pc commented 1 week ago

Some related to auto-merge broke here, I tried to approve it a few times and it didn't move forward, so I force-merged it