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

Coinbase in snark: coinbase split and no coinbase cases #1936

Merged
merged 5 commits into from Mar 28, 2019

Conversation

Projects
None yet
2 participants
@deepthiskumar
Copy link
Contributor

deepthiskumar commented Mar 19, 2019

Handles the following two cases when checking pending coinbases in blockchain snark

  1. when a coinbase is split into two parts
  2. No coinbase in a block

@deepthiskumar deepthiskumar requested a review from imeckler Mar 19, 2019

@deepthiskumar deepthiskumar changed the title handle coinbase split and no coinbase case Coinbase in snark: coinbase split and no coinbase cases Mar 19, 2019

deepthiskumar added some commits Mar 19, 2019

change unit test: when coinbase amount is less than max, two coinbase…
…s need to be added in the unchecked version
Currency.Amount.var_of_t Protocols.Coda_praos.coinbase_amount
in
let%bind rem_amount, `Underflow underflowed =
Currency.Amount.Checked.sub_flagged total_coinbase_amount amount

This comment has been minimized.

Copy link
@imeckler

imeckler Mar 26, 2019

Contributor

No need to use sub_flagged if you are going to assert there is no underflow.

let%bind amount2_equal_to_zero = equal_to_zero rem_amount in
let%bind stack_with_amount1 =
Coinbase_stack.Stack.Checked.push stack
(pk, Amount.Signed.Checked.of_unsigned amount)

This comment has been minimized.

Copy link
@imeckler

imeckler Mar 26, 2019

Contributor

There is an opportunity to save a lot of hashing here. Hashing a public key is about 1000 constraints and that could be shared between the two pushes. Maybe make an issue with an 'optimization' label

@deepthiskumar deepthiskumar merged commit 27938bc into fix/pending_coinbase Mar 28, 2019

18 checks passed

Codacy/PR Quality Review Up to standards. A positive pull request.
Details
ci/circleci: build-artifacts--testnet_postake Your tests passed on CircleCI!
Details
ci/circleci: build-artifacts--testnet_postake_snarkless_fake_hash Your tests passed on CircleCI!
Details
ci/circleci: build-wallet Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: test--fake_hash Your tests passed on CircleCI!
Details
ci/circleci: test--test_postake Your tests passed on CircleCI!
Details
ci/circleci: test--test_postake_bootstrap Your tests passed on CircleCI!
Details
ci/circleci: test--test_postake_catchup Your tests passed on CircleCI!
Details
ci/circleci: test--test_postake_five_even_snarkless Your tests passed on CircleCI!
Details
ci/circleci: test--test_postake_snarkless Your tests passed on CircleCI!
Details
ci/circleci: test--test_postake_split Your tests passed on CircleCI!
Details
ci/circleci: test--test_postake_split_snarkless Your tests passed on CircleCI!
Details
ci/circleci: test--test_postake_txns Your tests passed on CircleCI!
Details
ci/circleci: test-unit--dev Your tests passed on CircleCI!
Details
ci/circleci: test-unit--test_posig_snarkless Your tests passed on CircleCI!
Details
ci/circleci: test-unit--test_postake_snarkless Your tests passed on CircleCI!
Details
ci/circleci: tracetool Your tests passed on CircleCI!
Details

@deepthiskumar deepthiskumar deleted the fix/cb-split branch Mar 28, 2019

deepthiskumar added a commit that referenced this pull request Mar 29, 2019

coinbase check in-snark (#1663)
Implements in-SNARK check for coinbases. 
How:
1) A transaction snark now has a set of coinbases  (`Pending_coinbase.Stack`) that it includes.
2) Maintain a collection of coinbases included so far and subtract from it, the set of coinbases included in a ledger proof. This collection called `Pending coinbases` represents all the coinbases that are yet to be included in ledger proofs.
In blockchain snark, a new coinbase is added and the set of coinbases included in a ledger proof is subtracted. Also, handles the cases (#1936)
    1) when there is no coinbase included in the transition 
    2) when a coinbase is split into two parts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.