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

Transactions from an invalid block should be put back into the backlog #193

Closed
r-marques opened this issue Apr 20, 2016 · 2 comments
Closed
Assignees

Comments

@r-marques
Copy link
Contributor

When a block is marked invalid the transactions in the block need to be re-assigned and put back into the backlog.

The difficult part is to decide which node should do it. A simple solution would be to have a changefeed listening to updates on the bigchain table (the only updates permitted should be appending new votes) and everytime a new vote comes in we check if a majority decision was reached. If so and if the decision is invalid put the transactions back into the backlog. Since the primary key in the backlog table is the id of the transaction even if several nodes try to do this at the same time there will be no duplicated transactions in the backlog.

@rhsimplex
Copy link
Contributor

Ok, trying to get some understanding here. It seems the functions involved from core.py is write_vote.
write_vote occasionally looks up a block by primary key, and appends a new vote to the votes field at that record.

So the changefeed will look something like

feed = r.table('bigchain').filter(r.row['votes']).changes().run(self.conn)

Which I suppose will go somewhere in processes.py (somewhere in the map_bigchain function)? When a majority invalid vote happens (btw, how does bigchain know what a majority is...from the number of keys?) then all transactions are put back into q_new_transactions or inserted directly? I think inserted directly. The question is where does the function which does that go...in block.py?

Do the votes currently trigger anything at all? It looks like the votes get written but are never used again, correct?

Finally, should an invalidated block be deleted once all of its transactions are liquidated?

@r-marques
Copy link
Contributor Author

So the changefeed will look something like

feed = r.table('bigchain').filter(r.row['votes']).changes().run(self.conn)

Which I suppose will go somewhere in processes.py (somewhere in the map_bigchain function)?

We can use the already existing changefeed r.table('bigchain').changes().run(b.conn) and just act on updates assuming that the only updates in bigchain table will be new votes.
You can put the new_val in a queue and then create a process that will read from the queue, check if the block was decided invalid and if so write the transactions back to the backlog using write_transactions in every transaction in the block.

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

4 participants