-
Notifications
You must be signed in to change notification settings - Fork 49
feat(drive-abci): add shielded pool drive-abci integration (medusa part 3) #3220
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
24 commits
Select commit
Hold shift + click to select a range
ed3a886
feat(drive-abci): add shielded pool drive-abci integration
QuantumExplorer 4e84d4f
fix(drive-abci): fix shielded test compilation and proof verification…
QuantumExplorer c9a74f7
chore(drive-abci): cargo fmt
QuantumExplorer cfa16af
refactor(drive): remove unused PenalizeShieldedPoolAction
QuantumExplorer 1771400
fix(drive-abci): gate shielded basic_structure validation on platform…
QuantumExplorer 75f5650
docs(drive-abci): explain why ShieldFromAssetLock skips early proof v…
QuantumExplorer c1de6f0
Merge branch 'v3.1-dev' into feat/zk-drive-abci
QuantumExplorer f104242
fix(drive-abci): audit fixes for shielded pool integration
QuantumExplorer fe0697e
fix(drive): adapt proof verification for shielded pool tree structure…
QuantumExplorer 1486922
fix(drive-abci): address CodeRabbit review comments
QuantumExplorer db74541
refactor(drive): store anchors as key with O(1) lookup and dedicated …
QuantumExplorer b17ad9e
feat(drive): add anchors-by-height reverse index tree for pruning sup…
QuantumExplorer d1297b7
feat(drive-abci): prune shielded pool anchors older than 1000 blocks
QuantumExplorer 22354c0
perf(drive-abci): only prune shielded anchors every 100 blocks
QuantumExplorer 2b93bd4
fix(drive-abci): reject zero value_balance in shielded transfer and a…
QuantumExplorer 1518d6a
docs(drive-abci): update audit findings statuses and clarify strategy…
QuantumExplorer 738b243
fix(drive-abci): fix CI failures - formatting, clippy, and drive init…
QuantumExplorer 5712538
refactor(drive-abci): rename err to consensus_error in transform_into…
QuantumExplorer e0a8c54
Merge branch 'v3.1-dev' into feat/zk-drive-abci
QuantumExplorer f7fb180
refactor(drive-abci): extract anchor pruning interval to version field
QuantumExplorer 001b40f
Merge branch 'v3.1-dev' into feat/zk-drive-abci
QuantumExplorer 5d1a593
refactor(drive): extract shielded pool GroveDB operations into Drive …
QuantumExplorer af1fb34
fix(wasm-dpp2): replace missing impl_wasm_conversions with impl_wasm_…
QuantumExplorer 8e6764c
chore(drive-abci): comment out shielded strategy tests temporarily
QuantumExplorer 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
2 changes: 2 additions & 0 deletions
2
packages/rs-drive-abci/src/execution/platform_events/block_processing_end_events/mod.rs
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,5 +1,7 @@ | ||
| mod add_process_epoch_change_operations; | ||
| pub mod process_block_fees_and_validate_sum_trees; | ||
| mod prune_shielded_pool_anchors; | ||
| mod record_shielded_pool_anchor; | ||
|
|
||
| #[cfg(test)] | ||
| mod tests; |
38 changes: 38 additions & 0 deletions
38
.../execution/platform_events/block_processing_end_events/prune_shielded_pool_anchors/mod.rs
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,38 @@ | ||
| mod v0; | ||
|
|
||
| use crate::error::execution::ExecutionError; | ||
| use crate::error::Error; | ||
| use crate::platform_types::platform::Platform; | ||
| use crate::rpc::core::CoreRPCLike; | ||
| use dpp::version::PlatformVersion; | ||
| use drive::grovedb::Transaction; | ||
|
|
||
| impl<C> Platform<C> | ||
| where | ||
| C: CoreRPCLike, | ||
| { | ||
| /// Prunes shielded pool anchors older than the configured retention depth. | ||
| pub(in crate::execution) fn prune_shielded_pool_anchors( | ||
| &self, | ||
| block_height: u64, | ||
| transaction: &Transaction, | ||
| platform_version: &PlatformVersion, | ||
| ) -> Result<(), Error> { | ||
| match platform_version | ||
| .drive_abci | ||
| .methods | ||
| .block_end | ||
| .prune_shielded_pool_anchors | ||
| { | ||
| None => Ok(()), | ||
| Some(0) => { | ||
| self.prune_shielded_pool_anchors_v0(block_height, transaction, platform_version) | ||
| } | ||
| Some(version) => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { | ||
| method: "prune_shielded_pool_anchors".to_string(), | ||
| known_versions: vec![0], | ||
| received: version, | ||
| })), | ||
| } | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
...ecution/platform_events/block_processing_end_events/prune_shielded_pool_anchors/v0/mod.rs
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,44 @@ | ||
| use crate::error::Error; | ||
| use crate::platform_types::platform::Platform; | ||
| use crate::rpc::core::CoreRPCLike; | ||
| use dpp::version::PlatformVersion; | ||
| use drive::grovedb::Transaction; | ||
|
|
||
| impl<C> Platform<C> | ||
| where | ||
| C: CoreRPCLike, | ||
| { | ||
| /// Prunes anchors older than `shielded_anchor_retention_blocks` from the current height. | ||
| /// | ||
| /// Checks interval and retention depth conditions, then delegates to | ||
| /// `Drive::prune_shielded_pool_anchors` for the actual GroveDB operations. | ||
| pub(super) fn prune_shielded_pool_anchors_v0( | ||
| &self, | ||
| block_height: u64, | ||
| transaction: &Transaction, | ||
| platform_version: &PlatformVersion, | ||
| ) -> Result<(), Error> { | ||
| let event_constants = &platform_version | ||
| .drive_abci | ||
| .validation_and_processing | ||
| .event_constants; | ||
| let retention_blocks = event_constants.shielded_anchor_retention_blocks; | ||
| let pruning_interval = event_constants.shielded_anchor_pruning_interval; | ||
|
|
||
| // Only prune every N blocks to avoid unnecessary work | ||
| if !block_height.is_multiple_of(pruning_interval) { | ||
| return Ok(()); | ||
| } | ||
|
|
||
| // Nothing to prune if we haven't reached the retention depth yet | ||
| if block_height <= retention_blocks { | ||
| return Ok(()); | ||
| } | ||
|
|
||
| let cutoff_height = block_height - retention_blocks; | ||
|
|
||
| self.drive | ||
| .prune_shielded_pool_anchors(cutoff_height, transaction, platform_version) | ||
| .map_err(Error::Drive) | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
.../execution/platform_events/block_processing_end_events/record_shielded_pool_anchor/mod.rs
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,40 @@ | ||
| mod v0; | ||
|
|
||
| use crate::error::execution::ExecutionError; | ||
| use crate::error::Error; | ||
| use crate::platform_types::platform::Platform; | ||
| use crate::rpc::core::CoreRPCLike; | ||
| use dpp::version::PlatformVersion; | ||
| use drive::grovedb::Transaction; | ||
|
|
||
| impl<C> Platform<C> | ||
| where | ||
| C: CoreRPCLike, | ||
| { | ||
| /// Records the current shielded pool anchor if the commitment tree changed this block. | ||
| pub(in crate::execution) fn record_shielded_pool_anchor_if_changed( | ||
| &self, | ||
| block_height: u64, | ||
| transaction: &Transaction, | ||
| platform_version: &PlatformVersion, | ||
| ) -> Result<(), Error> { | ||
| match platform_version | ||
| .drive_abci | ||
| .methods | ||
| .block_end | ||
| .record_shielded_pool_anchor | ||
| { | ||
| None => Ok(()), | ||
| Some(0) => self.record_shielded_pool_anchor_if_changed_v0( | ||
| block_height, | ||
| transaction, | ||
| platform_version, | ||
| ), | ||
| Some(version) => Err(Error::Execution(ExecutionError::UnknownVersionMismatch { | ||
| method: "record_shielded_pool_anchor_if_changed".to_string(), | ||
| known_versions: vec![0], | ||
| received: version, | ||
| })), | ||
| } | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
...ecution/platform_events/block_processing_end_events/record_shielded_pool_anchor/v0/mod.rs
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,27 @@ | ||
| use crate::error::Error; | ||
| use crate::platform_types::platform::Platform; | ||
| use crate::rpc::core::CoreRPCLike; | ||
| use dpp::version::PlatformVersion; | ||
| use drive::grovedb::Transaction; | ||
|
|
||
| impl<C> Platform<C> | ||
| where | ||
| C: CoreRPCLike, | ||
| { | ||
| /// Records the current shielded pool anchor if the commitment tree changed this block. | ||
| /// | ||
| /// Delegates to `Drive::record_shielded_pool_anchor_if_changed` which handles | ||
| /// all GroveDB operations: reading the current and most recent anchors, and | ||
| /// conditionally writing to the anchors tree, anchors-by-height tree, and | ||
| /// most recent anchor item. | ||
| pub(super) fn record_shielded_pool_anchor_if_changed_v0( | ||
| &self, | ||
| block_height: u64, | ||
| transaction: &Transaction, | ||
| platform_version: &PlatformVersion, | ||
| ) -> Result<(), Error> { | ||
| self.drive | ||
| .record_shielded_pool_anchor_if_changed(block_height, transaction, platform_version) | ||
| .map_err(Error::Drive) | ||
| } | ||
| } |
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.
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.