Remove no longer needed cost_per_byte cases (#14850)

Remove no longer needed cost_per_byte cases.
This commit is contained in:
Amine Khaldi 2023-03-25 00:29:50 +01:00 committed by GitHub
parent df6991551a
commit 8afba0814d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 50 additions and 201 deletions

View File

@ -65,11 +65,7 @@ class CostLogger:
def add_cost(self, descriptor: str, spend_bundle: SpendBundle) -> SpendBundle:
program: BlockGenerator = simple_solution_generator(spend_bundle)
npc_result: NPCResult = get_name_puzzle_conditions(
program,
INFINITE_COST,
cost_per_byte=DEFAULT_CONSTANTS.COST_PER_BYTE,
mempool_mode=True,
height=DEFAULT_CONSTANTS.SOFT_FORK2_HEIGHT,
program, INFINITE_COST, mempool_mode=True, height=DEFAULT_CONSTANTS.SOFT_FORK2_HEIGHT
)
self.cost_dict[descriptor] = npc_result.cost
cost_to_subtract: int = 0

View File

@ -319,7 +319,6 @@ async def validate_block_body(
curr_npc_result = get_name_puzzle_conditions(
curr_block_generator,
min(constants.MAX_BLOCK_COST_CLVM, curr.transactions_info.cost),
cost_per_byte=constants.COST_PER_BYTE,
mempool_mode=False,
height=curr.height,
constants=constants,

View File

@ -131,11 +131,7 @@ def create_foliage(
if block_generator is not None:
generator_block_heights_list = block_generator.block_height_list
result: NPCResult = get_name_puzzle_conditions(
block_generator,
constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=constants.COST_PER_BYTE,
mempool_mode=True,
height=height,
block_generator, constants.MAX_BLOCK_COST_CLVM, mempool_mode=True, height=height
)
cost = result.cost

View File

@ -438,11 +438,7 @@ class Blockchain(BlockchainInterface):
block_generator: Optional[BlockGenerator] = await self.get_block_generator(block)
assert block_generator is not None
npc_result = get_name_puzzle_conditions(
block_generator,
self.constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=self.constants.COST_PER_BYTE,
mempool_mode=False,
height=block.height,
block_generator, self.constants.MAX_BLOCK_COST_CLVM, mempool_mode=False, height=block.height
)
tx_removals, tx_additions = tx_removals_and_additions(npc_result.conds)
return tx_removals, tx_additions, npc_result

View File

@ -91,7 +91,6 @@ def batch_pre_validate_blocks(
npc_result = get_name_puzzle_conditions(
block_generator,
min(constants.MAX_BLOCK_COST_CLVM, block.transactions_info.cost),
cost_per_byte=constants.COST_PER_BYTE,
mempool_mode=False,
height=block.height,
constants=constants,
@ -387,7 +386,6 @@ def _run_generator(
npc_result: NPCResult = get_name_puzzle_conditions(
block_generator,
min(constants.MAX_BLOCK_COST_CLVM, unfinished_block.transactions_info.cost),
cost_per_byte=constants.COST_PER_BYTE,
mempool_mode=False,
height=height,
)

View File

@ -1107,7 +1107,6 @@ class FullNodeAPI:
get_name_puzzle_conditions,
block_generator,
self.full_node.constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=self.full_node.constants.COST_PER_BYTE,
mempool_mode=False,
height=request.height,
),

View File

@ -37,7 +37,6 @@ def get_name_puzzle_conditions(
generator: BlockGenerator,
max_cost: int,
*,
cost_per_byte: int,
mempool_mode: bool,
height: uint32,
constants: ConsensusConstants = DEFAULT_CONSTANTS,

View File

@ -60,7 +60,6 @@ def validate_clvm_and_signature(
the NPCResult and a cache of the new pairings validated (if not error)
"""
cost_per_byte = constants.COST_PER_BYTE
additional_data = constants.AGG_SIG_ME_ADDITIONAL_DATA
try:
@ -68,7 +67,7 @@ def validate_clvm_and_signature(
program = simple_solution_generator(bundle)
# npc contains names of the coins removed, puzzle_hashes and their spend conditions
result: NPCResult = get_name_puzzle_conditions(
program, max_cost, cost_per_byte=cost_per_byte, mempool_mode=True, constants=constants, height=height
program, max_cost, mempool_mode=True, constants=constants, height=height
)
if result.error is not None:

View File

@ -293,11 +293,7 @@ class CATWallet:
# will only matter once the wallet generates transactions relying on
# new conditions, and we can change this by then
result: NPCResult = get_name_puzzle_conditions(
program,
self.wallet_state_manager.constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=self.wallet_state_manager.constants.COST_PER_BYTE,
mempool_mode=True,
height=uint32(0),
program, self.wallet_state_manager.constants.MAX_BLOCK_COST_CLVM, mempool_mode=True, height=uint32(0)
)
self.cost_of_single_tx = result.cost
self.log.info(f"Cost of a single tx for CAT wallet: {self.cost_of_single_tx}")

View File

@ -94,11 +94,7 @@ class Wallet:
# will only matter once the wallet generates transactions relying on
# new conditions, and we can change this by then
result: NPCResult = get_name_puzzle_conditions(
program,
self.wallet_state_manager.constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=self.wallet_state_manager.constants.COST_PER_BYTE,
mempool_mode=True,
height=uint32(0),
program, self.wallet_state_manager.constants.MAX_BLOCK_COST_CLVM, mempool_mode=True, height=uint32(0)
)
self.cost_of_single_tx = result.cost
self.log.info(f"Cost of a single tx for standard wallet: {self.cost_of_single_tx}")

View File

@ -2536,11 +2536,7 @@ class TestBodyValidation:
block_generator: BlockGenerator = BlockGenerator(blocks[-1].transactions_generator, [], [])
npc_result = get_name_puzzle_conditions(
block_generator,
b.constants.MAX_BLOCK_COST_CLVM * 1000,
cost_per_byte=b.constants.COST_PER_BYTE,
mempool_mode=False,
height=softfork_height,
block_generator, b.constants.MAX_BLOCK_COST_CLVM * 1000, mempool_mode=False, height=softfork_height
)
err = (await b.receive_block(blocks[-1], PreValidationResult(None, uint64(1), npc_result, True)))[1]
assert err in [Err.BLOCK_COST_EXCEEDS_MAX]
@ -2599,7 +2595,6 @@ class TestBodyValidation:
npc_result = get_name_puzzle_conditions(
block_generator,
min(b.constants.MAX_BLOCK_COST_CLVM * 1000, block.transactions_info.cost),
cost_per_byte=b.constants.COST_PER_BYTE,
mempool_mode=False,
height=softfork_height,
)
@ -2624,7 +2619,6 @@ class TestBodyValidation:
npc_result = get_name_puzzle_conditions(
block_generator,
min(b.constants.MAX_BLOCK_COST_CLVM * 1000, block.transactions_info.cost),
cost_per_byte=b.constants.COST_PER_BYTE,
mempool_mode=False,
height=softfork_height,
)
@ -2649,7 +2643,6 @@ class TestBodyValidation:
npc_result = get_name_puzzle_conditions(
block_generator,
min(b.constants.MAX_BLOCK_COST_CLVM * 1000, block.transactions_info.cost),
cost_per_byte=b.constants.COST_PER_BYTE,
mempool_mode=False,
height=softfork_height,
)

View File

@ -305,10 +305,7 @@ class TestBlockchainTransactions:
coin_2 = None
for coin in run_and_get_removals_and_additions(
new_blocks[-1],
test_constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=test_constants.COST_PER_BYTE,
height=softfork_height,
new_blocks[-1], test_constants.MAX_BLOCK_COST_CLVM, height=softfork_height
)[1]:
if coin.puzzle_hash == receiver_1_puzzlehash:
coin_2 = coin
@ -329,10 +326,7 @@ class TestBlockchainTransactions:
coin_3 = None
for coin in run_and_get_removals_and_additions(
new_blocks[-1],
test_constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=test_constants.COST_PER_BYTE,
height=softfork_height,
new_blocks[-1], test_constants.MAX_BLOCK_COST_CLVM, height=softfork_height
)[1]:
if coin.puzzle_hash == receiver_2_puzzlehash:
coin_3 = coin

View File

@ -11,13 +11,8 @@ from chia.types.spend_bundle import SpendBundle
def cost_of_spend_bundle(spend_bundle: SpendBundle) -> int:
program: BlockGenerator = simple_solution_generator(spend_bundle)
# always use the post soft-fork2 semantics
npc_result: NPCResult = get_name_puzzle_conditions(
program,
INFINITE_COST,
cost_per_byte=DEFAULT_CONSTANTS.COST_PER_BYTE,
mempool_mode=True,
height=DEFAULT_CONSTANTS.SOFT_FORK2_HEIGHT,
program, INFINITE_COST, mempool_mode=True, height=DEFAULT_CONSTANTS.SOFT_FORK2_HEIGHT
)
return npc_result.cost

View File

@ -54,20 +54,12 @@ class CoinStore:
self._add_coin_entry(coin, birthday)
return coin
def validate_spend_bundle(
self,
spend_bundle: SpendBundle,
now: CoinTimestamp,
max_cost: int,
cost_per_byte: int,
) -> int:
def validate_spend_bundle(self, spend_bundle: SpendBundle, now: CoinTimestamp, max_cost: int) -> int:
# this should use blockchain consensus code
program = simple_solution_generator(spend_bundle)
# always use the post soft-fork2 semantics
result: NPCResult = get_name_puzzle_conditions(
program, max_cost, cost_per_byte=cost_per_byte, mempool_mode=True, height=uint32(4000000)
)
result: NPCResult = get_name_puzzle_conditions(program, max_cost, mempool_mode=True, height=uint32(4000000))
if result.error is not None:
raise BadSpendBundleError(f"condition validation failure {Err(result.error)}")
@ -106,9 +98,8 @@ class CoinStore:
spend_bundle: SpendBundle,
now: CoinTimestamp,
max_cost: int,
cost_per_byte: int,
):
err = self.validate_spend_bundle(spend_bundle, now, max_cost, cost_per_byte)
err = self.validate_spend_bundle(spend_bundle, now, max_cost)
if err != 0:
raise BadSpendBundleError(f"validation failure {err}")
additions = spend_bundle.additions()

View File

@ -28,7 +28,6 @@ T1 = CoinTimestamp(1, 10000000)
T2 = CoinTimestamp(5, 10003000)
MAX_BLOCK_COST_CLVM = int(1e18)
COST_PER_BYTE = int(12000)
def secret_exponent_for_index(index: int) -> int:
@ -75,7 +74,7 @@ def do_test_spend(
coin_spend = CoinSpend(coin, puzzle_reveal, solution)
spend_bundle = SpendBundle([coin_spend], G2Element())
coin_db.update_coin_store_for_spend_bundle(spend_bundle, spend_time, MAX_BLOCK_COST_CLVM, COST_PER_BYTE)
coin_db.update_coin_store_for_spend_bundle(spend_bundle, spend_time, MAX_BLOCK_COST_CLVM)
# ensure all outputs are there
for puzzle_hash, amount in payments:

View File

@ -96,11 +96,7 @@ class TestCoinStoreWithBlocks:
if block.transactions_generator is not None:
block_gen: BlockGenerator = BlockGenerator(block.transactions_generator, [], [])
npc_result = get_name_puzzle_conditions(
block_gen,
bt.constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=bt.constants.COST_PER_BYTE,
mempool_mode=False,
height=softfork_height,
block_gen, bt.constants.MAX_BLOCK_COST_CLVM, mempool_mode=False, height=softfork_height
)
tx_removals, tx_additions = tx_removals_and_additions(npc_result.conds)
else:

View File

@ -1970,9 +1970,7 @@ def generator_condition_tester(
program = SerializedProgram.from_bytes(binutils.assemble(prg).as_bin())
generator = BlockGenerator(program, [], [])
print(f"len: {len(bytes(program))}")
npc_result: NPCResult = get_name_puzzle_conditions(
generator, max_cost, cost_per_byte=COST_PER_BYTE, mempool_mode=mempool_mode, height=height
)
npc_result: NPCResult = get_name_puzzle_conditions(generator, max_cost, mempool_mode=mempool_mode, height=height)
return npc_result
@ -2151,7 +2149,7 @@ class TestGeneratorConditions:
)
generator = BlockGenerator(program, [], [])
npc_result: NPCResult = get_name_puzzle_conditions(
generator, MAX_BLOCK_COST_CLVM, cost_per_byte=COST_PER_BYTE, mempool_mode=False, height=softfork_height
generator, MAX_BLOCK_COST_CLVM, mempool_mode=False, height=softfork_height
)
assert npc_result.error is None
assert len(npc_result.conds.spends) == 2

View File

@ -77,11 +77,7 @@ class TestCostCalculation:
program: BlockGenerator = simple_solution_generator(spend_bundle)
npc_result: NPCResult = get_name_puzzle_conditions(
program,
test_constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=test_constants.COST_PER_BYTE,
mempool_mode=False,
height=softfork_height,
program, test_constants.MAX_BLOCK_COST_CLVM, mempool_mode=False, height=softfork_height
)
assert npc_result.error is None
@ -147,19 +143,11 @@ class TestCostCalculation:
)
generator = BlockGenerator(program, [], [])
npc_result: NPCResult = get_name_puzzle_conditions(
generator,
test_constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=test_constants.COST_PER_BYTE,
mempool_mode=True,
height=softfork_height,
generator, test_constants.MAX_BLOCK_COST_CLVM, mempool_mode=True, height=softfork_height
)
assert npc_result.error is not None
npc_result = get_name_puzzle_conditions(
generator,
test_constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=test_constants.COST_PER_BYTE,
mempool_mode=False,
height=softfork_height,
generator, test_constants.MAX_BLOCK_COST_CLVM, mempool_mode=False, height=softfork_height
)
assert npc_result.error is None
@ -182,19 +170,11 @@ class TestCostCalculation:
program = SerializedProgram.from_bytes(binutils.assemble(f"(i (0xfe (q . 0)) (q . ()) {disassembly})").as_bin())
generator = BlockGenerator(program, [], [])
npc_result: NPCResult = get_name_puzzle_conditions(
generator,
test_constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=test_constants.COST_PER_BYTE,
mempool_mode=True,
height=softfork_height,
generator, test_constants.MAX_BLOCK_COST_CLVM, mempool_mode=True, height=softfork_height
)
assert npc_result.error is not None
npc_result = get_name_puzzle_conditions(
generator,
test_constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=test_constants.COST_PER_BYTE,
mempool_mode=False,
height=softfork_height,
generator, test_constants.MAX_BLOCK_COST_CLVM, mempool_mode=False, height=softfork_height
)
assert npc_result.error is None
@ -208,11 +188,7 @@ class TestCostCalculation:
with assert_runtime(seconds=0.5, label=request.node.name):
generator = BlockGenerator(program, [], [])
npc_result = get_name_puzzle_conditions(
generator,
test_constants.MAX_BLOCK_COST_CLVM,
cost_per_byte=test_constants.COST_PER_BYTE,
mempool_mode=False,
height=softfork_height,
generator, test_constants.MAX_BLOCK_COST_CLVM, mempool_mode=False, height=softfork_height
)
assert npc_result.error is None
@ -233,22 +209,14 @@ class TestCostCalculation:
# ensure we fail if the program exceeds the cost
generator = BlockGenerator(program, [], [])
npc_result: NPCResult = get_name_puzzle_conditions(
generator,
10000000,
cost_per_byte=0,
mempool_mode=False,
height=softfork_height,
)
npc_result = get_name_puzzle_conditions(generator, 10000000, mempool_mode=False, height=softfork_height)
assert npc_result.error is not None
assert npc_result.cost == 0
# raise the max cost to make sure this passes
# ensure we pass if the program does not exceeds the cost
npc_result = get_name_puzzle_conditions(
generator, 23000000, cost_per_byte=0, mempool_mode=False, height=softfork_height
)
npc_result = get_name_puzzle_conditions(generator, 23000000, mempool_mode=False, height=softfork_height)
assert npc_result.error is None
assert npc_result.cost > 10000000

View File

@ -127,9 +127,7 @@ class TestROM:
cost, r = run_generator_unsafe(gen, max_cost=MAX_COST)
print(r)
npc_result = get_name_puzzle_conditions(
gen, max_cost=MAX_COST, cost_per_byte=COST_PER_BYTE, mempool_mode=False, height=softfork_height
)
npc_result = get_name_puzzle_conditions(gen, max_cost=MAX_COST, mempool_mode=False, height=softfork_height)
assert npc_result.error is None
assert npc_result.cost == EXPECTED_COST + ConditionCost.CREATE_COIN.value + (
len(bytes(gen.program)) * COST_PER_BYTE

View File

@ -157,12 +157,7 @@ class TestPoolPuzzles(TestCase):
sig,
)
# Spend it!
coin_db.update_coin_store_for_spend_bundle(
spend_bundle,
time,
DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM,
DEFAULT_CONSTANTS.COST_PER_BYTE,
)
coin_db.update_coin_store_for_spend_bundle(spend_bundle, time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM)
# Test that we can retrieve the extra data
assert get_delayed_puz_info_from_launcher_spend(launcher_coinsol) == (DELAY_TIME, DELAY_PH)
assert solution_to_pool_state(launcher_coinsol) == pool_state
@ -181,10 +176,7 @@ class TestPoolPuzzles(TestCase):
)
# Spend it!
fork_coin_db.update_coin_store_for_spend_bundle(
SpendBundle([post_launch_coinsol], G2Element()),
time,
DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM,
DEFAULT_CONSTANTS.COST_PER_BYTE,
SpendBundle([post_launch_coinsol], G2Element()), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
)
# HONEST ABSORB
@ -217,10 +209,7 @@ class TestPoolPuzzles(TestCase):
)
# Spend it!
coin_db.update_coin_store_for_spend_bundle(
SpendBundle(coin_sols, G2Element()),
time,
DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM,
DEFAULT_CONSTANTS.COST_PER_BYTE,
SpendBundle(coin_sols, G2Element()), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
)
# ABSORB A NON EXISTENT REWARD (Negative test)
@ -251,10 +240,7 @@ class TestPoolPuzzles(TestCase):
BadSpendBundleError, match="condition validation failure Err.ASSERT_ANNOUNCE_CONSUMED_FAILED"
):
coin_db.update_coin_store_for_spend_bundle(
SpendBundle([singleton_coinsol], G2Element()),
time,
DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM,
DEFAULT_CONSTANTS.COST_PER_BYTE,
SpendBundle([singleton_coinsol], G2Element()), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
)
# SPEND A NON-REWARD P2_SINGLETON (Negative test)
@ -281,10 +267,7 @@ class TestPoolPuzzles(TestCase):
BadSpendBundleError, match="condition validation failure Err.ASSERT_ANNOUNCE_CONSUMED_FAILED"
):
coin_db.update_coin_store_for_spend_bundle(
SpendBundle([singleton_coinsol, bad_coinsol], G2Element()),
time,
DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM,
DEFAULT_CONSTANTS.COST_PER_BYTE,
SpendBundle([singleton_coinsol, bad_coinsol], G2Element()), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
)
# ENTER WAITING ROOM
@ -310,10 +293,7 @@ class TestPoolPuzzles(TestCase):
)
# Spend it!
coin_db.update_coin_store_for_spend_bundle(
SpendBundle([travel_coinsol], sig),
time,
DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM,
DEFAULT_CONSTANTS.COST_PER_BYTE,
SpendBundle([travel_coinsol], sig), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
)
# ESCAPE TOO FAST (Negative test)
@ -337,10 +317,7 @@ class TestPoolPuzzles(TestCase):
# Spend it and hope it fails!
with pytest.raises(BadSpendBundleError, match="condition validation failure Err.ASSERT_HEIGHT_RELATIVE_FAILED"):
coin_db.update_coin_store_for_spend_bundle(
SpendBundle([return_coinsol], sig),
time,
DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM,
DEFAULT_CONSTANTS.COST_PER_BYTE,
SpendBundle([return_coinsol], sig), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
)
# ABSORB WHILE IN WAITING ROOM
@ -359,10 +336,7 @@ class TestPoolPuzzles(TestCase):
)
# Spend it!
coin_db.update_coin_store_for_spend_bundle(
SpendBundle(coin_sols, G2Element()),
time,
DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM,
DEFAULT_CONSTANTS.COST_PER_BYTE,
SpendBundle(coin_sols, G2Element()), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
)
# LEAVE THE WAITING ROOM
@ -395,10 +369,7 @@ class TestPoolPuzzles(TestCase):
)
# Spend it!
coin_db.update_coin_store_for_spend_bundle(
SpendBundle([return_coinsol], sig),
time,
DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM,
DEFAULT_CONSTANTS.COST_PER_BYTE,
SpendBundle([return_coinsol], sig), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
)
# ABSORB ONCE MORE FOR GOOD MEASURE
@ -416,8 +387,5 @@ class TestPoolPuzzles(TestCase):
)
# Spend it!
coin_db.update_coin_store_for_spend_bundle(
SpendBundle(coin_sols, G2Element()),
time,
DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM,
DEFAULT_CONSTANTS.COST_PER_BYTE,
SpendBundle(coin_sols, G2Element()), time, DEFAULT_CONSTANTS.MAX_BLOCK_COST_CLVM
)

View File

@ -12,7 +12,7 @@ from chia.util.ints import uint32
def run_and_get_removals_and_additions(
block: FullBlock, max_cost: int, *, cost_per_byte: int, height: uint32, mempool_mode=False
block: FullBlock, max_cost: int, *, height: uint32, mempool_mode=False
) -> Tuple[List[bytes32], List[Coin]]:
removals: List[bytes32] = []
additions: List[Coin] = []
@ -23,11 +23,7 @@ def run_and_get_removals_and_additions(
if block.transactions_generator is not None:
npc_result = get_name_puzzle_conditions(
BlockGenerator(block.transactions_generator, [], []),
max_cost,
cost_per_byte=cost_per_byte,
mempool_mode=mempool_mode,
height=height,
BlockGenerator(block.transactions_generator, [], []), max_cost, mempool_mode=mempool_mode, height=height
)
assert npc_result.error is None
rem, add = tx_removals_and_additions(npc_result.conds)

View File

@ -578,7 +578,7 @@ class TestCATTrades:
bundle = Offer.aggregate([first_offer, second_offer, third_offer, fourth_offer, fifth_offer]).to_valid_spend()
program = simple_solution_generator(bundle)
result: NPCResult = get_name_puzzle_conditions(
program, INFINITE_COST, cost_per_byte=0, mempool_mode=True, height=softfork_height
program, INFINITE_COST, mempool_mode=True, height=softfork_height
)
assert result.error is None

View File

@ -34,7 +34,6 @@ ANYONE_CAN_SPEND_WITH_PADDING_PUZZLE_HASH = Program.to(binutils.assemble("(a (q
POOL_REWARD_PREFIX_MAINNET = bytes32.fromhex("ccd5bb71183532bff220ba46c268991a00000000000000000000000000000000")
MAX_BLOCK_COST_CLVM = int(1e18)
COST_PER_BYTE = int(12000)
class PuzzleDB:
@ -418,9 +417,7 @@ def spend_coin_to_singleton(
coin_spend = CoinSpend(farmed_coin, ANYONE_CAN_SPEND_PUZZLE, conditions)
spend_bundle = SpendBundle.aggregate([launcher_spend_bundle, SpendBundle([coin_spend], G2Element())])
additions, removals = coin_store.update_coin_store_for_spend_bundle(
spend_bundle, now, MAX_BLOCK_COST_CLVM, COST_PER_BYTE
)
additions, removals = coin_store.update_coin_store_for_spend_bundle(spend_bundle, now, MAX_BLOCK_COST_CLVM)
launcher_coin = launcher_spend_bundle.coin_spends[0].coin
@ -486,7 +483,7 @@ def test_lifecycle_with_coinstore_as_wallet():
#######
# spend coin to a singleton
additions, removals = spend_coin_to_singleton(PUZZLE_DB, LAUNCHER_PUZZLE, coin_store, now)
_, removals = spend_coin_to_singleton(PUZZLE_DB, LAUNCHER_PUZZLE, coin_store, now)
assert len(list(coin_store.all_unspent_coins())) == 1
@ -521,9 +518,7 @@ def test_lifecycle_with_coinstore_as_wallet():
coin_spend = SINGLETON_WALLET.coin_spend_for_conditions(PUZZLE_DB, conditions=singleton_conditions)
spend_bundle = SpendBundle([coin_spend, p2_singleton_coin_spend], G2Element())
additions, removals = coin_store.update_coin_store_for_spend_bundle(
spend_bundle, now, MAX_BLOCK_COST_CLVM, COST_PER_BYTE
)
_, removals = coin_store.update_coin_store_for_spend_bundle(spend_bundle, now, MAX_BLOCK_COST_CLVM)
now.seconds += 500
now.height += 1
@ -552,9 +547,7 @@ def test_lifecycle_with_coinstore_as_wallet():
coin_spend = SINGLETON_WALLET.coin_spend_for_conditions(PUZZLE_DB, conditions=singleton_conditions)
spend_bundle = SpendBundle([coin_spend, p2_singleton_coin_spend], G2Element())
additions, removals = coin_store.update_coin_store_for_spend_bundle(
spend_bundle, now, MAX_BLOCK_COST_CLVM, COST_PER_BYTE
)
_, removals = coin_store.update_coin_store_for_spend_bundle(spend_bundle, now, MAX_BLOCK_COST_CLVM)
now.seconds += 500
now.height += 1
@ -605,9 +598,7 @@ def test_lifecycle_with_coinstore_as_wallet():
spend_bundle = SpendBundle([singleton_coin_spend], G2Element())
additions, removals = coin_store.update_coin_store_for_spend_bundle(
spend_bundle, now, MAX_BLOCK_COST_CLVM, COST_PER_BYTE
)
_, removals = coin_store.update_coin_store_for_spend_bundle(spend_bundle, now, MAX_BLOCK_COST_CLVM)
assert len(list(coin_store.all_unspent_coins())) == 1
@ -643,9 +634,7 @@ def test_lifecycle_with_coinstore_as_wallet():
spend_bundle = SpendBundle([coin_spend, p2_singleton_coin_spend], G2Element())
spend_bundle.debug()
additions, removals = coin_store.update_coin_store_for_spend_bundle(
spend_bundle, now, MAX_BLOCK_COST_CLVM, COST_PER_BYTE
)
_, removals = coin_store.update_coin_store_for_spend_bundle(spend_bundle, now, MAX_BLOCK_COST_CLVM)
now.seconds += 500
now.height += 1
@ -661,9 +650,7 @@ def test_lifecycle_with_coinstore_as_wallet():
)
spend_bundle = SpendBundle([coin_spend], G2Element())
additions, removals = coin_store.update_coin_store_for_spend_bundle(
spend_bundle, now, MAX_BLOCK_COST_CLVM, COST_PER_BYTE
)
_, removals = coin_store.update_coin_store_for_spend_bundle(spend_bundle, now, MAX_BLOCK_COST_CLVM)
now.seconds += 500
now.height += 1
change_count = SINGLETON_WALLET.update_state(PUZZLE_DB, removals)
@ -700,9 +687,7 @@ def test_lifecycle_with_coinstore_as_wallet():
)
spend_bundle = SpendBundle([coin_spend, p2_singleton_coin_spend], G2Element())
additions, removals = coin_store.update_coin_store_for_spend_bundle(
spend_bundle, now, MAX_BLOCK_COST_CLVM, COST_PER_BYTE
)
_, removals = coin_store.update_coin_store_for_spend_bundle(spend_bundle, now, MAX_BLOCK_COST_CLVM)
now.seconds += 500
now.height += 1
@ -730,9 +715,7 @@ def test_lifecycle_with_coinstore_as_wallet():
PUZZLE_DB.add_puzzle(full_puzzle)
try:
additions, removals = coin_store.update_coin_store_for_spend_bundle(
spend_bundle, now, MAX_BLOCK_COST_CLVM, COST_PER_BYTE
)
_, removals = coin_store.update_coin_store_for_spend_bundle(spend_bundle, now, MAX_BLOCK_COST_CLVM)
assert 0
except BadSpendBundleError as ex:
assert ex.args[0] == "condition validation failure Err.ASSERT_HEIGHT_RELATIVE_FAILED"
@ -740,9 +723,7 @@ def test_lifecycle_with_coinstore_as_wallet():
now.seconds += 350000
now.height += 1445
additions, removals = coin_store.update_coin_store_for_spend_bundle(
spend_bundle, now, MAX_BLOCK_COST_CLVM, COST_PER_BYTE
)
_, removals = coin_store.update_coin_store_for_spend_bundle(spend_bundle, now, MAX_BLOCK_COST_CLVM)
SINGLETON_WALLET.update_state(PUZZLE_DB, removals)
@ -757,9 +738,7 @@ def test_lifecycle_with_coinstore_as_wallet():
spend_bundle = SpendBundle([coin_spend], G2Element())
spend_bundle.debug()
additions, removals = coin_store.update_coin_store_for_spend_bundle(
spend_bundle, now, MAX_BLOCK_COST_CLVM, COST_PER_BYTE
)
_, removals = coin_store.update_coin_store_for_spend_bundle(spend_bundle, now, MAX_BLOCK_COST_CLVM)
update_count = SINGLETON_WALLET.update_state(PUZZLE_DB, removals)
assert update_count == 0