Skip to content

Commit

Permalink
Fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kus committed Oct 2, 2024
1 parent 9ca287b commit 3c0ad6f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Run a specific test file (or several files):
scarb test tests/data/light_481823.json
```

Show output for a specific test:

```sh
scarb test tests/data/light_481823.json --nocapture
```

Re-generate integration test data:

```sh
Expand Down
6 changes: 4 additions & 2 deletions packages/consensus/src/types/utreexo.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ pub impl UtreexoStateImpl of UtreexoStateTrait {
fn validate_and_apply(
ref self: UtreexoState, utxo_set: UtxoSet, proofs: Span<UtreexoProof>
) -> Result<(), ByteArray> {
let mut lead_idx = 0;
let mut proof_idx = 0;
let mut inner_result = Result::Ok(());

for leaf_hash in utxo_set
.leaves_to_delete {
let proof = proofs[lead_idx];
let proof = proofs[proof_idx];

let res = self.verify(leaf_hash, proof);
if res.is_err() {
Expand All @@ -67,7 +67,9 @@ pub impl UtreexoStateImpl of UtreexoStateTrait {
}

self.delete(proof);
proof_idx += 1;
};

inner_result?;

for leaf_hash in utxo_set.leaves_to_add {
Expand Down
4 changes: 2 additions & 2 deletions scripts/data/generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def generate_data(
:param mode: Validation mode:
"light" — generate block headers with Merkle root only
"full, full_fast" — generate full blocks with transactions (and referenced UTXOs)
"full" — generate full blocks with transactions (and referenced UTXOs)
"utreexo" — only last block from the batch is included, but it is extended with Utreexo state/proofs
:param initial_height: The block height of the initial chain state (0 means the state after genesis)
:param num_blocks: The number of blocks to apply on top of it (has to be at least 1)
Expand Down Expand Up @@ -419,7 +419,7 @@ def str2bool(value):
"--mode",
dest="mode",
default="full",
choices=["light", "full"],
choices=["light", "full", "utreexo"],
help="Mode",
)

Expand Down
4 changes: 2 additions & 2 deletions scripts/data/regenerate_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ generate_test() {
local num_blocks=${3:-1}
test_file="${data_dir}/${mode}_${test_case}.json"
if [[ ! -f "$test_file" || $force -eq 1 ]]; then
python ../../scripts/data/generate_data.py $mode $height $num_blocks $test_file
python ../../scripts/data/generate_data.py --mode $mode --height $height --num_blocks $num_blocks --output_file $test_file
fi
}

Expand All @@ -67,7 +67,7 @@ done

for test_case in "${full_test_cases[@]}"; do
echo "Generating test data: full mode, chain state @ $test_case, single block"
generate_test "full_fast" $test_case
generate_test "full" $test_case
done

for test_case in "${utreexo_test_cases[@]}"; do
Expand Down

0 comments on commit 3c0ad6f

Please sign in to comment.