Skip to content

Commit

Permalink
Merge branch 'main' into pin_in_lock
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky committed Sep 27, 2024
2 parents a615b73 + b7fbc6b commit 972884d
Show file tree
Hide file tree
Showing 21 changed files with 191 additions and 165 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/build-macos-installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
matrix:
python-version: ["3.10"]
os:
- runs-on: macos-12
- runs-on: macos-13
name: intel
bladebit-suffix: macos-x86-64.tar.gz
arch-artifact-name: intel
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
uses: Chia-Network/actions/setjobenv@main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MACOSX_DEPLOYMENT_TARGET: 12
MACOSX_DEPLOYMENT_TARGET: 13

- name: Test for secrets access
id: check_secrets
Expand Down Expand Up @@ -296,10 +296,6 @@ jobs:
fail-fast: false
matrix:
os:
- name: 12
matrix: 12
runs-on:
intel: macos-12
- name: 13
matrix: 13
runs-on:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_wheel_availability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: macOS
matrix: macos
runs-on:
intel: macos-12
intel: macos-13
arm: macos-13-arm64
- name: Windows
matrix: windows
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: macOS
matrix: macos
runs-on:
intel: macos-12
intel: macos-13
arm: macos-13-arm64
- name: Windows
matrix: windows
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-install-scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
os:
- runs-on: macos-latest
matrix: macos-arm
- runs-on: macos-12
- runs-on: macos-13
matrix: macos-intel
- runs-on: ubuntu-latest
matrix: linux
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
concurrency-name: macos-intel
configuration: ${{ needs.configure.outputs.configuration }}
matrix_mode: ${{ needs.configure.outputs.matrix_mode }}
runs-on: macos-12
runs-on: macos-13
arch: intel
macos-arm:
if: github.event_name != 'workflow_dispatch' || inputs.run-macos-arm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload-pypi-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
matrix: macos
emoji: 🍎
runs-on:
intel: macos-12
intel: macos-13
arm: macos-13-arm64
- name: Windows
matrix: windows
Expand Down
24 changes: 14 additions & 10 deletions chia/_tests/clvm/test_program.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import pytest
from chia_rs import ENABLE_FIXED_DIV
from clvm.EvalError import EvalError
from clvm.operators import KEYWORD_TO_ATOM
from clvm_tools.binutils import assemble, disassemble
Expand Down Expand Up @@ -120,27 +119,32 @@ def test_run() -> None:
assert ret.atom == bytes([0xFE])

# run()
with pytest.raises(ValueError, match="div operator with negative operands is deprecated"):
cost, ret = div.run_with_cost(100000, [10, -5], 0)
cost, ret = div.run_with_cost(100000, [10, -5], 0)
assert cost == 1107
print(ret)
assert ret.atom == bytes([0xFE])

cost, ret = div.run_with_cost(100000, [10, -5], ENABLE_FIXED_DIV)
cost, ret = div.run_with_cost(100000, [10, -5], 0)
assert cost == 1107
print(ret)
assert ret.atom == bytes([0xFE])

# run_with_flags()
with pytest.raises(ValueError, match="div operator with negative operands is deprecated"):
cost, ret = div.run_with_flags(100000, 0, [10, -5])
cost, ret = div.run_with_flags(100000, 0, [10, -5])
assert cost == 1107
print(ret)
assert ret.atom == bytes([0xFE])

cost, ret = div.run_with_flags(100000, ENABLE_FIXED_DIV, [10, -5])
cost, ret = div.run_with_flags(100000, 0, [10, -5])
assert cost == 1107
print(ret)
assert ret.atom == bytes([0xFE])

# run_with_cost()
with pytest.raises(ValueError, match="div operator with negative operands is deprecated"):
ret = div.run([10, -5], 100000, 0)
ret = div.run([10, -5], 100000, 0)
print(ret)
assert ret.atom == bytes([0xFE])

ret = div.run([10, -5], 100000, ENABLE_FIXED_DIV)
ret = div.run([10, -5], 100000, 0)
print(ret)
assert ret.atom == bytes([0xFE])
5 changes: 1 addition & 4 deletions chia/_tests/core/full_node/test_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,7 @@ async def test_agg_sig_infinity(
)

# infinity is disallowed after soft-fork-5 activates
if consensus_mode >= ConsensusMode.SOFT_FORK_5:
expected_error = Err.INVALID_CONDITION
else:
expected_error = None
expected_error = Err.INVALID_CONDITION
await check_conditions(bt, conditions, expected_error)

@pytest.mark.anyio
Expand Down
15 changes: 5 additions & 10 deletions chia/_tests/core/mempool/test_mempool_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
from typing import Any, Awaitable, Callable, Collection, Dict, List, Optional, Set, Tuple

import pytest
from chia_rs import ELIGIBLE_FOR_DEDUP, ELIGIBLE_FOR_FF, AugSchemeMPL, G2Element
from chia_rs import ELIGIBLE_FOR_DEDUP, ELIGIBLE_FOR_FF, AugSchemeMPL, G2Element, get_conditions_from_spendbundle
from chiabip158 import PyBIP158

from chia._tests.conftest import ConsensusMode
from chia._tests.util.misc import invariant_check_mempool
from chia._tests.util.setup_nodes import OldSimulatorsAndWallets, setup_simulators_and_wallets
from chia.consensus.constants import ConsensusConstants
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.full_node.bundle_tools import simple_solution_generator
from chia.full_node.mempool import MAX_SKIPPED_ITEMS, PRIORITY_TX_THRESHOLD
from chia.full_node.mempool_check_conditions import get_name_puzzle_conditions, mempool_check_time_locks
from chia.full_node.mempool_check_conditions import mempool_check_time_locks
from chia.full_node.mempool_manager import (
MEMPOOL_MIN_FEE_INCREASE,
QUOTE_BYTES,
Expand Down Expand Up @@ -442,16 +441,12 @@ def make_bundle_spends_map_and_fee(


def mempool_item_from_spendbundle(spend_bundle: SpendBundle) -> MempoolItem:
generator = simple_solution_generator(spend_bundle)
npc_result = get_name_puzzle_conditions(
generator=generator, max_cost=INFINITE_COST, mempool_mode=True, height=uint32(0), constants=DEFAULT_CONSTANTS
)
assert npc_result.conds is not None
bundle_coin_spends, fee = make_bundle_spends_map_and_fee(spend_bundle, npc_result.conds)
conds = get_conditions_from_spendbundle(spend_bundle, INFINITE_COST, DEFAULT_CONSTANTS, uint32(0))
bundle_coin_spends, fee = make_bundle_spends_map_and_fee(spend_bundle, conds)
return MempoolItem(
spend_bundle=spend_bundle,
fee=fee,
conds=npc_result.conds,
conds=conds,
spend_bundle_name=spend_bundle.name(),
height_added_to_mempool=TEST_HEIGHT,
bundle_coin_spends=bundle_coin_spends,
Expand Down
6 changes: 4 additions & 2 deletions chia/_tests/wallet/nft_wallet/test_nft_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,8 @@ async def test_nft_bulk_set_did(wallet_environments: WalletTestFramework) -> Non
]
fee = uint64(1000)
set_did_bulk_resp = await env.rpc_client.set_nft_did_bulk(
NFTSetDIDBulk(did_id=hmr_did_id, nft_coin_list=nft_coin_list, fee=fee, push=True)
NFTSetDIDBulk(did_id=hmr_did_id, nft_coin_list=nft_coin_list, fee=fee, push=True),
wallet_environments.tx_config,
)
assert len(set_did_bulk_resp.spend_bundle.coin_spends) == 5
assert set_did_bulk_resp.tx_num == 5 # 1 for each NFT being spent (3), 1 for fee tx, 1 for did tx
Expand Down Expand Up @@ -2031,7 +2032,8 @@ async def test_nft_bulk_transfer(wallet_environments: WalletTestFramework) -> No
fee = uint64(1000)
address = encode_puzzle_hash(await wallet_1.get_puzzle_hash(new=False), AddressType.XCH.hrp(env_1.node.config))
bulk_transfer_resp = await env_0.rpc_client.transfer_nft_bulk(
NFTTransferBulk(target_address=address, nft_coin_list=nft_coin_list, fee=fee, push=True)
NFTTransferBulk(target_address=address, nft_coin_list=nft_coin_list, fee=fee, push=True),
wallet_environments.tx_config,
)
assert len(bulk_transfer_resp.spend_bundle.coin_spends) == 4
assert bulk_transfer_resp.tx_num == 4
Expand Down
4 changes: 3 additions & 1 deletion chia/_tests/wallet/test_signer_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ async def test_p2dohp_wallet_signer_protocol(wallet_environments: WalletTestFram
)
assert derivation_record is not None
pubkey: G1Element = derivation_record.pubkey
synthetic_pubkey: G1Element = G1Element.from_bytes(puzzle.uncurry()[1].at("f").atom)
atom = puzzle.uncurry()[1].at("f").atom
assert atom is not None
synthetic_pubkey: G1Element = G1Element.from_bytes(atom)
message: bytes = delegated_puzzle_hash + coin.name() + wallet_state_manager.constants.AGG_SIG_ME_ADDITIONAL_DATA

utx: UnsignedTransaction = UnsignedTransaction(
Expand Down
13 changes: 6 additions & 7 deletions chia/consensus/block_body_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass, field
from typing import Awaitable, Callable, Collection, Dict, List, Optional, Set, Tuple, Union

from chia_rs import AugSchemeMPL, BLSCache, G1Element
from chia_rs import AugSchemeMPL, BLSCache, G1Element, SpendBundleConditions
from chiabip158 import PyBIP158

from chia.consensus.block_record import BlockRecord
Expand Down Expand Up @@ -85,7 +85,7 @@ def reset(self, fork_height: int, header_hash: bytes32) -> None:
self.removals_since_fork = {}
self.block_hashes = []

def include_spends(self, npc_result: Optional[NPCResult], block: FullBlock, header_hash: bytes32) -> None:
def include_spends(self, conds: Optional[SpendBundleConditions], block: FullBlock, header_hash: bytes32) -> None:
height = block.height

assert self.peak_height == height - 1
Expand All @@ -97,11 +97,10 @@ def include_spends(self, npc_result: Optional[NPCResult], block: FullBlock, head
self.peak_height = int(block.height)
self.peak_hash = header_hash

if npc_result is not None:
assert npc_result.conds is not None
if conds is not None:
assert block.foliage_transaction_block is not None
timestamp = block.foliage_transaction_block.timestamp
for spend in npc_result.conds.spends:
for spend in conds.spends:
self.removals_since_fork[bytes32(spend.coin_id)] = ForkRem(bytes32(spend.puzzle_hash), height)
for puzzle_hash, amount, hint in spend.create_coin:
coin = Coin(bytes32(spend.coin_id), bytes32(puzzle_hash), uint64(amount))
Expand Down Expand Up @@ -367,8 +366,8 @@ async def validate_block_body(

# 14. Check for duplicate spends inside block
removal_counter = collections.Counter(removals)
for k, v in removal_counter.items():
if v > 1:
for count in removal_counter.values():
if count > 1:
return Err.DOUBLE_SPEND, None

# 15. Check if removals exist and were not previously spent. (unspent_db + diff_store + this_block)
Expand Down
6 changes: 3 additions & 3 deletions chia/consensus/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ async def run_single_block(self, block: FullBlock, fork_info: ForkInfo) -> None:
)
assert npc.error is None

fork_info.include_spends(npc, block, block.header_hash)
fork_info.include_spends(None if npc is None else npc.conds, block, block.header_hash)

async def add_block(
self,
Expand Down Expand Up @@ -412,7 +412,7 @@ async def add_block(
# main chain, we still need to re-run it to update the additions and
# removals in fork_info.
await self.advance_fork_info(block, fork_info)
fork_info.include_spends(npc_result, block, header_hash)
fork_info.include_spends(None if npc_result is None else npc_result.conds, block, header_hash)
self.add_block_record(block_rec)
return AddBlockResult.ALREADY_HAVE_BLOCK, None, None

Expand Down Expand Up @@ -444,7 +444,7 @@ async def add_block(
# case we're validating blocks on a fork, the next block validation will
# need to know of these additions and removals. Also, _reconsider_peak()
# will need these results
fork_info.include_spends(npc_result, block, header_hash)
fork_info.include_spends(None if npc_result is None else npc_result.conds, block, header_hash)

# block_to_block_record() require the previous block in the cache
if not genesis and prev_block is not None:
Expand Down
Loading

0 comments on commit 972884d

Please sign in to comment.