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

Flexible provenance tracking for state commitments #3527

Merged
merged 10 commits into from
Dec 19, 2023
Merged

Conversation

hdevalence
Copy link
Member

Closes #3349

This PR removes the previous NoteSource, a stuffed transaction hash, with
a new, extensible CommitmentSource, and makes managing commitment sources the
responsibility of the SCT component that manages state commitments. This
allows several important use cases:

  • We can track provenance of funds as they enter the chain, by recording the
    sender address, packet number, and channel for NotePayloads created by the
    ICS20 handler. This is particularly important because there is no "transaction"
    to download to fetch extended information there.

  • Clients have an easier time deciding whether they need to do an extended
    fetch of block data, they just need to see if any detected payload was from a
    Transaction source.

  • We can save space in the compact block by "dehydrating" the transaction
    sources and removing the transaction hashes. Clients already have to fetch
    a full block's worth of transactions, because nullifiers don't have source info
    attached, so we gain nothing by including detailed source info in the CompactBlock.

  • Clients have an easier time working with Penumbra data, since there's no more
    ad-hoc stuffing.

In addition, it does various other cleanup along the way.

This puts management of the compact block where it belongs, in the compact block crate.
This allows the compact block handling to be folded into the top-level
application crate. It was only being used for gas scheduling, but that can just
as easily be a set of constants instead.
This commit removes the previous `NoteSource`, a stuffed transaction hash, with
a new, extensible `CommitmentSource`, and makes managing commitment sources the
responsibility of the SCT component that manages state commitments.  This
allows several important use cases:

- We can track provenance of funds as they enter the chain, by recording the
  sender address, packet number, and channel for `NotePayloads` created by the
  ICS20 handler. This is particularly important because there is no "transaction"
  to download to fetch extended information there.

- Clients have an easier time deciding whether they need to do an extended
  fetch of block data, they just need to see if any detected payload was from a
  `Transaction` source.

- We can save space in the compact block by "dehydrating" the transaction
  sources and removing the transaction hashes.  Clients _already_ have to fetch
  a full block's worth of transactions, because nullifiers don't have source info
  attached, so we gain nothing by including detailed source info in the `CompactBlock`.

- Clients have an easier time working with Penumbra data, since there's no more
  ad-hoc stuffing.
Since any kind of state fragment can be nullified, this should be the
responsibility of the SCT component, not the shielded pool.
Replicating all the type parameters everywhere is quite dangerous, since if any
of them are mistyped, the query will silently fail.
Comment on lines -16 to -25
/// Queries the state commitment tree's block anchor for a given height.
BlockAnchor {
/// The height to query.
height: u64,
},
/// Queries the state commitment tree's epoch anchor for a given epoch index.
EpochAnchor {
/// The epoch to query.
epoch: u64,
},
Copy link
Member Author

Choose a reason for hiding this comment

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

This is functionality that should really be part of an indexer / explorer, rather than asking every full node to keep the data around in case someone wants to run this command against a random fullnode.

Comment on lines +149 to +153

state_tx
.finish_block(state_tx.app_params_updated())
.await
.expect("must be able to finish compact block");
Copy link
Member Author

Choose a reason for hiding this comment

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

Finishing the compact block is now the responsibility of the compact block component.

@@ -60,6 +62,7 @@ async fn spend_happy_path() -> anyhow::Result<()> {
spend.check_stateless(transaction_context).await?;
spend.check_stateful(state.clone()).await?;
let mut state_tx = state.try_begin_transaction().unwrap();
state_tx.put_mock_source(1u8);
Copy link
Member Author

Choose a reason for hiding this comment

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

This has to be inserted now that the SCT logic tracks provenance, otherwise execution will fail, because in the mock setting, we're only running a single action in isolation, which wouldn't pick up the transaction-level source setting.

@hdevalence
Copy link
Member Author

hdevalence commented Dec 19, 2023

Demo of this support in pcli:

 Account  Value              Source
 # 0      10000000gm         Genesis
 # 0      10000000test_btc   Genesis
 # 0      10000000test_usd   Genesis
 # 0      10000000cube       Genesis
 # 0      10000000test_osmo  Genesis
 # 0      10000000pizza      Genesis
 # 0      10000000test_eth   Genesis
 # 0      10000000test_atom  Genesis
 # 0      100000penumbra     Tx 45e4416093f08a112fbab72812a954e91064d9e898f1c2c4a018b2fcca21dcf3
 # 0      9870000penumbra    Tx eb56f4748a49c8846c228be80f92933e532b7c1c747adbfb446872473aa3946a
 # 0      10000000gn         Genesis
 # 1      10000penumbra      Tx a58084bb9ca58723fecd3d5bb35dbde8e05771a064e148650b269e134081b46b
 # 1      10000penumbra      Tx e7239198053283808822ff3aafc7affe8719048bb910f1fa429c29a541faeaf8
 # 1      10000penumbra      Tx eb56f4748a49c8846c228be80f92933e532b7c1c747adbfb446872473aa3946a

@hdevalence hdevalence merged commit 51cf205 into main Dec 19, 2023
5 checks passed
@hdevalence hdevalence deleted the provenance branch December 19, 2023 09:04
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

Successfully merging this pull request may close these issues.

Provenance Tracking
1 participant