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

Use Rust version of MerkleSet #17908

Merged
merged 12 commits into from Apr 29, 2024
3 changes: 1 addition & 2 deletions chia/_tests/blockchain/test_blockchain.py
Expand Up @@ -9,7 +9,7 @@
from typing import List, Optional

import pytest
from chia_rs import AugSchemeMPL, G2Element
from chia_rs import AugSchemeMPL, G2Element, MerkleSet
from clvm.casts import int_to_bytes

from chia._tests.blockchain.blockchain_test_utils import (
Expand Down Expand Up @@ -54,7 +54,6 @@
from chia.util.generator_tools import get_block_header
from chia.util.hash import std_hash
from chia.util.ints import uint8, uint32, uint64
from chia.util.merkle_set import MerkleSet
from chia.util.misc import available_logical_cores
from chia.util.recursive_replace import recursive_replace
from chia.util.vdf_prover import get_vdf_info_and_proof
Expand Down
9 changes: 8 additions & 1 deletion chia/_tests/wallet/sync/test_wallet_sync.py
Expand Up @@ -49,6 +49,7 @@
from chia.wallet.util.wallet_types import WalletIdentifier
from chia.wallet.wallet_state_manager import WalletStateManager
from chia.wallet.wallet_weight_proof_handler import get_wp_fork_point
from chia_rs import confirm_not_included_already_hashed


async def get_tx_count(wsm: WalletStateManager, wallet_id: int) -> int:
Expand Down Expand Up @@ -536,7 +537,13 @@ async def test_request_additions_errors(simulator_and_wallet: OldSimulatorsAndWa
assert response.proofs is not None
assert len(response.proofs) == 1
assert len(response.coins) == 1

root = (await full_node_api.full_node.block_store.get_full_block(last_block.header_hash)).foliage_transaction_block.additions_root
assert confirm_not_included_already_hashed(root, response.proofs[0][0], response.proofs[0][1])
arvidn marked this conversation as resolved.
Show resolved Hide resolved
# proofs is a tuple of (puzzlehash, proof, proof_2)
# proof is a proof of inclusion (or exclusion) of that puzzlehash
# proof_2 is a proof of all the coins with that puzzlehash (all coin names are concatenated and hashed into one entry in the merkle set for this)
# the response contains the list of coins so you can check the proof_2

assert response.proofs[0][0] == std_hash(b"")
assert response.proofs[0][1] is not None
assert response.proofs[0][2] is None
Expand Down
3 changes: 1 addition & 2 deletions chia/full_node/full_node_api.py
Expand Up @@ -10,7 +10,7 @@
from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, cast

import anyio
from chia_rs import AugSchemeMPL, G1Element, G2Element
from chia_rs import AugSchemeMPL, G1Element, G2Element, MerkleSet
from chiabip158 import PyBIP158

from chia.consensus.block_creation import create_unfinished_block
Expand Down Expand Up @@ -66,7 +66,6 @@
from chia.util.hash import std_hash
from chia.util.ints import uint8, uint32, uint64, uint128
from chia.util.limited_semaphore import LimitedSemaphoreFullError
from chia.util.merkle_set import MerkleSet

if TYPE_CHECKING:
from chia.full_node.full_node import FullNode
Expand Down
3 changes: 1 addition & 2 deletions chia/wallet/util/wallet_sync_utils.py
Expand Up @@ -5,7 +5,7 @@
import random
from typing import Any, List, Optional, Set, Tuple, Union

from chia_rs import compute_merkle_set_root
from chia_rs import compute_merkle_set_root, confirm_included_already_hashed, confirm_not_included_already_hashed

from chia.full_node.full_node_api import FullNodeAPI
from chia.protocols.shared_protocol import Capability
Expand Down Expand Up @@ -36,7 +36,6 @@
from chia.types.coin_spend import CoinSpend, make_spend
from chia.types.header_block import HeaderBlock
from chia.util.ints import uint32
from chia.util.merkle_set import confirm_included_already_hashed, confirm_not_included_already_hashed
from chia.wallet.util.peer_request_cache import PeerRequestCache

log = logging.getLogger(__name__)
Expand Down