Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase 1 logic #24

Open
3 tasks
ninabreznik opened this issue Jun 14, 2020 · 3 comments
Open
3 tasks

Phase 1 logic #24

ninabreznik opened this issue Jun 14, 2020 · 3 comments
Assignees

Comments

@ninabreznik
Copy link
Member

ninabreznik commented Jun 14, 2020

@todo

  • rename stuff (see parameter naming below)
  • change stuff (see change proposals below)
  • other fixes (see Updates/Bug fixes #23 )

1. publisher registers new data

we get merkle root like this https://pastebin.com/QH7egWUX and then submit it to the chain

await API.tx.datVerify.registerData(merkleRoot)

2. chain emits SomethingStored event

3. after the event is emitted, users can register for different roles: encoder, hoster, attestor

await API.tx.datVerify.registerEncoder()
await API.tx.datVerify.registerSeeder()
await API.tx.datVerify.registerAttestor()

4. When users registers for any of the roles, chain will check if there is any data that needs hosting and if there is at least one hoster, one encoder and one attestor, then 'New Pin' is emitted

5. new event is emitted (NewPin) where encoder and hoster are notified about what feed needs hosting/encoding

const [encoderID, hosterID, datID] = event.data

6. we pair hoster and encoder: encoder compresses data and passes them over to hoster

7. when encoder finishes its job, it notifies the chain (registerEncoding)

const args = [hosterID, datID, start, end]
// if more ranges, send same tx for each range separately

8. when hoster gets all the data, it also notifies the chain (confirmHosting)

await API.tx.datVerify.confirmHosting(datID, index) // index = HostedMap.encoded[index] (get encoderID and then loop through to get position in the array)

9. chain emits event: HostingStarted

const data = event.data // [hosterID, datID]

10. Publisher can now submitChallenge

await API.tx.datVerify.submitChallenge(hosterID, datID)

11. Challenge event is emitted where hoster is notified about the challenges

const [hosterKey, datKey] = event.data
// hostedMap => see which chunks are hosted by this hoster for this key (Rust API line 317)

12. Hoster submits proof to the chain

//challengeID no longer exists -> use [datID, chunk] directly
await API.tx.datVerify.submitProof(challengeID, []) //challenge ID is parsed

13. If challenges are successful, chain emits new event: AttestPhase

const [challengeID, expectedAttestors] = event.data
const attestorIDs = JSON.parse(expectedAttestors).expected_attestors

// change proposal:
// could we just pass an array of attestors instead of an object
const [challengeID, attestorIDs] = event.data

14. random attester is selected to go grab data from the swarm

  • currently we just hardcode the response, so no attester actually goes to the swarm

15. Attester reports back to the chain (submitAttestation)

  function getAttestation () {
    const location = 0
    const latency = 0
    return [location, latency]
  }
const attestation = await getAttestation()
//challengeID no longer exists -> use [hosterId, datID, chunk] directly
const submit = await API.tx.datVerify.submitAttestation(challengeID, attestation)
@jam10o-new
Copy link

Missing in description above -

step 8) confirmHosting has an additional index parameter to identify which encoding is being confirmed.

jam10o-new pushed a commit that referenced this issue Jun 16, 2020
@jam10o-new
Copy link

also, changes described in point 13 have been implemented

@jam10o-new
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants