Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into quex.port_coin_cmds_t…
Browse files Browse the repository at this point in the history
…o_chia_command
  • Loading branch information
Quexington committed Dec 10, 2024
2 parents 8d92fee + 35c8375 commit 5bbc3df
Show file tree
Hide file tree
Showing 34 changed files with 283 additions and 152 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-linux-installer-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:

env:
CHIA_INSTALLER_VERSION: ${{ needs.version.outputs.chia-installer-version }}
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CHIA_BLOCKCHAIN: ${{ needs.version.outputs.chia-installer-version }}
POETRY_DYNAMIC_VERSIONING_OVERRIDE: "chia-blockchain=${{ needs.version.outputs.chia-installer-version }}"
TAG_TYPE: ${{ needs.version.outputs.tag-type }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-linux-installer-rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

env:
CHIA_INSTALLER_VERSION: ${{ needs.version.outputs.chia-installer-version }}
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CHIA_BLOCKCHAIN: ${{ needs.version.outputs.chia-installer-version }}
POETRY_DYNAMIC_VERSIONING_OVERRIDE: "chia-blockchain=${{ needs.version.outputs.chia-installer-version }}"
TAG_TYPE: ${{ needs.version.outputs.tag-type }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-macos-installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

env:
CHIA_INSTALLER_VERSION: ${{ needs.version.outputs.chia-installer-version }}
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CHIA_BLOCKCHAIN: ${{ needs.version.outputs.chia-installer-version }}
POETRY_DYNAMIC_VERSIONING_OVERRIDE: "chia-blockchain=${{ needs.version.outputs.chia-installer-version }}"
TAG_TYPE: ${{ needs.version.outputs.tag-type }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-windows-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

env:
CHIA_INSTALLER_VERSION: ${{ needs.version.outputs.chia-installer-version }}
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CHIA_BLOCKCHAIN: ${{ needs.version.outputs.chia-installer-version }}
POETRY_DYNAMIC_VERSIONING_OVERRIDE: "chia-blockchain=${{ needs.version.outputs.chia-installer-version }}"
TAG_TYPE: ${{ needs.version.outputs.tag-type }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
- name: "Dependency Review"
uses: actions/dependency-review-action@v4
with:
allow-dependencies-licenses: pkg:pypi/pyinstaller
allow-dependencies-licenses: pkg:pypi/pyinstaller, pkg:pypi/mypy
deny-licenses: AGPL-1.0-only, AGPL-1.0-or-later, AGPL-1.0-or-later, AGPL-3.0-or-later, GPL-1.0-only, GPL-1.0-or-later, GPL-2.0-only, GPL-2.0-or-later, GPL-3.0-only, GPL-3.0-or-later
2 changes: 1 addition & 1 deletion .repo-content-updater.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
var_overrides:
DEPENDABOT_ACTIONS_REVIEWERS: '["cmmarslender", "altendky"]'
DEPENDABOT_PIP_REBASE_STRATEGY: disabled
DEPENDENCY_REVIEW_ALLOW_DEPENDENCIES_LICENSES: pkg:pypi/pyinstaller, pkg:pypi/mypy
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| Releases | Repo Stats | Socials |
| ----------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [![Latest Release][badge-release]][link-latest] <br /> [![Latest RC][badge-rc]][link-release] <br /> [![Latest Beta][badge-beta]][link-release] | [![Coverage][badge-coverage]][link-coverage] <br /> [![Downloads][badge-downloads]][link-downloads] <br /> [![Commits][badge-commits]][link-commits] <br /> [![Contributers][badge-contributers]][link-contributers] | [![Discord][badge-discord]][link-discord] <br /> [![YouTube][badge-youtube]][link-youtube] <br /> [![Reddit][badge-reddit]][link-reddit] <br /> [![Twitter][badge-twitter]][link-twitter] |
| [![Latest Release][badge-release]][link-latest] <br /> [![Latest RC][badge-rc]][link-release] <br /> [![Latest Beta][badge-beta]][link-release] | [![Coverage][badge-coverage]][link-coverage] <br /> [![Downloads][badge-downloads]][link-downloads] <br /> [![Commits][badge-commits]][link-commits] <br /> [![Contributors][badge-contributors]][link-contributors] | [![Discord][badge-discord]][link-discord] <br /> [![YouTube][badge-youtube]][link-youtube] <br /> [![Reddit][badge-reddit]][link-reddit] <br /> [![Twitter][badge-twitter]][link-twitter] |

Chia is a modern cryptocurrency built from scratch, designed to be efficient, decentralized, and secure. Here are some of the features and benefits:

Expand Down Expand Up @@ -42,7 +42,7 @@ Once installed, an [Intro to Chia][link-intro] guide is available in the [Chia D
[badge-beta]: https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fdownload.chia.net%2Flatest%2Fbadge-data-beta.json&query=%24.message&logo=chianetwork&logoColor=black&label=Latest%20Beta&labelColor=%23e9fbbc&color=%231e2b2e
[badge-beta2]: https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fdownload.chia.net%2Flatest%2Fbadge-data-beta.json&query=%24.message&logo=chianetwork&logoColor=%23e9fbbc&label=Latest%20Beta&labelColor=%23474748&color=%231e2b2e&link=https%3A%2F%2Fgithub.com%2FChia-Network%2Fchia-blockchain%2Freleases&link=https%3A%2F%2Fgithub.com%2FChia-Network%2Fchia-blockchain%2Freleases
[badge-commits]: https://img.shields.io/github/commit-activity/w/Chia-Network/chia-blockchain?logo=GitHub
[badge-contributers]: https://img.shields.io/github/contributors/Chia-Network/chia-blockchain?logo=GitHub
[badge-contributors]: https://img.shields.io/github/contributors/Chia-Network/chia-blockchain?logo=GitHub
[badge-coverage]: https://img.shields.io/coverallsCoverage/github/Chia-Network/chia-blockchain?logo=Coveralls&logoColor=red&labelColor=%23212F39
[badge-discord]: https://dcbadge.vercel.app/api/server/chia?style=flat-square&theme=full-presence
[badge-discord2]: https://img.shields.io/discord/1034523881404370984.svg?label=Discord&logo=discord&colorB=1e2b2f
Expand All @@ -56,7 +56,7 @@ Once installed, an [Intro to Chia][link-intro] guide is available in the [Chia D
[link-chialisp]: https://chialisp.com/
[link-commits]: https://github.com/Chia-Network/chia-blockchain/commits/main/
[link-consensus]: https://docs.chia.net/consensus-intro/
[link-contributers]: https://github.com/Chia-Network/chia-blockchain/graphs/contributors
[link-contributors]: https://github.com/Chia-Network/chia-blockchain/graphs/contributors
[link-coverage]: https://coveralls.io/github/Chia-Network/chia-blockchain
[link-discord]: https://discord.gg/chia
[link-docs]: https://docs.chia.net/docs-home/
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The subdirectory jobs do not include the tests from their parents.

## testconfig.py

In the top tests directory, [testconfig.py](https://github.com/Chia-Network/chia-blockchain/tree/main/tests/testconfig.py)
In the top tests directory, [testconfig.py](https://github.com/Chia-Network/chia-blockchain/blob/main/chia/_tests/testconfig.py)
contains the application settings and the per-directory default settings.

## config.py
Expand Down
8 changes: 4 additions & 4 deletions chia/_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ def get_keychain():
class ConsensusMode(ComparableEnum):
PLAIN = 0
HARD_FORK_2_0 = 1
SOFT_FORK_5 = 2
SOFT_FORK_6 = 2


@pytest.fixture(
scope="session",
params=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0, ConsensusMode.SOFT_FORK_5],
params=[ConsensusMode.PLAIN, ConsensusMode.HARD_FORK_2_0, ConsensusMode.SOFT_FORK_6],
)
def consensus_mode(request):
return request.param
Expand All @@ -216,7 +216,7 @@ def blockchain_constants(consensus_mode: ConsensusMode) -> ConsensusConstants:
PLOT_FILTER_64_HEIGHT=uint32(15),
PLOT_FILTER_32_HEIGHT=uint32(20),
)
if consensus_mode >= ConsensusMode.SOFT_FORK_5:
if consensus_mode >= ConsensusMode.SOFT_FORK_6:
ret = ret.replace(
SOFT_FORK6_HEIGHT=uint32(2),
)
Expand Down Expand Up @@ -267,7 +267,7 @@ def db_version(request) -> int:
return request.param


SOFTFORK_HEIGHTS = [1000000, 5496000, 5496100, 5716000, 5940000]
SOFTFORK_HEIGHTS = [1000000, 5496000, 5496100, 5716000, 6800000]


@pytest.fixture(scope="function", params=SOFTFORK_HEIGHTS)
Expand Down
78 changes: 77 additions & 1 deletion chia/_tests/core/mempool/test_mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from typing import Callable, Optional

import pytest
from chia_rs import G1Element, G2Element
from chia_rs import G1Element, G2Element, get_flags_for_height_and_constants
from clvm.casts import int_to_bytes
from clvm_tools import binutils
from clvm_tools.binutils import assemble

from chia._tests.blockchain.blockchain_test_utils import _validate_and_add_block
from chia._tests.connection_utils import add_dummy_connection, connect_and_get_peer
Expand All @@ -28,6 +29,7 @@
from chia._tests.util.time_out_assert import time_out_assert
from chia.consensus.condition_costs import ConditionCost
from chia.consensus.cost_calculator import NPCResult
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.full_node.bitcoin_fee_estimator import create_bitcoin_fee_estimator
from chia.full_node.fee_estimation import EmptyMempoolInfo, MempoolInfo
from chia.full_node.full_node_api import FullNodeAPI
Expand Down Expand Up @@ -3186,3 +3188,77 @@ def test_get_puzzle_and_solution_for_coin_failure() -> None:
ValueError, match=f"Failed to get puzzle and solution for coin {TEST_COIN}, error: \\('coin not found', '80'\\)"
):
get_puzzle_and_solution_for_coin(BlockGenerator(SerializedProgram.to(None), []), TEST_COIN, 0, test_constants)


# TODO: import this from chia_rs once we bump the version we depend on
ENABLE_KECCAK = 0x200
ENABLE_KECCAK_OPS_OUTSIDE_GUARD = 0x100


def test_flags_for_height() -> None:
# the keccak operator is supposed to be enabled at soft-fork 6 height
flags = get_flags_for_height_and_constants(DEFAULT_CONSTANTS.SOFT_FORK6_HEIGHT, DEFAULT_CONSTANTS)
print(f"{flags:x}")
assert (flags & ENABLE_KECCAK) != 0

flags = get_flags_for_height_and_constants(DEFAULT_CONSTANTS.SOFT_FORK6_HEIGHT - 1, DEFAULT_CONSTANTS)
print(f"{flags:x}")
assert (flags & ENABLE_KECCAK) == 0


def test_keccak() -> None:
# the keccak operator is 62. The assemble() function doesn't support it
# (yet)

# keccak256 is available when the softfork has activated
keccak_prg = Program.to(
assemble(
"(softfork (q . 1134) (q . 1) (q a (i "
"(= "
'(62 (q . "foobar"))'
"(q . 0x38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e))"
"(q . 0) (q x)) (q . ())) (q . ()))"
)
)

cost, ret = keccak_prg.run_with_flags(1215, ENABLE_KECCAK, [])
assert cost == 1215
assert ret.atom == b""

# keccak is ignored when the softfork has not activated
cost, ret = keccak_prg.run_with_flags(1215, 0, [])
assert cost == 1215
assert ret.atom == b""

# make sure keccak is actually executed, by comparing with the wrong output
keccak_prg = Program.to(
assemble(
"(softfork (q . 1134) (q . 1) (q a (i "
'(= (62 (q . "foobar")) '
"(q . 0x58d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e))"
"(q . 0) (q x)) (q . ())) (q . ()))"
)
)
with pytest.raises(ValueError, match="clvm raise"):
keccak_prg.run_with_flags(1215, ENABLE_KECCAK, [])

# keccak is ignored when the softfork has not activated
cost, ret = keccak_prg.run_with_flags(1215, 0, [])
assert cost == 1215
assert ret.atom == b""

# === HARD FORK ===
# new operators *outside* the softfork guard
# keccak256 is available outside the guard with the appropriate flag
keccak_prg = Program.to(
assemble(
"(a (i (= "
'(62 (q . "foobar")) '
"(q . 0x38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e)) "
"(q . 0) (q x)) (q . ()))"
)
)

cost, ret = keccak_prg.run_with_flags(994, ENABLE_KECCAK | ENABLE_KECCAK_OPS_OUTSIDE_GUARD, [])
assert cost == 994
assert ret.atom == b""
12 changes: 7 additions & 5 deletions chia/_tests/environments/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from chia.simulator.full_node_simulator import FullNodeSimulator
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.util.ints import uint32, uint64
from chia.wallet.transaction_record import TransactionRecord
from chia.wallet.transaction_record import LightTransactionRecord
from chia.wallet.util.transaction_type import CLAWBACK_INCOMING_TRANSACTION_TYPES
from chia.wallet.util.tx_config import DEFAULT_TX_CONFIG, TXConfig
from chia.wallet.wallet import Wallet
Expand Down Expand Up @@ -264,9 +264,9 @@ async def change_balances(self, update_dictionary: dict[Union[int, str], dict[st

async def wait_for_transactions_to_settle(
self, full_node_api: FullNodeSimulator, _exclude_from_mempool_check: list[bytes32] = []
) -> list[TransactionRecord]:
) -> list[LightTransactionRecord]:
# Gather all pending transactions
pending_txs: list[TransactionRecord] = await self.wallet_state_manager.tx_store.get_all_unconfirmed()
pending_txs: list[LightTransactionRecord] = await self.wallet_state_manager.tx_store.get_all_unconfirmed()
# Filter clawback txs
pending_txs = [
tx
Expand Down Expand Up @@ -357,7 +357,7 @@ async def process_pending_states(
ph_indexes[wallet_id] = await env.wallet_state_manager.puzzle_store.get_unused_count(wallet_id)
puzzle_hash_indexes.append(ph_indexes)

pending_txs: list[list[TransactionRecord]] = []
pending_txs: list[list[LightTransactionRecord]] = []
peak = self.full_node.full_node.blockchain.get_peak_height()
assert peak is not None
# Check balances prior to block
Expand Down Expand Up @@ -413,7 +413,9 @@ async def process_pending_states(
try:
await self.full_node.check_transactions_confirmed(env.wallet_state_manager, txs)
except TimeoutError: # pragma: no cover
unconfirmed: list[TransactionRecord] = await env.wallet_state_manager.tx_store.get_all_unconfirmed()
unconfirmed: list[
LightTransactionRecord
] = await env.wallet_state_manager.tx_store.get_all_unconfirmed()
raise TimeoutError(
f"ENV-{i} TXs not confirmed: {[tx.to_json_dict() for tx in unconfirmed if tx in txs]}"
)
Expand Down
4 changes: 1 addition & 3 deletions chia/_tests/util/full_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from chia.types.full_block import FullBlock
from chia.types.peer_info import PeerInfo
from chia.types.validation_state import ValidationState
from chia.util.augmented_chain import AugmentedBlockchain
from chia.util.config import load_config
from chia.util.ints import uint16

Expand Down Expand Up @@ -212,8 +211,7 @@ async def run_sync_test(
)
fork_height = block_batch[0].height - 1
header_hash = block_batch[0].prev_header_hash
success, summary, _err = await full_node.add_block_batch(
AugmentedBlockchain(full_node.blockchain),
success, summary = await full_node.add_block_batch(
block_batch,
peer_info,
ForkInfo(fork_height, fork_height, header_hash),
Expand Down
2 changes: 2 additions & 0 deletions chia/_tests/util/gen_ssl_certs.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def patched_write_ssl_cert_and_key(cert_path: Path, cert_data: bytes, key_path:
ca_crt = chia_ca_crt if cert_type == "public" else private_ca_crt
ca_key = chia_ca_key if cert_type == "public" else private_ca_key

assert ca_crt is not None
assert ca_key is not None
generate_ca_signed_cert(ca_crt, ca_key, Path(crt), Path(key))

patch.undo()
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/util/test_replace_str_to_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
MAX_GENERATOR_SIZE=uint32(1000000),
MAX_GENERATOR_REF_LIST_SIZE=uint32(512),
POOL_SUB_SLOT_ITERS=uint64(37600000000),
SOFT_FORK6_HEIGHT=uint32(9999999),
SOFT_FORK6_HEIGHT=uint32(6800000),
HARD_FORK_HEIGHT=uint32(5496000),
PLOT_FILTER_128_HEIGHT=uint32(10542000),
PLOT_FILTER_64_HEIGHT=uint32(15592000),
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/util/test_testnet_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_testnet11() -> None:
overrides: dict[str, Any] = {}
update_testnet_overrides("testnet11", overrides)
assert overrides == {
"SOFT_FORK6_HEIGHT": 9999999,
"SOFT_FORK6_HEIGHT": 2000000,
}


Expand Down
7 changes: 6 additions & 1 deletion chia/_tests/wallet/dao_wallet/test_dao_wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2694,7 +2694,12 @@ async def test_dao_cat_exits(
dao_id_0 = dao_wallet_res_0.wallet_id
cat_wallet_0 = wallet_node_0.wallet_state_manager.wallets[dao_wallet_res_0.cat_wallet_id]
dao_cat_wallet_0 = wallet_node_0.wallet_state_manager.wallets[dao_wallet_res_0.dao_cat_wallet_id]
txs = await wallet_0.wallet_state_manager.tx_store.get_all_unconfirmed()
ltxs = await wallet_0.wallet_state_manager.tx_store.get_all_unconfirmed()
txs: list[TransactionRecord] = []
for ltx in ltxs:
tx = await wallet_0.wallet_state_manager.tx_store.get_transaction_record(ltx.name)
assert tx is not None
txs.append(tx)
await full_node_api.wait_transaction_records_entered_mempool(records=txs, timeout=60)
await full_node_api.process_transaction_records(records=txs, timeout=60)
await full_node_api.process_all_wallet_transactions(wallet_0, 60)
Expand Down
3 changes: 0 additions & 3 deletions chia/_tests/wallet/sync/test_wallet_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
from chia.types.full_block import FullBlock
from chia.types.peer_info import PeerInfo
from chia.types.validation_state import ValidationState
from chia.util.augmented_chain import AugmentedBlockchain
from chia.util.hash import std_hash
from chia.util.ints import uint32, uint64, uint128
from chia.wallet.nft_wallet.nft_wallet import NFTWallet
Expand Down Expand Up @@ -361,7 +360,6 @@ async def test_long_sync_wallet(
)
fork_height = blocks_reorg[-num_blocks - 10].height - 1
await full_node.add_block_batch(
AugmentedBlockchain(full_node.blockchain),
blocks_reorg[-num_blocks - 10 : -1],
PeerInfo("0.0.0.0", 0),
ForkInfo(fork_height, fork_height, blocks_reorg[-num_blocks - 10].prev_header_hash),
Expand Down Expand Up @@ -490,7 +488,6 @@ async def test_wallet_reorg_get_coinbase(
full_node.constants, True, block_record, full_node.blockchain
)
await full_node.add_block_batch(
AugmentedBlockchain(full_node.blockchain),
blocks_reorg_2[-44:],
PeerInfo("0.0.0.0", 0),
ForkInfo(blocks_reorg_2[-45].height, blocks_reorg_2[-45].height, blocks_reorg_2[-45].header_hash),
Expand Down
10 changes: 7 additions & 3 deletions chia/_tests/wallet/test_transaction_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
from chia.wallet.transaction_record import TransactionRecord, TransactionRecordOld, minimum_send_attempts
from chia.wallet.util.query_filter import TransactionTypeFilter
from chia.wallet.util.transaction_type import TransactionType
from chia.wallet.wallet_transaction_store import WalletTransactionStore, filter_ok_mempool_status
from chia.wallet.wallet_transaction_store import (
WalletTransactionStore,
filter_ok_mempool_status,
get_light_transaction_record,
)

module_seeded_random = random.Random()
module_seeded_random.seed(a=0, version=2)
Expand Down Expand Up @@ -252,8 +256,8 @@ async def test_get_all_unconfirmed(seeded_random: random.Random) -> None:
)
await store.add_transaction_record(tr1)
await store.add_transaction_record(tr2)

assert await store.get_all_unconfirmed() == [tr1]
all_unconfirmed = await store.get_all_unconfirmed()
assert all_unconfirmed == [get_light_transaction_record(tr1)]


@pytest.mark.anyio
Expand Down
Loading

0 comments on commit 5bbc3df

Please sign in to comment.