dojo icon indicating copy to clipboard operation
dojo copied to clipboard

[Katana] Unit tests for hash computations

Open kariy opened this issue 1 year ago • 2 comments

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

https://github.com/dojoengine/dojo/blob/5a7ecd8624a235c2b4e365d73612a952c0611716/crates/katana/primitives/src/utils/transaction.rs#L318-L323

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 avatar May 08 '24 17:05 kariy

Will like to take care of this one!

Jonatan-Chaverri avatar May 08 '24 21:05 Jonatan-Chaverri

Will like to take care of this one!

assigned!

kariy avatar May 08 '24 21:05 kariy

@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?

Jonatan-Chaverri avatar Jun 02 '24 01:06 Jonatan-Chaverri

@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:

https://github.com/dojoengine/dojo/blob/5a7ecd8624a235c2b4e365d73612a952c0611716/crates/katana/primitives/src/utils/transaction.rs#L187-L194

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

kariy avatar Jun 02 '24 04:06 kariy

hi @glihm, I would love to work on this

g4titanx avatar Jul 23 '24 09:07 g4titanx

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

kariy avatar Jul 23 '24 20:07 kariy

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

Jonatan-Chaverri avatar Jul 23 '24 21:07 Jonatan-Chaverri

okay, thanks

g4titanx avatar Jul 24 '24 16:07 g4titanx

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

g4titanx avatar Jul 26 '24 11:07 g4titanx

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.

kariy avatar Jul 26 '24 14:07 kariy

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?

g4titanx avatar Jul 26 '24 14:07 g4titanx

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 avatar Jul 26 '24 14:07 kariy

does it make sense to use that same hash?

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

kariy avatar Jul 26 '24 14:07 kariy

alright then

g4titanx avatar Jul 26 '24 14:07 g4titanx

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

g4titanx avatar Jul 26 '24 14:07 g4titanx

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.

kariy avatar Jul 26 '24 15:07 kariy

okay.

g4titanx avatar Jul 26 '24 15:07 g4titanx

completed #2216

kariy avatar Jul 27 '24 21:07 kariy