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

Issues from running substrate & service #18

Closed
ninabreznik opened this issue Feb 14, 2020 · 4 comments
Closed

Issues from running substrate & service #18

ninabreznik opened this issue Feb 14, 2020 · 4 comments
Assignees

Comments

@ninabreznik
Copy link
Member

ninabreznik commented Feb 14, 2020

newPin event

It seems like it doesn't log the correct user nor hypercore address. I get all event logs look the same (same user + same key (not matching the actual hypercore key)). The user account logged in the event seem to be always the one that gets finalized first (we're also creating users)

VIDEO 1 (watch first) https://www.loom.com/share/78305a4036804a14af3f67fa0c36e2f0


VIDEO 2 (watch next) https://www.loom.com/share/4bb8ab5e497c47ceb7b09734122d2688

@serapath serapath mentioned this issue Feb 14, 2020
28 tasks
@jam10o-new
Copy link

jam10o-new commented Feb 14, 2020

So, looking into the apps UI, I'm actually seeing all of the expected events seperately, so all the pins are happening successfully.

I can however replicate the same issue in datdot-service, which leads me to believe this is a bug in either @polkadot/api or our use of it.

         {"ApplyExtrinsic":6} : system.ExtrinsicSuccess [{"weight":10000,"class":"normal","paysFee":true}]
         {"ApplyExtrinsic":6} : datVerify.NewPin ["5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw","0xc463e0b2d4c1816242918adc2670915c16a8cd2125ae41d2b1e01696269e4219"]
         {"ApplyExtrinsic":6} : system.ExtrinsicSuccess [{"weight":10000,"class":"normal","paysFee":true}]
         {"ApplyExtrinsic":6} : datVerify.NewPin ["5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw","0xc463e0b2d4c1816242918adc2670915c16a8cd2125ae41d2b1e01696269e4219"]
         {"ApplyExtrinsic":6} : system.ExtrinsicSuccess [{"weight":10000,"class":"normal","paysFee":true}]
         {"ApplyExtrinsic":6} : datVerify.NewPin ["5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw","0xc463e0b2d4c1816242918adc2670915c16a8cd2125ae41d2b1e01696269e4219"]
         {"ApplyExtrinsic":6} : system.ExtrinsicSuccess [{"weight":10000,"class":"normal","paysFee":true}

Notice we are printing console.log('\t', phase.toString(), : ${section}.${method}, data.toString())

where {"ApplyExtrinsic":6} is the output of phase.toString() where "6" represents the index of the event - the fact that every line here outputs "6" indicates that these are indeed all the same event, which is probably not what we are expecting.

@jam10o-new
Copy link

@ninabreznik as recommended by Jaco we should probably not be reusing the same const registerSeeder = api.tx.datVerify.registerSeeder() for every call.

@jam10o-new
Copy link

  const keypairs = [ALICE, CHARLIE, DAVE, EVE, FERDIE, NEW_ACCOUNT]

  /* ------------------------------------------------------------------------

                                 EXTRINSICS

---------------------------------------------------------------------------- */

  /* -------------------------  TRANSACTIONS -------------------------------- */

  /* ---   registerSeeder()  --- */

async function registerSeederAccount(pair){
  const registerSeeder = api.tx.datVerify.registerSeeder()
  await promiseRerun(registerSeeder.signAndSend(pair, ({ events = [], status }) => {
    if (status.isFinalized) {
      events.forEach(({ phase, event: { data, method, section } }) => {
        console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString())
      })
    }
  }))
}

for(const pairIndex in keypairs){
  await registerSeederAccount(keypairs[pairIndex])
}

^^ this refactoring fixes the issue for me.

@jam10o-new
Copy link

jam10o-new commented Feb 14, 2020

Re: part 2 - I should probably also clarify that currently we don't "pin" dats (as in assign an existing hypercore to a host) unless the host explicitly asks for one to host - which means if you register_seeder and there is nothing to host, you don't emit a newPin event. This behaviour will change (you declare capacity and you get a set of hypercores under that capacity which rotate over time, you need to watch for NewPins with your address) but currently newPin is only emitted as part of register_seeder and only iff there is data preregistered and available to pin.

jam10o-new pushed a commit that referenced this issue Jun 13, 2021
* fix

* Update consensus/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>
jam10o-new pushed a commit that referenced this issue Jun 13, 2021
* fix

* Update consensus/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>
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