-
Notifications
You must be signed in to change notification settings - Fork 44
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
Added support for on-chain (public) accounts in store #293
Conversation
# Conflicts: # .gitignore # Cargo.toml
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, left only a few nits.
b1b29e5
to
5167ec6
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
614485d
to
54d3527
Compare
54d3527
to
63160a2
Compare
Co-authored-by: Augusto Hack <[email protected]>
76504e0
to
d6b02c8
Compare
# Conflicts: # Cargo.lock # Cargo.toml # block-producer/src/block.rs # block-producer/src/block_builder/mod.rs # block-producer/src/test_utils/block.rs # block-producer/src/test_utils/proven_tx.rs # faucet/Cargo.toml # proto/src/errors.rs # store/src/db/migrations.rs # store/src/db/sql.rs # store/src/state.rs
# Conflicts: # block-producer/src/block_builder/prover/block_witness.rs # block-producer/src/test_utils/block.rs
d6b02c8
to
09987a8
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.
Looks good! Thank you! I left a few comments inline. Once these are addressed, we can merge.
store/src/db/sql.rs
Outdated
SELECT | ||
account_id, account_hash, block_num | ||
account_id, | ||
account_hash, | ||
block_num, | ||
details |
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 is probably fine for now, but this function is used to build a sync_state
response where account details are not needed. So, we are doing potentially quite a bit of extra work here by fetching details from the database and parsing them.
Let's create an issue to address this in the future.
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 refactored this, now there are two different structures (AccountHashUpdate
is reused), so details aren't provided here anymore.
# Conflicts: # Cargo.lock # block-producer/src/block_builder/prover/tests.rs # block-producer/src/block_builder/tests.rs # block-producer/src/test_utils/account.rs # store/src/db/tests.rs
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.
Thank you! I know this PR is already merged - but I left a few comments. We can discuss/address these on Monday.
message AccountHashUpdate { | ||
account.AccountId account_id = 1; | ||
digest.Digest account_hash = 2; | ||
fixed32 block_num = 3; | ||
uint32 block_num = 3; | ||
} | ||
|
||
message AccountInfo { | ||
AccountHashUpdate update = 1; | ||
optional bytes details = 2; | ||
} |
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.
account.AccountId
can be just AccountId
- right?
Also, I wonder if this is the best naming. Specifically, AccountHashUpdate
seems a bit confusing. Maybe the following would be better?
message AccountSummary {
AccountId account_id = 1;
digest.Digest account_hash = 2;
uint32 block_num = 3;
}
message AccountDetails {
AccountSummary summary = 1;
optional bytes details = 2;
}
Or we can even expand the details like so:
message AccountDetails {
AccountId account_id = 1;
digest.Digest account_hash = 2;
uint32 block_num = 3;
optional bytes details = 4;
}
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.
We already have AccountDetails
structure in miden-objects, maybe need to end up with different name.
* `account`: `AccountInfo` – account state information. For public accounts there is also details describing current state, stored on-chain; | ||
for private accounts only hash of the latest known state is returned. |
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.
nit: I would write this as:
account
:AccountDetails
- latest state of the account. For public accounts, this will include full details describing the current account state. For private accounts, only the hash of the latest state and the time of the last update is returned.
Also, we usually don't do manual line breaks in markdown files.
* `account`: `AccountInfo` – account state information. For public accounts there is also details describing current state, stored on-chain; | ||
for private accounts only hash of the latest known state is returned. |
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.
Similar comment as above.
* feat: add `account_details` table to the DB * refactor: rename `block_number` column in nullifiers table to `block_num` * refactor: use `BETWEEN` in interval comparison checks * feat: implement account details protobuf messages, domain objects and conversions * feat: (WIP) implement account details support * feat: (WIP) implement account details support * feat: (WIP) implement account details support * feat: (WIP) implement account details support * fix: db creation * docs: remove TODO * refactor: apply formatting * feat: implement endpoint for getting public account details * tests: add test for storage * feat: add rpc endpoint for getting account details * refactor: keep only domain object changes * fix: compilation errors * fix: use note tag conversion from `u64` * refactor: remove account details protobuf messages * fix: remove unused error invariants * refactor: introduce `UpdatedAccount` struct * fix: rollback details conversion * fix: compilation error * feat: account details in store * refactor: add constraint name for foreign key * refactor: small code improvement Co-authored-by: Augusto Hack <[email protected]> * feat: account id validation * refactor: rename `get_account_details` to `select_*` * feat: return serialized account details * feat: add requirement of account id to be public in RPC * fix: remove error message used in different PR * fix: union account details with account and process them together * docs: remove `GetAccountDetails` from README.md * fix: remove unused error invariants * fix: use `Account` instead of `AccountDetails` in store * wip * feat: implement `GetAccountDetails` endpoint * docs: document `GetAccountDetails` endpoint * refactor: simplify code, make account details optional * fix: clippy warning * fix: address review comments * fix: update code to the latest miden-base * refactor: little code improvement --------- Co-authored-by: Augusto Hack <[email protected]>
In this PR database structure updated and only read-only access is implemented. Inserting of account details into the database is implemented in the next PR with block applying.