-
Notifications
You must be signed in to change notification settings - Fork 37
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
feat: Add account details endpoint #248
feat: Add account details endpoint #248
Conversation
27288fc
to
eaa7dd6
Compare
Now during the state sync we check the updated account hashes for onchain accoints. if they don't match, then we fetch the current state from the node. The old validation for offchain accounts is left unchanged but I refactored it so the logic looks similar to the one for onchain accoints. I also left a few TODO's and panics that'll be removed in follow-up commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments for now, please disregard if you were already planning changes for any of them (since it's still a draft)
src/client/sync.rs
Outdated
let updated_onchain_accounts = self | ||
.get_updated_onchain_accounts(&response.account_hash_updates, &onchain_accounts) | ||
.await?; | ||
self.check_local_account_hashes(&response.account_hash_updates, &offchain_accounts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's take the opportunity of the refactor to rename this to validate_local_account_hashes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I would leave the comment that was taken out (or something similar that takes your changes into account)
eaa7dd6
to
8d9c31d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Fixed the CI issue I believe seems I didn't. I left some comments which should be simple to address, but in any case they can be deferred to a follow up PR or issue.
There are also a couple of TODO
s that need addressing but I'm guessing those were planned
NonFungibleFaucet, | ||
NonFungibleFaucet { | ||
#[clap(short, long, value_enum, default_value_t = AccountStorageMode::OffChain)] | ||
storage_mode: AccountStorageMode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can add this to the AccountCmd::New
since it's common to all variants.
pub enum AccountStorageMode { | ||
OffChain, | ||
OnChain, | ||
} | ||
|
||
impl From<AccountStorageMode> for accounts::AccountStorageMode { | ||
fn from(value: AccountStorageMode) -> Self { | ||
match value { | ||
AccountStorageMode::OffChain => accounts::AccountStorageMode::Local, | ||
AccountStorageMode::OnChain => accounts::AccountStorageMode::OnChain, | ||
} | ||
} | ||
} | ||
|
||
impl From<&AccountStorageMode> for accounts::AccountStorageMode { | ||
fn from(value: &AccountStorageMode) -> Self { | ||
accounts::AccountStorageMode::from(*value) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a TODO
to review these struct's names (and maybe the local
vs offchain
terms)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! added it here and in the client/accounts.rs one
src/client/rpc/tonic_client.rs
Outdated
&mut self, | ||
account_id: AccountId, | ||
) -> Result<Option<Account>, NodeRpcClientError> { | ||
debug_assert!(account_id.is_on_chain()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be an error instead of a panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed!
src/client/rpc/mod.rs
Outdated
async fn get_account_update( | ||
&mut self, | ||
account_id: AccountId, | ||
) -> Result<Option<Account>, NodeRpcClientError>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the return type should be Account
instead of Option<Account>
for this. I believe the node will return an error if the account is not found so an Account
is always expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went for Option since it's what the response comes with so I expected that there will eventually be some use for the summary but no details case. In any way we can take another look at it in the future and keep it simple for now
* feat: add GetAccountDetails endpoint to tonic rpc client * feat: update CLI to provide account storage mode as cli args * feat: handle updated onchain accounts during sync and refactor Now during the state sync we check the updated account hashes for onchain accoints. if they don't match, then we fetch the current state from the node. The old validation for offchain accounts is left unchanged but I refactored it so the logic looks similar to the one for onchain accoints. I also left a few TODO's and panics that'll be removed in follow-up commits. * use updated create_basic_wallet and faucet * use next for miden node proto * update order of create_basic_fungible_faucet * add small integration test for onchain accounts transactions * address comments * add missing sync * fix: read Account instead of AccountDetails from get_account_details response * remove dbg statement * re-enable other integration tests * extend mint integration test to reuse same on-chain account in two clients * Test fix * Test fix * Test fix * Update Makefile.toml * address review * extend onchain integration test to do transfer between accounts * update missing documentation * fix test * Follow ups * Stop test execution before transfer We stop the onchain accounts test before running the p2id transaction because there's an error on how inputs are inserted/extracted on the vm, so until that gets fixed we'll leave the test code but do an early return so the test still passes. * add rpc endpoints to trait functions' documentation * split test helper in two functions * fix tests * Update main.rs * dep version * re-add assert * remove unnecessary sleeps --------- Co-authored-by: Ignacio Amigo <ignacio.amigo@lambdaclass.com>
* Use next branches * Fix integration test build (still doesnt work accordingly) * Fix advice inputs? * Fix and fmt * Update script * Update script properly * fix integration test * point to next instead of custom branch * fix falcon seed size * update note script root * temp: clone the node on next branch * run tests in parallel * Fix path creation * Fix tests and small refactors * test * Fix tests's account id * Several refactors after updates * Tests fix * Mint script fix * Fix integration * Make compatible with newer ref * Fix test * feat: Add account details endpoint (#248) * feat: add GetAccountDetails endpoint to tonic rpc client * feat: update CLI to provide account storage mode as cli args * feat: handle updated onchain accounts during sync and refactor Now during the state sync we check the updated account hashes for onchain accoints. if they don't match, then we fetch the current state from the node. The old validation for offchain accounts is left unchanged but I refactored it so the logic looks similar to the one for onchain accoints. I also left a few TODO's and panics that'll be removed in follow-up commits. * use updated create_basic_wallet and faucet * use next for miden node proto * update order of create_basic_fungible_faucet * add small integration test for onchain accounts transactions * address comments * add missing sync * fix: read Account instead of AccountDetails from get_account_details response * remove dbg statement * re-enable other integration tests * extend mint integration test to reuse same on-chain account in two clients * Test fix * Test fix * Test fix * Update Makefile.toml * address review * fix compilation errors * add onchain accounts to docs --------- Co-authored-by: Ignacio Amigo <ignacio.amigo@lambdaclass.com> * feat: Implement `GetNotesById` RPC endpoint (#247) * On-chain note support. * Merge conflicts * Fixes * Update main.rs * Update sync.rs * Use correct dependencies * Remove underscore * Follow ups * Docs and fixes * doc&refactor: missing changes from #248 (#249) * feat: add GetAccountDetails endpoint to tonic rpc client * feat: update CLI to provide account storage mode as cli args * feat: handle updated onchain accounts during sync and refactor Now during the state sync we check the updated account hashes for onchain accoints. if they don't match, then we fetch the current state from the node. The old validation for offchain accounts is left unchanged but I refactored it so the logic looks similar to the one for onchain accoints. I also left a few TODO's and panics that'll be removed in follow-up commits. * use updated create_basic_wallet and faucet * use next for miden node proto * update order of create_basic_fungible_faucet * add small integration test for onchain accounts transactions * address comments * add missing sync * fix: read Account instead of AccountDetails from get_account_details response * remove dbg statement * re-enable other integration tests * extend mint integration test to reuse same on-chain account in two clients * Test fix * Test fix * Test fix * Update Makefile.toml * address review * extend onchain integration test to do transfer between accounts * update missing documentation * fix test * Follow ups * Stop test execution before transfer We stop the onchain accounts test before running the p2id transaction because there's an error on how inputs are inserted/extracted on the vm, so until that gets fixed we'll leave the test code but do an early return so the test still passes. * add rpc endpoints to trait functions' documentation * split test helper in two functions * fix tests * Update main.rs * dep version * re-add assert * remove unnecessary sleeps --------- Co-authored-by: Ignacio Amigo <ignacio.amigo@lambdaclass.com> * Cargo toml * Address reviews --------- Co-authored-by: Martin Fraga <martin.fraga@lambdaclass.com> Co-authored-by: Martin Fraga <fragamartine@gmail.com>
* Use next branches * Fix integration test build (still doesnt work accordingly) * Fix advice inputs? * Fix and fmt * Update script * Update script properly * fix integration test * point to next instead of custom branch * fix falcon seed size * update note script root * temp: clone the node on next branch * run tests in parallel * Fix path creation * Fix tests and small refactors * test * Fix tests's account id * Several refactors after updates * Tests fix * Mint script fix * Fix integration * Make compatible with newer ref * Fix test * feat: Add account details endpoint (#248) * feat: add GetAccountDetails endpoint to tonic rpc client * feat: update CLI to provide account storage mode as cli args * feat: handle updated onchain accounts during sync and refactor Now during the state sync we check the updated account hashes for onchain accoints. if they don't match, then we fetch the current state from the node. The old validation for offchain accounts is left unchanged but I refactored it so the logic looks similar to the one for onchain accoints. I also left a few TODO's and panics that'll be removed in follow-up commits. * use updated create_basic_wallet and faucet * use next for miden node proto * update order of create_basic_fungible_faucet * add small integration test for onchain accounts transactions * address comments * add missing sync * fix: read Account instead of AccountDetails from get_account_details response * remove dbg statement * re-enable other integration tests * extend mint integration test to reuse same on-chain account in two clients * Test fix * Test fix * Test fix * Update Makefile.toml * address review * fix compilation errors * add onchain accounts to docs --------- Co-authored-by: Ignacio Amigo <ignacio.amigo@lambdaclass.com> * feat: Implement `GetNotesById` RPC endpoint (#247) * On-chain note support. * Merge conflicts * Fixes * Update main.rs * Update sync.rs * Use correct dependencies * Remove underscore * Follow ups * Docs and fixes * doc&refactor: missing changes from #248 (#249) * feat: add GetAccountDetails endpoint to tonic rpc client * feat: update CLI to provide account storage mode as cli args * feat: handle updated onchain accounts during sync and refactor Now during the state sync we check the updated account hashes for onchain accoints. if they don't match, then we fetch the current state from the node. The old validation for offchain accounts is left unchanged but I refactored it so the logic looks similar to the one for onchain accoints. I also left a few TODO's and panics that'll be removed in follow-up commits. * use updated create_basic_wallet and faucet * use next for miden node proto * update order of create_basic_fungible_faucet * add small integration test for onchain accounts transactions * address comments * add missing sync * fix: read Account instead of AccountDetails from get_account_details response * remove dbg statement * re-enable other integration tests * extend mint integration test to reuse same on-chain account in two clients * Test fix * Test fix * Test fix * Update Makefile.toml * address review * extend onchain integration test to do transfer between accounts * update missing documentation * fix test * Follow ups * Stop test execution before transfer We stop the onchain accounts test before running the p2id transaction because there's an error on how inputs are inserted/extracted on the vm, so until that gets fixed we'll leave the test code but do an early return so the test still passes. * add rpc endpoints to trait functions' documentation * split test helper in two functions * fix tests * Update main.rs * dep version * re-add assert * remove unnecessary sleeps --------- Co-authored-by: Ignacio Amigo <ignacio.amigo@lambdaclass.com> * Cargo toml * Address reviews --------- Co-authored-by: Martin Fraga <martin.fraga@lambdaclass.com> Co-authored-by: Martin Fraga <fragamartine@gmail.com>
This PR introduces a few things:
account new
command,--storage-mode=onchain,offchain(default)
that enables the creation of onchain accountsget_account_updates
trait function. This function takes an account ID and fetches theGetAccountDetails
endpoint on the node added on #294 from miden-node (and previous PRs)get_account_updates
function to fetch the most up to date account