-
Notifications
You must be signed in to change notification settings - Fork 116
feat: compute account delta commitment before fee #1705
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f0a73d9
feat: Compute account delta commitment before fee
PhilippGackstatter 3daa551
feat: remove and add fee from delta for commitment computation
PhilippGackstatter 0ae5880
chore: add changelog
PhilippGackstatter 6f40c26
fix: rustfmt
PhilippGackstatter 1d0ec9d
chore: update bench-tx
PhilippGackstatter 5d08334
chore: add note on `TxAccountUpdate::account_delta_commitment`
PhilippGackstatter 2463377
chore: rerun `bench-tx` after merging `next`
PhilippGackstatter a895d04
Merge remote-tracking branch 'origin/next' into pgackst-compute-delta…
PhilippGackstatter 7d8d6ee
feat: Introduce helper function for pre fee commitment computation
PhilippGackstatter 66edcdb
chore: Clarify proven tx delta commitment comment
PhilippGackstatter 9846ffa
chore: add comment in executor
PhilippGackstatter a350070
chore: Rerun tx bench
PhilippGackstatter db64df6
Merge remote-tracking branch 'origin/next' into pgackst-compute-delta…
PhilippGackstatter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,23 @@ | ||
| { | ||
| "simple": { | ||
| "prologue": 4167, | ||
| "notes_processing": 2540, | ||
| "prologue": 4178, | ||
| "notes_processing": 2624, | ||
| "note_execution": { | ||
| "0x7fe47b84889353de93aea4bfeaa8da5da0036ea7a84dfc5ff5765ec51440896f": 1266, | ||
| "0xbf1c92f4f0b35b51d3f3e8f7ba19abf7718a7e087627df0d17987af8a1cb872a": 1233 | ||
| "0x2a96867a0f22d54d1e3530c074c3ad9ba9542b5060edf2f8398202f5d2e3f557": 1308, | ||
| "0xc52584ba513fd5eaaec47234263a1b20ce4d848488430e577dbdd6d9254d5bae": 1275 | ||
| }, | ||
| "tx_script_processing": 45, | ||
| "epilogue": 1525, | ||
| "after_compute_fee_cycles": 1143 | ||
| "tx_script_processing": 39, | ||
| "epilogue": 2368, | ||
| "after_tx_cycles_obtained": 1205 | ||
| }, | ||
| "p2id": { | ||
| "prologue": 2755, | ||
| "notes_processing": 1572, | ||
| "prologue": 2779, | ||
| "notes_processing": 1653, | ||
| "note_execution": { | ||
| "0x7ff44c53fefcd88ee714511b6d2976189549fec4b26695ee5e2b5293f50a845a": 1539 | ||
| "0xb3044cb915c500d7678047e7f6cdfc9581efd8ebd07ff1977ef86f7072c51463": 1620 | ||
| }, | ||
| "tx_script_processing": 45, | ||
| "epilogue": 62233, | ||
| "after_compute_fee_cycles": 891 | ||
| "tx_script_processing": 39, | ||
| "epilogue": 63153, | ||
| "after_tx_cycles_obtained": 1187 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| use anyhow::Context; | ||
| use miden_objects::asset::FungibleAsset; | ||
| use miden_objects::{self, Felt, Word}; | ||
| use miden_testing::{Auth, MockChain}; | ||
|
|
||
| use crate::prove_and_verify_transaction; | ||
|
|
||
| // FEE TESTS | ||
| // ================================================================================================ | ||
|
|
||
| /// Tests that a simple account can be created with non-zero fees and the transaction can be proven | ||
| /// and verified. | ||
| /// | ||
| /// This is an interesting test case because the prover needs to apply the fee asset to the account | ||
| /// delta in order to prove the correct delta commitment. Once we have other tests with fees, this | ||
| /// test may become obsolete. | ||
| #[test] | ||
| fn prove_account_creation_with_fees() -> anyhow::Result<()> { | ||
| let amount = 10_000; | ||
| let mut builder = MockChain::builder().verification_base_fee(50); | ||
| let account = builder.create_new_wallet(Auth::IncrNonce)?; | ||
| let fee_note = builder.add_p2id_note_with_fee(account.id(), amount)?; | ||
| let chain = builder.build()?; | ||
|
|
||
| let tx = chain | ||
| .build_tx_context(account, &[fee_note.id()], &[])? | ||
| .build()? | ||
| .execute_blocking() | ||
| .context("failed to execute account-creating transaction")?; | ||
|
|
||
| let expected_fee = tx.compute_fee(); | ||
| assert_eq!(expected_fee, tx.fee().amount()); | ||
|
|
||
| // We expect that the new account contains the amount minus the paid fee. | ||
| let added_asset = FungibleAsset::new(chain.native_asset_id(), amount)?.sub(tx.fee())?; | ||
|
|
||
| assert_eq!(tx.account_delta().nonce_delta(), Felt::new(1)); | ||
| // except for the nonce, the storage delta should be empty | ||
| assert!(tx.account_delta().storage().is_empty()); | ||
| assert_eq!(tx.account_delta().vault().added_assets().count(), 1); | ||
| assert_eq!(tx.account_delta().vault().removed_assets().count(), 0); | ||
| assert_eq!(tx.account_delta().vault().added_assets().next().unwrap(), added_asset.into()); | ||
| assert_eq!(tx.final_account().nonce(), Felt::new(1)); | ||
| // account commitment should not be the empty word | ||
| assert_ne!(tx.account_delta().to_commitment(), Word::empty()); | ||
|
|
||
| prove_and_verify_transaction(tx)?; | ||
|
|
||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| mod faucet; | ||
| mod fee; | ||
| mod p2id; | ||
| mod p2ide; | ||
| mod send_note; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.