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

match out-of-snark and in-snark account-timing updates #5937

Merged
merged 4 commits into from
Sep 15, 2020

Conversation

deepthiskumar
Copy link
Member

@deepthiskumar deepthiskumar commented Sep 14, 2020

Outside snark, the timing field is updated only for accounts whose balance is deducted (when we check if the account still maintains a min balance). In transaction snark this wasn't true for coinbase and fee transfer, where the coinbase/fee receiver account's timing field was getting set to Untimed when the tokens were unlocked.
Changed the out-of-snark behaviour to update the timing of fee transfer/coinbase accounts that is encoded as fee_payer or source account in a transaction to avoid checks in the snark

Checklist:

  • Document code purpose, how to use it
    • Mention expected invariants, implicit constraints
  • Tests were added for the new behavior
    • Document test purpose, significance of failures
    • Test names should reflect their purpose
  • All tests pass (CI will check this if you didn't)
  • Serialized types are in stable-versioned modules
  • Does this close issues? List them:

@deepthiskumar deepthiskumar requested a review from a team as a code owner September 14, 2020 22:47
~txn_amount ~txn_global_slot)
in
(* Like receiver account in payments, coinbase fee transfer account or other fee transfer account don't have the timing field updated *)
Account_timing.if_ is_coinbase_or_fee_transfer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if_ call is rather expensive. Can we rework this to change the non-snark logic instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we update both accounts in coinbase and fee transfers (otherwise it seems inconsistent) then there will still be an if_ call when we update the receiver timing (if user command then don't update the timing). An alternative would be to just update all the accounts' timing field for every type of transaction (stake delegation, receiver account in payments, coinbase, and fee transfer)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would be to just update all the accounts' timing field for every type of transaction (stake delegation, receiver account in payments, coinbase, and fee transfer)

This is definitely my preferred solution. This should already be the case for all user commands, it should just be coinbases and fee transfers that need updating in transaction_logic.ml and sparse_ledger.ml.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For user commands, we currently don't update the receiver account's timing (receiver in payments and delegate in stake delegations). i'll change that as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrmr1993 Would checking the timing for receiver account be cheaper than the two if_ calls though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the receiver account timing to be updated? I don't think we ever reduce the balance for the receiver account, so I would have thought the timing isn't relevant, unless I'm missing some nuance.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we don't reduce the balance for coinbase and fee transfer accounts either. But the way we encode those as fee_payer and receiver, we either update both or none otherwise it is inconsistent. Like, one of the fee transfers in a fee transfer transaction has the timing updated but not the other

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In those cases, I had leant on the side of doing what's cheapest in the snark. It seems correct to me to either update the timing or not when we're not decreasing the balance of an account. Since we always re-check the timing whenever it's relevant, it should make no practical difference.

I propose changing the non-snark logic to match the existing snark behaviour, and that we live with the small inconsistency around the receiver account not getting it's timing re-normalised.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, makes sense in the interest of not increasing the proving time whenever possible

@netlify
Copy link

netlify bot commented Sep 14, 2020

Preview:

Built with commit eb0b7e9

https://deploy-preview-5937--o1website2.netlify.app

@deepthiskumar deepthiskumar added the ci-build-me Add this label to trigger a circle+buildkite build for this branch label Sep 15, 2020
Copy link
Member

@mrmr1993 mrmr1993 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@deepthiskumar deepthiskumar added the ready-to-merge Adding this label will trigger mergify and trigger CI to run and merge the PR label Sep 15, 2020
@mergify mergify bot merged commit e026054 into develop Sep 15, 2020
@mergify mergify bot deleted the fix/locked-coinbase-accounts branch September 15, 2020 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-build-me Add this label to trigger a circle+buildkite build for this branch ready-to-merge Adding this label will trigger mergify and trigger CI to run and merge the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants