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

Add rollback support to accountant #84

Closed
garious opened this issue Mar 28, 2018 · 4 comments
Closed

Add rollback support to accountant #84

garious opened this issue Mar 28, 2018 · 4 comments
Assignees

Comments

@garious
Copy link
Contributor

garious commented Mar 28, 2018

First some background. The accountant currently maintains two hash tables, a map of public keys to balances, and a map of pending transaction IDs (signatures) to spending plans:

pub struct Accountant {
    balances: HashMap<PublicKey, i64>,
    pending: HashMap<Signature, Plan>,
}

When a new transaction enters the system, here's what happens:

  1. The from balance is updated (balances[txn.from] -= txn.tokens)
  2. The transaction is placed in the pending map and will wait for any witnesses its spending plan requires.

Once the it has the needed witnesses and the spending plan is reduced to a Payment, it is removed from the map and balances is updated (balances[payment.to] += payment.tokens).

The problem here is that we're making updates to both balances and pending before the transaction has been finalized. Instead, the Accountant state should be broken up into at least two pieces, a finalized state and at least one unverified block state. Note this is the first time we've used the term block. It means, "a set of transactions that are verified together." Also, we say "at least" so that the leader can optimistically start work on a second unverified block while the first has been submitted for verification. In fact, depending on how long verification takes, it's not unreasonable to imagine the Accountant maintaining a long queue of unverified blocks.

Once a block has been verified by at least 2/3 of the verifiers, the block state should be merged into the finalized state. We say the block state is coalesced. The reason to coalesce is to save memory and redundant computation, and it can only be done after the block has been finalized.

So what does it mean to support rollback? At a high-level, it means the system state rolls back to an earlier point in time. In this architecture, it means that unverified blocks and associated state are simply discarded and never coalesced.

@garious garious added this to the v0.5.0 milestone Mar 28, 2018
@garious garious self-assigned this Mar 28, 2018
garious added a commit that referenced this issue Mar 29, 2018
Diagram for what's described in #84 for rollback support.
@garious
Copy link
Contributor Author

garious commented Mar 29, 2018

consensus

@garious garious removed this from the v0.5.0 milestone Apr 12, 2018
@garious garious added this to the v0.6.0 milestone Apr 26, 2018
@garious garious modified the milestones: v0.6.0, v0.7.0 May 22, 2018
@garious garious removed this from the v0.7.0 milestone Jun 5, 2018
@garious
Copy link
Contributor Author

garious commented Jun 5, 2018

Removed the v0.7.0 milestone because we came up with a simpler, albeit slower, mechanism for rollback described in #310. We can revisit this one a little later.

@mvines mvines added this to the The Future! milestone Sep 5, 2018
@garious garious assigned rob-solana and unassigned garious Oct 31, 2018
@garious garious modified the milestones: The Future!, v0.11 Tabletops Oct 31, 2018
@garious
Copy link
Contributor Author

garious commented Oct 31, 2018

@rob-solana, this was the old ticket for rollback. Feel free to close it if it's now a duplicate.

@rob-solana
Copy link
Contributor

wow! blast from the past. covered in #1426

vkomenda pushed a commit to vkomenda/solana that referenced this issue Aug 29, 2021
* Remove initialize signers

* update js to do initialize atomically
wen-coding pushed a commit to wen-coding/solana that referenced this issue Mar 15, 2024
segfaultdoc pushed a commit to jito-labs/solana that referenced this issue Aug 7, 2024
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

3 participants