-
Notifications
You must be signed in to change notification settings - Fork 40
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
Return the list of committed transactions in state sync endpoint #377
Conversation
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.
code looks good! I left some minor questions. I'll test this against the client to have another layer of validation
.iter() | ||
.flat_map(|(&account_id, update)| { | ||
update.transactions.iter().flat_map(move |&tx| { | ||
let mut result = vec![Felt::ZERO, Felt::ZERO, Felt::ZERO, account_id.into()]; |
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.
why do we need to add the account id to the elements to hash?
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.
Please look into this issue for clarifications: 0xPolygonMiden/miden-base#722
ORDER BY | ||
transaction_id ASC |
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.
does the order by transaction id add anything? was it supposed to be ordered by block number?
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 just wanted to have reproducible results. If for client it's matter to have ordering by block number, I can change it.
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 don't think any ordering would matter for the client, but it makes sense for reproducible results.
crates/store/src/db/tests.rs
Outdated
#[test] | ||
fn test_sql_select_transactions() { | ||
fn query_transactions(conn: &mut Connection) -> Vec<RpoDigest> { | ||
sql::select_transactions_by_accounts_and_block_range(conn, 1, 2, &[1]).unwrap() | ||
} | ||
|
||
let mut conn = create_db(); | ||
|
||
let transactions = query_transactions(&mut conn); | ||
|
||
assert!(transactions.is_empty(), "No elements must be initially in the DB"); | ||
|
||
let count = insert_transactions(&mut conn); | ||
|
||
assert_eq!(count, 2, "Two elements must have been inserted"); | ||
} |
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 also query after inserting the transactions and make sure it's also 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.
Good catch, thank you! I moved query code to separated function in this matter, but forgot to query for a second time. :(
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 couple of small comments inline.
Also, I think one thing that is missing is verifying that tx_hash
is consistent with transaction info in the block during apply_block (we check that all other data in the block is consistent with the header, would be good to check that transaction data is consistent as well).
Lastly, what do you think of moving transaction IDs into AccountSummary
(something along the lines what is suggested in #371 (comment)). I don't think we should do it in this PR, but curious how much work it would be.
Oh - also, let's resolve merge conflicts and update the changelog. |
# Conflicts: # Cargo.lock # Cargo.toml # crates/store/src/state.rs
f5cf27a
to
c904c9f
Compare
I looked into the code and it seems to be pretty easy to implement this. |
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 a couple of comments (also, I wasn't sure if the AccountSummary
updates are meant to be included in this PR or a follow-up).
ORDER BY | ||
transaction_id ASC |
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 don't think any ordering would matter for the client, but it makes sense for reproducible results.
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.
One thing I noticed we might still have problems with in the client is that we're still not getting the info of when the transaction was included in a block. This is due to the fact that we return a sync state response with all nullifiers and transaction ids in the range (request.block_header, next_block_header) where block header is the block of the first note matching any of the requests' tags or account ids. So, if many TXs that only consume notes are sent and then we sync after a while, we'll still receive the TXs ids but won't know which got included in which block. A similar thing happens with nullifiers as well.
Ah - good point! We could return |
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!
Before merging this, let's do the changes I mentioned here (will require a PR in miden-base
).
In a follow-up PR we can update the structure of returned data (i.e., move transaction IDs into account summaries, return block numbers for nullifiers and transaction IDs).
also, I think after 0xPolygonMiden/miden-base#732 got merged in base it's breaking compilation, idk if we should fix it here or should I open a new PR (I still need these changes to compile the node) |
Ah, yes! @polydez could you update this PR to make sure it works with latest pub fn format_input_notes(notes: &InputNotes<InputNoteCommitment>) -> String {
format_array(notes.iter().map(|c| match c.note_id() {
Some(note_id) => format!("({}, {})", c.nullifier().to_hex(), note_id.to_hex()),
None => format!("({})", c.nullifier().to_hex()),
}))
} After this, we'll merge this PR and can address my comments from #377 (comment) in a separate PR. |
created #380. I'm open to taking it |
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've pushed a couple of small commits to point this back at next
in miden-base
and also did some minor refactoring.
Thank you! I'll assign it to you. |
Resolves: #371
Related issue: 0xPolygonMiden/miden-base#722