Skip to content
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

Unit tests for hash computations #1942

Closed
kariy opened this issue May 8, 2024 · 18 comments
Closed

Unit tests for hash computations #1942

kariy opened this issue May 8, 2024 · 18 comments
Assignees
Labels
external-contributor good first issue Good for newcomers katana This issue is related to Katana

Comments

@kariy
Copy link
Member

kariy commented May 8, 2024

Write unit tests for all the hash computation functions in this module like so:

#[test]
fn test_compute_deploy_account_v1_tx_hash() {
// Starknet mainnet tx hash: https://voyager.online/tx/0x3d013d17c20a5db05d5c2e06c948a4e0bf5ea5b851b15137316533ec4788b6b
let expected_hash =
felt!("0x3d013d17c20a5db05d5c2e06c948a4e0bf5ea5b851b15137316533ec4788b6b");

The tests should use actual values from the live network (eg mainnet).

We need unit tests for:

  • DeployAccount v3
  • Declare v1,v2,v3
  • Invoke v1,v3
  • L1Handler v1
  • L1 message hash
@kariy kariy added good first issue Good for newcomers katana This issue is related to Katana labels May 8, 2024
@Jonatan-Chaverri
Copy link
Contributor

Will like to take care of this one!

@kariy
Copy link
Member Author

kariy commented May 8, 2024

Will like to take care of this one!

assigned!

@Jonatan-Chaverri
Copy link
Contributor

@kariy @glihm (or anybody who knows) I need help with this... how can I find real transactions on Voyager that match the criteria for every test? Deploy account, Declare and Invoke transactions, for v1, v2 and v3 for each... I'm I supposed to create those transactions?

@kariy
Copy link
Member Author

kariy commented Jun 2, 2024

@kariy @glihm (or anybody who knows) I need help with this... how can I find real transactions on Voyager that match the criteria for every test? Deploy account, Declare and Invoke transactions, for v1, v2 and v3 for each... I'm I supposed to create those transactions?

You can just pick any txs (of each type) on Voyager then take their hash and the tx data that are used as inputs for the tx hash computation.

For example, to compute a invoke tx hash you'd need these data:

pub fn compute_invoke_v1_tx_hash(
sender_address: FieldElement,
calldata: &[FieldElement],
max_fee: u128,
chain_id: FieldElement,
nonce: FieldElement,
is_query: bool,
) -> FieldElement {

starknet docs for extra reference: https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/transactions/

@glihm glihm changed the title [Katana] Unit tests for hash computations Unit tests for hash computations Jun 19, 2024
@g4titanx
Copy link
Contributor

hi @glihm, I would love to work on this

@kariy
Copy link
Member Author

kariy commented Jul 23, 2024

hey @Jonatan-Chaverri because there hasn't been any progress so far, i will be assigning this to @g4titanx instead.

@kariy kariy assigned g4titanx and unassigned Jonatan-Chaverri Jul 23, 2024
@Jonatan-Chaverri
Copy link
Contributor

@kariy Sure, sorry, have been busy these months with hackathons and other stuff. You can go ahead @g4titanx

@g4titanx
Copy link
Contributor

okay, thanks

@g4titanx
Copy link
Contributor

g4titanx commented Jul 26, 2024

hi @kariy do you know of a faster way to search for versions of txs on voyager? i am having zero-luck finding a v3 declare type. i mean, since it's a v3 it should be among the latest txs. but even the latest txs dont use v3

@kariy
Copy link
Member Author

kariy commented Jul 26, 2024

hi @kariy do you know of a faster way to search for versions of txs on voyager? i am having zero-luck finding a v3 declare type. i mean, since it's a v3 it should be among the latest txs. but even the latest txs dont use v3

good question, tbh im also not sure. both starkscan and voyager doesn't seem to allow filtering by tx version.

i looked around the pathfinder repo for this, and maybe we can just copy the tx data for declare v3 from them https://github.com/eqlabs/pathfinder/blob/a133f157bda062187d99129367a0b18182476470/crates/common/src/transaction.rs#L1083.

@g4titanx
Copy link
Contributor

g4titanx commented Jul 26, 2024

hi @kariy do you know of a faster way to search for versions of txs on voyager? i am having zero-luck finding a v3 declare type. i mean, since it's a v3 it should be among the latest txs. but even the latest txs dont use v3

good question, tbh im also not sure. both starkscan and voyager doesn't seem to allow filtering by tx version.

i looked around the pathfinder repo for this, and maybe we can just copy the tx data for declare v3 from them https://github.com/eqlabs/pathfinder/blob/a133f157bda062187d99129367a0b18182476470/crates/common/src/transaction.rs#L1083.

yeah, we could. i entered the hash on voyager, there is no record of it tho.
does it make sense to use that same hash?

@kariy
Copy link
Member Author

kariy commented Jul 26, 2024

hi @kariy do you know of a faster way to search for versions of txs on voyager? i am having zero-luck finding a v3 declare type. i mean, since it's a v3 it should be among the latest txs. but even the latest txs dont use v3

good question, tbh im also not sure. both starkscan and voyager doesn't seem to allow filtering by tx version.
i looked around the pathfinder repo for this, and maybe we can just copy the tx data for declare v3 from them https://github.com/eqlabs/pathfinder/blob/a133f157bda062187d99129367a0b18182476470/crates/common/src/transaction.rs#L1083.

yeah, we could. i entered the hash on voyager, there is no record of it tho.

based on the test cases, it seems to be a tx from SN_GOERLI chain (which is now deprecated). lets just use that one.

@kariy
Copy link
Member Author

kariy commented Jul 26, 2024

does it make sense to use that same hash?

we just need to use chain id for SN_GOERLI when we compute the hash

@g4titanx
Copy link
Contributor

alright then

@g4titanx
Copy link
Contributor

we just need to use chain id for SN_GOERLI when we compute the hash

how do i reference the SN_GOERLI tho, it's not part of the chain id enum here

@kariy
Copy link
Member Author

kariy commented Jul 26, 2024

we just need to use chain id for SN_GOERLI when we compute the hash

how do i reference the SN_GOERLI tho, it's not part of the chain id enum here

replied on the PR, basically lets use Katana's own type for chain id, instead of starknet-rs's.

@g4titanx
Copy link
Contributor

okay.

@kariy
Copy link
Member Author

kariy commented Jul 27, 2024

completed #2216

@kariy kariy closed this as completed Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external-contributor good first issue Good for newcomers katana This issue is related to Katana
Projects
None yet
Development

No branches or pull requests

3 participants