-
Notifications
You must be signed in to change notification settings - Fork 89
feat(validator): FPI support in data store #1493
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
Changes from 13 commits
a8902bf
dee698c
c48b3e4
0196ec3
cad2829
1b67747
ea60c4d
ac8d725
9422930
d04f329
5a89c77
b02e938
197ff32
4fb4c63
2f86074
c6130c8
f93f6c4
File filter
Filter by extension
Conversations
Jump to
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.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,7 +53,11 @@ impl DataStore for TransactionInputsDataStore { | |
| foreign_account_id: AccountId, | ||
| _ref_block: BlockNumber, | ||
| ) -> impl FutureMaybeSend<Result<AccountInputs, DataStoreError>> { | ||
| async move { Err(DataStoreError::AccountNotFound(foreign_account_id)) } | ||
| async move { | ||
| self.tx_inputs.read_foreign_account_inputs(foreign_account_id).map_err(|err| { | ||
| DataStoreError::other_with_source("failed to read foreign account inputs", err) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| fn get_vault_asset_witnesses( | ||
|
|
@@ -63,58 +67,53 @@ impl DataStore for TransactionInputsDataStore { | |
| vault_keys: BTreeSet<AssetVaultKey>, | ||
| ) -> impl FutureMaybeSend<Result<Vec<AssetWitness>, DataStoreError>> { | ||
| async move { | ||
| if self.tx_inputs.account().id() != account_id { | ||
| return Err(DataStoreError::AccountNotFound(account_id)); | ||
| } | ||
|
|
||
| if self.tx_inputs.account().vault().root() != vault_root { | ||
| return Err(DataStoreError::Other { | ||
| error_msg: "vault root mismatch".into(), | ||
| source: None, | ||
| }); | ||
| if self.tx_inputs.account().id() == account_id { | ||
| // Get asset witnessess from native account. | ||
| Result::<Vec<_>, _>::from_iter(vault_keys.into_iter().map(|vault_key| { | ||
| match self.tx_inputs.account().vault().open(vault_key) { | ||
|
||
| Ok(vault_proof) => AssetWitness::new(vault_proof.into()).map_err(|err| { | ||
| DataStoreError::other_with_source( | ||
| "failed to open vault asset tree", | ||
| err, | ||
| ) | ||
| }), | ||
| Err(err) => { | ||
| Err(DataStoreError::other_with_source("failed to open vault", err)) | ||
| }, | ||
| } | ||
| })) | ||
| } else { | ||
| // Get asset witnessess from foreign account. | ||
| self.tx_inputs | ||
| .read_vault_asset_witnesses(vault_root, vault_keys) | ||
| .map_err(|err| { | ||
| DataStoreError::other_with_source( | ||
| "failed to read vault asset witnesses", | ||
| err, | ||
| ) | ||
| }) | ||
| } | ||
|
|
||
| Result::<Vec<_>, _>::from_iter(vault_keys.into_iter().map(|vault_key| { | ||
| match self.tx_inputs.account().vault().open(vault_key) { | ||
| Ok(vault_proof) => { | ||
| AssetWitness::new(vault_proof.into()).map_err(|err| DataStoreError::Other { | ||
| error_msg: "failed to open vault asset tree".into(), | ||
| source: Some(err.into()), | ||
| }) | ||
| }, | ||
| Err(err) => Err(DataStoreError::Other { | ||
| error_msg: "failed to open vault".into(), | ||
| source: Some(err.into()), | ||
| }), | ||
| } | ||
| })) | ||
| } | ||
| } | ||
|
|
||
| fn get_storage_map_witness( | ||
| &self, | ||
| account_id: AccountId, | ||
| _account_id: AccountId, | ||
| _map_root: Word, | ||
| _map_key: Word, | ||
| ) -> impl FutureMaybeSend<Result<StorageMapWitness, DataStoreError>> { | ||
| async move { | ||
| if self.tx_inputs.account().id() != account_id { | ||
| return Err(DataStoreError::AccountNotFound(account_id)); | ||
| } | ||
|
|
||
| // For partial accounts, storage map witness is not available. | ||
| Err(DataStoreError::Other { | ||
| error_msg: "storage map witness not available with partial account state".into(), | ||
| source: None, | ||
| }) | ||
| unimplemented!( | ||
| "get_storage_map_witness is not used during re-execution of transactions" | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| fn get_note_script( | ||
| &self, | ||
| _script_root: Word, | ||
| ) -> impl FutureMaybeSend<Result<Option<NoteScript>, DataStoreError>> { | ||
| async move { Ok(None) } | ||
| async move { unimplemented!("get_note_script is not used during re-execution of transactions") } | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.