Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

blockstream state persist #3

Closed
shrugs opened this issue Apr 8, 2018 · 16 comments
Closed

blockstream state persist #3

shrugs opened this issue Apr 8, 2018 · 16 comments
Labels
gitcoin There's a Gitcoin bounty attached to this!

Comments

@shrugs
Copy link
Member

shrugs commented Apr 8, 2018

Problem

If we are following the chain but then stop processing during a short-lived fork, once we restart the process the blockstream queue will be empty so it will blindly trust that the next block it sees is the main chain because it can't do any resolution since it doesn't know the blocks before that to calculate longest chain.

Solution

When resuming from a block number n, actually import all blocks from n-10 to n and then start triggering any listeners that want info from blocks n+

@nionis
Copy link
Contributor

nionis commented Jul 24, 2018

Could we, take our latest block in the database, follow up until parent is not within the fork and continue from there?
This makes it future proof in case there are longer chains than 10 (extremely unlikely right?)

@shrugs
Copy link
Member Author

shrugs commented Jul 24, 2018

@nionis can you explain "follow up until parent is not within the fork and continue from there?" more deeply?

@nionis
Copy link
Contributor

nionis commented Jul 24, 2018

@shrugs I am not sure if I am technically correct, but when the system boots again after restart:

  • we want to resume from a block, specified either from database or in .env
  • we want to make sure block was not invalidated
  1. query eth node by block hash to check if block was invalidated (is that possible somehow?)
  2. if not invalidated continue normally | if invalided trace back the chain using parentHash until parent block is the root of the split and thus its valid, then we start from there

But I am not sure if there is an easy way to check if block was invalidated cause then blockstream would have implemented it already

edit:
as long as there is a guarantee that the short lived fork is below 10 blocks then we are way better of using initial method stated of course

@shrugs
Copy link
Member Author

shrugs commented Jul 25, 2018

It may be difficult to check if a specific block has been invalidated, I haven't tried that though.

Hmm, we may not be able to just plug-and-play the blockstream; we'll have to consolidate our own database with whatever it sees, so we'd have to be able to replace its internal blockchain with the one in the database and then run it. Hmm, this requires a bit more thought from me, code-wise, sorry.

@shrugs shrugs changed the title blockstream state persist? blockstream state persist Aug 5, 2018
@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 360.0 DAI (360.0 USD @ $1.0/DAI) attached to it.

@shrugs
Copy link
Member Author

shrugs commented Aug 9, 2018

@nionis that's yours to claim 😉

@gitcoinbot
Copy link

gitcoinbot commented Aug 10, 2018

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 11 months, 3 weeks from now.
Please review their action plans below:

  1. nionis has been approved to start work.

    I suppose what is left right now it to test the state, since the erc20 issue is unrelated with block-persist branch

Learn more on the Gitcoin Issue Details page.

@nionis
Copy link
Contributor

nionis commented Aug 10, 2018

@shrugs sweet! thanks :)

@shrugs shrugs added the gitcoin There's a Gitcoin bounty attached to this! label Aug 12, 2018
@shrugs
Copy link
Member Author

shrugs commented Aug 12, 2018

closed via #47, thanks @nionis!

@shrugs shrugs closed this as completed Aug 12, 2018
@gitcoinbot
Copy link

@nionis Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • warning (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@nionis
Copy link
Contributor

nionis commented Aug 13, 2018

@shrugs I guess this is done?

@shrugs
Copy link
Member Author

shrugs commented Aug 13, 2018

@nionis yup; I'm not the funder, though, so I gotta let vivek get around to approving it. I've dm'd him :)

@shrugs
Copy link
Member Author

shrugs commented Aug 13, 2018

@nionis actually, can you submit a PR on gitcoin or something? I haven't gone through the flow as a claimer, so idk what it's like.

@vs77bb
Copy link

vs77bb commented Aug 13, 2018

Hi @nionis can you 'Submit Work' on Gitcoin here? If you need a bit of ETH to make your first transaction, the Gitcoin Faucet can help.

From there, I'll pay out the bounty! Great work here 🙂

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 360.0 DAI (360.0 USD @ $1.0/DAI) has been submitted by:

  1. @nionis

@vs77bb please take a look at the submitted work:


@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 360.0 DAI (360.0 USD @ $1.0/DAI) attached to this issue has been approved & issued to @nionis.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
gitcoin There's a Gitcoin bounty attached to this!
Projects
None yet
Development

No branches or pull requests

4 participants