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

change: Track the balance of the deferred chain value pool #8729

Merged
merged 64 commits into from
Aug 5, 2024

Conversation

upbqdn
Copy link
Member

@upbqdn upbqdn commented Jul 29, 2024

Motivation

Close #8688.

Depends-On: #8694.

Solution

There are two main changes in this PR:

  • Calculate and store deferred value balances for each block in the non-finalized state, and
  • track the total amount of the deferred chain value pool in the finalized state.

This PR also bumps the major database format version.

High-level Description

  • The amount of the deferred balance per block is calculated in zebra-consensus during the semantic validation of both checkpointed and non-checkpointed blocks.
  • The deferred balances are passed to zebra-state in the validated blocks.
  • The balances are added to the chain value pool of each chain in the non-finalized state upon committing the block, and subtracted upon removing the block.
  • Zebra stores the balances of individual blocks in the non-finalized state but doesn't do so in the finalized one. It only tracks the total amount in the deferred chain value pool of the tip of the finalized state by adding the deferred balances to the pool upon committing blocks coming from the non-finalized state. Therefore, retrieving the deferred values for individual blocks from the finalized state doesn't currently work. If we ever need this functionality, I think it will be better to calculate it dynamically based on height and network.
  • The ValueBalance struct has a new field, so it has a new serialization format for storing the struct in the database. This new format is backward-compatible but not forward-compatible with the currently supported Zebra versions, so this PR bumps the major database format version from 25.3.0 to 26.0.0.

Tests

Current tests should suffice.

PR Author's Checklist

  • The PR name will make sense to users.
  • The PR provides a CHANGELOG summary.
  • The solution is tested.
  • The documentation is up to date.
  • The PR has a priority label.

PR Reviewer's Checklist

  • The PR Author's checklist is complete.
  • The PR resolves the issue.

arya2 and others added 30 commits July 25, 2024 16:46
…tructs, splits them into pre/post NU6 funding streams, and adds them as a field on `testnet::Parameters`
…onversion logic with constraints.

Minor refactors
…red Testnets, but that being okay since configured testnet parameters are checked when they're being built
…ams, updates the `miner_fees_are_valid()` and `subsidy_is_valid()` functions to check that the deferred pool contribution is valid and that there are no unclaimed block subsidies after NU6 activation, and adds some TODOs
…too, adds Mainnet/Testnet NU6 activation heights, fixes lints/compilation issue
…est_funding_stream_values()` to use a configured testnet with the post-NU6 Mainnet funding streams height range
Base automatically changed from deferred-pool to main August 1, 2024 23:22
@oxarbitrage
Copy link
Contributor

Can we rebase to get rid of extra commits ?

@arya2
Copy link
Contributor

arya2 commented Aug 5, 2024

Can we rebase to get rid of extra commits ?

I'd prefer that we avoid a rebase since there would be a lot of major conflicts with a relatively high chance of one being resolved incorrectly. We could try squashing the changes? (Though I think this is fine as-is).

@arya2
Copy link
Contributor

arya2 commented Aug 5, 2024

Thank you for this change!

The full sync on Mainnet with almost all of the changes succeeded here, and we just checked that the Testnet sync passed as well in GCP (though Github is having trouble updating the test's status).

It looks like the full sync tests that are still pending in Github aren't required for merging into the main branch anyway, so this should merge soon.

@mergify mergify bot merged commit 82ded59 into main Aug 5, 2024
121 of 123 checks passed
@mergify mergify bot deleted the update-value-balance branch August 5, 2024 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-state Area: State / database changes NU-6 Network Upgrade: NU6 specific tasks P-Medium ⚡ rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add lockbox pool in zebra-state
4 participants