Skip to content

Commit 6b3841b

Browse files
committed
Merge branch 'main' into farmer_solver_networking
2 parents 9b18601 + ebf8105 commit 6b3841b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+731
-438
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,11 @@ jobs:
185185
collect-junit: false
186186

187187
coverage:
188-
if: github.repository_owner == 'Chia-Network'
188+
if: always() && github.repository_owner == 'Chia-Network'
189189
name: ${{ matrix.os.emoji }} Coverage - ${{ matrix.python.name }}
190190
runs-on: ${{ matrix.os.runs-on }}
191191
needs:
192+
- configure
192193
- macos-intel
193194
- macos-arm
194195
- ubuntu
@@ -209,6 +210,12 @@ jobs:
209210
matrix: "3.10"
210211

211212
steps:
213+
- uses: re-actors/alls-green@release/v1.2
214+
id: alls-green
215+
with:
216+
allowed-skips: ${{ needs.configure.outputs.mac_intel != 'true' && 'macos-intel' || '' }}
217+
jobs: ${{ toJSON(needs) }}
218+
212219
- uses: actions/checkout@v5
213220
with:
214221
fetch-depth: 0
@@ -265,13 +272,13 @@ jobs:
265272
- uses: chia-network/actions/activate-venv@main
266273

267274
- name: Add time out assert results to workflow summary
268-
if: always() && false
275+
if: always() && steps.alls-green.outputs.success == 'true' && false
269276
run: |
270277
python -m chia._tests.process_junit --limit 50 --type time_out_assert --xml junit-results/junit.xml --markdown --link-prefix ${{ github.event.repository.html_url }}/blob/${{ github.sha }}/ --link-line-separator \#L >> "$GITHUB_STEP_SUMMARY"
271278
python -m chia._tests.process_junit --type time_out_assert --xml junit-results/junit.xml --markdown --link-prefix ${{ github.event.repository.html_url }}/blob/${{ github.sha }}/ --link-line-separator \#L >> junit-results/time_out_assert.md
272279
273280
- name: Publish JUnit results
274-
if: always() && false
281+
if: always() && steps.alls-green.outputs.success == 'true' && false
275282
uses: actions/upload-artifact@v4
276283
with:
277284
name: junit-results
@@ -285,18 +292,18 @@ jobs:
285292
coverage html --rcfile=.coveragerc --data-file=coverage-reports/.coverage --directory coverage-reports/html/
286293
287294
- uses: coverallsapp/github-action@v2
288-
if: always()
295+
if: always() && steps.alls-green.outputs.success == 'true'
289296
env:
290297
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
291298

292299
- name: Coverage report (chia/)
293-
if: always()
300+
if: always() && steps.alls-green.outputs.success == 'true'
294301
run: |
295302
set -o pipefail
296303
coverage report --rcfile=.coveragerc --data-file=coverage-reports/.coverage --include='chia/**/*' --omit='chia/_tests/**/*' --show-missing | tee coverage-reports/coverage-chia-stdout
297304
298305
- name: Coverage report (chia/_tests/)
299-
if: always()
306+
if: always() && steps.alls-green.outputs.success == 'true'
300307
run: |
301308
set -o pipefail
302309
coverage report --rcfile=.coveragerc --data-file=coverage-reports/.coverage --include='chia/_tests/**/*' --show-missing | tee coverage-reports/coverage-tests-stdout
@@ -307,7 +314,7 @@ jobs:
307314
echo "hash=$(git rev-parse HEAD~1)" >> "$GITHUB_OUTPUT"
308315
309316
- name: Coverage report (diff)
310-
if: (github.base_ref != '' || github.event.before != '') && always()
317+
if: (github.base_ref != '' || github.event.before != '') && always() && steps.alls-green.outputs.success == 'true'
311318
env:
312319
compare-branch: ${{ github.base_ref == '' && steps.parent-commit.outputs.hash || format('origin/{0}', github.base_ref) }}
313320
run: |
@@ -320,7 +327,7 @@ jobs:
320327
fi
321328
322329
- name: Remove previous coverage report comment and label from PR
323-
if: github.base_ref != '' && always()
330+
if: github.base_ref != '' && always() && steps.alls-green.outputs.success == 'true'
324331
shell: bash
325332
env:
326333
COV_STATUS: ${{ env.COV_STATUS }}
@@ -341,7 +348,7 @@ jobs:
341348
fi
342349
343350
- name: Add diff coverage report comment to PR
344-
if: github.base_ref != '' && always()
351+
if: github.base_ref != '' && always() && steps.alls-green.outputs.success == 'true'
345352
env:
346353
BRANCH_NAME: ${{ github.sha }}
347354
COV_STATUS: ${{ env.COV_STATUS }}
@@ -391,12 +398,12 @@ jobs:
391398
fi
392399
393400
- name: Add diff coverage report to workflow summary
394-
if: (github.base_ref != '' || github.event.before != '') && always()
401+
if: (github.base_ref != '' || github.event.before != '') && always() && steps.alls-green.outputs.success == 'true'
395402
run: |
396403
cat coverage-reports/diff-cover.md >> "$GITHUB_STEP_SUMMARY"
397404
398405
- name: Publish coverage reports
399-
if: always()
406+
if: always() && steps.alls-green.outputs.success == 'true'
400407
uses: actions/upload-artifact@v4
401408
with:
402409
name: coverage-reports

build_scripts/build_linux_deb-2-installer.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ if [ "$PLATFORM" = "arm64" ]; then
9191
# https://github.com/jordansissel/fpm/issues/1801#issuecomment-919877499
9292
# @TODO Consolidates the process to amd64 if the issue of electron-builder is resolved
9393
sudo apt-get -y install ruby ruby-dev
94-
# ERROR: Error installing fpm:
95-
# The last version of dotenv (>= 0) to support your Ruby & RubyGems was 2.8.1. Try installing it with `gem install dotenv -v 2.8.1` and then running the current command again
96-
# dotenv requires Ruby version >= 3.0. The current ruby version is 2.7.0.0.
97-
# @TODO Once ruby 3.0 can be installed on `apt install ruby`, installing dotenv below should be removed.
98-
sudo gem install dotenv -v 2.8.1
9994
sudo gem install fpm
10095
echo USE_SYSTEM_FPM=true "${NPM_PATH}/electron-builder" build --linux deb --arm64 \
10196
--config.extraMetadata.name=chia-blockchain \

chia/_tests/blockchain/blockchain_test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ async def _validate_and_add_block(
7676
conds = None
7777
else:
7878
# fake the signature validation. Just say True here.
79-
conds = SpendBundleConditions([], 0, 0, 0, None, None, [], 0, 0, 0, True, 0, 0)
79+
conds = SpendBundleConditions([], 0, 0, 0, None, None, [], 0, 0, 0, True, 0, 0, 0, 0, 0)
8080
results = PreValidationResult(None, uint64(1), conds, uint32(0))
8181
else:
8282
future = await pre_validate_block(

chia/_tests/blockchain/test_blockchain.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4352,6 +4352,9 @@ async def test_include_spends_same_as_parent(
43524352
True,
43534353
0,
43544354
0,
4355+
0,
4356+
0,
4357+
0,
43554358
)
43564359
# Now let's run the test
43574360
test_setup.fork_info.include_spends(conds, test_setup.test_block, test_setup.test_block.header_hash)

chia/_tests/core/custom_types/test_proof_of_space.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from chia._tests.util.misc import Marks, datacases
1313
from chia.consensus.default_constants import DEFAULT_CONSTANTS
1414
from chia.types.blockchain_format.proof_of_space import (
15-
calculate_plot_difficulty,
1615
calculate_prefix_bits,
16+
calculate_required_plot_strength,
1717
check_plot_size,
1818
make_pos,
1919
passes_plot_filter,
@@ -201,26 +201,26 @@ def test_verify_and_get_quality_string_v2(caplog: pytest.LogCaptureFixture, case
201201

202202

203203
@pytest.mark.parametrize(
204-
"height, difficulty",
204+
"height, strength",
205205
[
206206
(0, 2),
207207
(DEFAULT_CONSTANTS.HARD_FORK_HEIGHT, 2),
208208
(DEFAULT_CONSTANTS.HARD_FORK2_HEIGHT, 2),
209-
(DEFAULT_CONSTANTS.PLOT_DIFFICULTY_4_HEIGHT - 1, 2),
210-
(DEFAULT_CONSTANTS.PLOT_DIFFICULTY_4_HEIGHT, 4),
211-
(DEFAULT_CONSTANTS.PLOT_DIFFICULTY_5_HEIGHT - 1, 4),
212-
(DEFAULT_CONSTANTS.PLOT_DIFFICULTY_5_HEIGHT, 5),
213-
(DEFAULT_CONSTANTS.PLOT_DIFFICULTY_6_HEIGHT - 1, 5),
214-
(DEFAULT_CONSTANTS.PLOT_DIFFICULTY_6_HEIGHT, 6),
215-
(DEFAULT_CONSTANTS.PLOT_DIFFICULTY_7_HEIGHT - 1, 6),
216-
(DEFAULT_CONSTANTS.PLOT_DIFFICULTY_7_HEIGHT, 7),
217-
(DEFAULT_CONSTANTS.PLOT_DIFFICULTY_8_HEIGHT - 1, 7),
218-
(DEFAULT_CONSTANTS.PLOT_DIFFICULTY_8_HEIGHT, 8),
219-
(DEFAULT_CONSTANTS.PLOT_DIFFICULTY_8_HEIGHT + 1000000, 8),
209+
(DEFAULT_CONSTANTS.PLOT_STRENGTH_4_HEIGHT - 1, 2),
210+
(DEFAULT_CONSTANTS.PLOT_STRENGTH_4_HEIGHT, 4),
211+
(DEFAULT_CONSTANTS.PLOT_STRENGTH_5_HEIGHT - 1, 4),
212+
(DEFAULT_CONSTANTS.PLOT_STRENGTH_5_HEIGHT, 5),
213+
(DEFAULT_CONSTANTS.PLOT_STRENGTH_6_HEIGHT - 1, 5),
214+
(DEFAULT_CONSTANTS.PLOT_STRENGTH_6_HEIGHT, 6),
215+
(DEFAULT_CONSTANTS.PLOT_STRENGTH_7_HEIGHT - 1, 6),
216+
(DEFAULT_CONSTANTS.PLOT_STRENGTH_7_HEIGHT, 7),
217+
(DEFAULT_CONSTANTS.PLOT_STRENGTH_8_HEIGHT - 1, 7),
218+
(DEFAULT_CONSTANTS.PLOT_STRENGTH_8_HEIGHT, 8),
219+
(DEFAULT_CONSTANTS.PLOT_STRENGTH_8_HEIGHT + 1000000, 8),
220220
],
221221
)
222-
def test_calculate_plot_difficulty(height: uint32, difficulty: uint8) -> None:
223-
assert calculate_plot_difficulty(DEFAULT_CONSTANTS, height) == difficulty
222+
def test_calculate_plot_strength(height: uint32, strength: uint8) -> None:
223+
assert calculate_required_plot_strength(DEFAULT_CONSTANTS, height) == strength
224224

225225

226226
@pytest.mark.parametrize(

chia/_tests/core/full_node/test_full_node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@
112112

113113

114114
def test_pre_validation_result() -> None:
115-
conds = SpendBundleConditions([], 0, 0, 0, None, None, [], 0, 0, 0, True, 0, 0)
115+
conds = SpendBundleConditions([], 0, 0, 0, None, None, [], 0, 0, 0, True, 0, 0, 0, 0, 0)
116116
results = PreValidationResult(None, uint64(1), conds, uint32(0))
117117
assert results.validated_signature is True
118118

119-
conds = SpendBundleConditions([], 0, 0, 0, None, None, [], 0, 0, 0, False, 0, 0)
119+
conds = SpendBundleConditions([], 0, 0, 0, None, None, [], 0, 0, 0, False, 0, 0, 0, 0, 0)
120120
results = PreValidationResult(None, uint64(1), conds, uint32(0))
121121
assert results.validated_signature is False
122122

chia/_tests/core/full_node/test_generator_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
def test_tx_removals_and_additions() -> None:
8383
conditions = SpendBundleConditions(
84-
spends, uint64(0), uint32(0), uint64(0), None, None, [], uint64(0), 0, 0, False, 0, 0
84+
spends, uint64(0), uint32(0), uint64(0), None, None, [], uint64(0), 0, 0, False, 0, 0, 0, 0, 0
8585
)
8686
expected_rems = [coin_ids[0], coin_ids[1]]
8787
expected_additions = []

chia/_tests/core/mempool/test_mempool.py

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def make_item(
119119
return MempoolItem(
120120
SpendBundle([], G2Element()),
121121
fee,
122-
SpendBundleConditions([], 0, 0, 0, None, None, [], cost, 0, 0, False, 0, 0),
122+
SpendBundleConditions([], 0, 0, 0, None, None, [], cost, 0, 0, False, 0, 0, 0, 0, 0),
123123
spend_bundle_name,
124124
uint32(0),
125125
assert_height,
@@ -3213,6 +3213,97 @@ def test_get_puzzle_and_solution_for_coin_failure() -> None:
32133213
raise ValueError(f"Failed to get puzzle and solution for coin {TEST_COIN}, error: {e}") from e
32143214

32153215

3216+
# this puzzle just creates coins, however many are requested by the solution
3217+
# (mod (A)
3218+
# (defun loop (n)
3219+
# (if (= n 1)
3220+
# (list)
3221+
# (c (list 51 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff n) (loop (- n 1))))
3222+
# )
3223+
# (loop A)
3224+
# )
3225+
create_coins_loop: str = (
3226+
"ff02ffff01ff02ff02ffff04ff02ffff04ff05ff80808080ffff04ffff01ff02"
3227+
"ffff03ffff09ff05ffff010180ff80ffff01ff04ffff04ffff0133ffff04ffff"
3228+
"01a0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
3229+
"ffffffff04ff05ff80808080ffff02ff02ffff04ff02ffff04ffff11ff05ffff"
3230+
"010180ff808080808080ff0180ff018080"
3231+
)
3232+
3233+
3234+
# this test uses artificial puzzles just to exercise the block creation. These
3235+
# spends are expected not to verify any signatures
3236+
# This is to keep the test simple.
3237+
@pytest.mark.parametrize(
3238+
"puzzle, solution",
3239+
[
3240+
# create 2000 coins
3241+
(create_coins_loop, "ff8207d180"),
3242+
# create 1000 coins
3243+
(create_coins_loop, "ff8203e980"),
3244+
# create 500 coins
3245+
(create_coins_loop, "ff8201f580"),
3246+
],
3247+
)
3248+
@pytest.mark.parametrize("old", [True, False])
3249+
def test_create_block_generator_custom_spend(puzzle: str, solution: str, old: bool) -> None:
3250+
mempool_info = MempoolInfo(
3251+
CLVMCost(uint64(11000000000 * 3)),
3252+
FeeRate(uint64(1000000)),
3253+
CLVMCost(uint64(11000000000)),
3254+
)
3255+
3256+
fee_estimator = create_bitcoin_fee_estimator(test_constants.MAX_BLOCK_COST_CLVM)
3257+
solution_str = SerializedProgram.fromhex(solution)
3258+
puzzle_reveal = SerializedProgram.fromhex(puzzle)
3259+
puzzle_hash = puzzle_reveal.get_tree_hash()
3260+
mempool = Mempool(mempool_info, fee_estimator)
3261+
coins = [Coin(bytes32.random(), puzzle_hash, uint64(amount)) for amount in range(100000000, 100000022)]
3262+
3263+
spend_bundles = [
3264+
SpendBundle(
3265+
coin_spends=[CoinSpend(coin, puzzle_reveal=puzzle_reveal, solution=solution_str)],
3266+
aggregated_signature=G2Element(),
3267+
)
3268+
for coin in coins
3269+
]
3270+
3271+
for sb in spend_bundles:
3272+
mi = mempool_item_from_spendbundle(sb)
3273+
mempool.add_to_pool(mi)
3274+
invariant_check_mempool(mempool)
3275+
3276+
create_block = mempool.create_block_generator if old else mempool.create_block_generator2
3277+
generator = create_block(test_constants, test_constants.HARD_FORK2_HEIGHT, 10.0)
3278+
assert generator is not None
3279+
3280+
assert generator.signature == G2Element()
3281+
3282+
removals = set(generator.removals)
3283+
3284+
err, conds = run_block_generator2(
3285+
bytes(generator.program),
3286+
generator.generator_refs,
3287+
test_constants.MAX_BLOCK_COST_CLVM,
3288+
0,
3289+
generator.signature,
3290+
None,
3291+
test_constants,
3292+
)
3293+
3294+
assert err is None
3295+
assert conds is not None
3296+
3297+
assert len(conds.spends) == len(removals)
3298+
3299+
for spend in conds.spends:
3300+
removal = Coin(spend.parent_id, spend.puzzle_hash, uint64(spend.coin_amount))
3301+
assert removal in coins
3302+
assert removal in removals
3303+
3304+
invariant_check_mempool(mempool)
3305+
3306+
32163307
@pytest.mark.parametrize("old", [True, False])
32173308
def test_create_block_generator(old: bool) -> None:
32183309
mempool = construct_mempool()

chia/_tests/core/mempool/test_mempool_manager.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
QUOTE_BYTES,
4242
QUOTE_EXECUTION_COST,
4343
MempoolManager,
44+
NewPeakItem,
4445
TimelockConditions,
4546
can_replace,
4647
check_removals,
@@ -375,6 +376,9 @@ def make_test_conds(
375376
False,
376377
0,
377378
0,
379+
0,
380+
0,
381+
0,
378382
)
379383

380384

@@ -590,7 +594,9 @@ def make_bundle_spends_map_and_fee(
590594

591595

592596
def mempool_item_from_spendbundle(spend_bundle: SpendBundle) -> MempoolItem:
593-
conds = get_conditions_from_spendbundle(spend_bundle, INFINITE_COST, DEFAULT_CONSTANTS, uint32(0))
597+
conds = get_conditions_from_spendbundle(
598+
spend_bundle, INFINITE_COST, DEFAULT_CONSTANTS, DEFAULT_CONSTANTS.HARD_FORK2_HEIGHT
599+
)
594600
bundle_coin_spends, fee = make_bundle_spends_map_and_fee(spend_bundle, conds)
595601
return MempoolItem(
596602
spend_bundle=spend_bundle,
@@ -3260,3 +3266,47 @@ async def test_different_ff_versions() -> None:
32603266
latest_singleton_lineage2 = new_mi2.bundle_coin_spends[version2_id].latest_singleton_lineage
32613267
assert latest_singleton_lineage2 is not None
32623268
assert latest_singleton_lineage2.coin_id == new_latest_lineage_id
3269+
3270+
3271+
@pytest.mark.anyio
3272+
@pytest.mark.parametrize(
3273+
"condition_and_error",
3274+
[
3275+
(ConditionOpcode.ASSERT_HEIGHT_RELATIVE, Err.ASSERT_HEIGHT_RELATIVE_FAILED),
3276+
(ConditionOpcode.ASSERT_HEIGHT_ABSOLUTE, Err.ASSERT_HEIGHT_ABSOLUTE_FAILED),
3277+
],
3278+
)
3279+
@pytest.mark.parametrize("optimized_path", [True, False])
3280+
async def test_new_peak_txs_added(condition_and_error: tuple[ConditionOpcode, Err], optimized_path: bool) -> None:
3281+
"""
3282+
Tests that deferred transactions because of time-lock are retried once the
3283+
time-lock allows them to be reconsidered.
3284+
"""
3285+
coins = TestCoins([TEST_COIN], {})
3286+
mempool_manager = await setup_mempool(coins)
3287+
# Add an item that should go to the pending cache
3288+
assert mempool_manager.peak is not None
3289+
condition_height = mempool_manager.peak.height + 1
3290+
condition, expected_error = condition_and_error
3291+
sb, sb_name, result = await generate_and_add_spendbundle(mempool_manager, [[condition, condition_height]])
3292+
_, status, error = result
3293+
assert status == MempoolInclusionStatus.PENDING
3294+
assert error == expected_error
3295+
# Advance the mempool beyond the asserted height to retry the test item
3296+
if optimized_path:
3297+
spent_coins: Optional[list[bytes32]] = []
3298+
new_peak_info = await mempool_manager.new_peak(
3299+
create_test_block_record(height=uint32(condition_height)), spent_coins
3300+
)
3301+
# We're not there yet (needs to be higher, not equal)
3302+
assert mempool_manager.get_mempool_item(sb_name, include_pending=False) is None
3303+
assert new_peak_info.items == []
3304+
else:
3305+
spent_coins = None
3306+
new_peak_info = await mempool_manager.new_peak(
3307+
create_test_block_record(height=uint32(condition_height + 1)), spent_coins
3308+
)
3309+
# The item gets retried successfully now
3310+
mi = mempool_manager.get_mempool_item(sb_name, include_pending=False)
3311+
assert mi is not None
3312+
assert new_peak_info.items == [NewPeakItem(sb_name, sb, mi.conds)]

0 commit comments

Comments
 (0)