Skip to content

Commit

Permalink
add missing cost constants for conditions (Chia-Network#6655)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn authored Jun 14, 2021
1 parent 07f64d2 commit e76c400
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions chia/consensus/condition_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ConditionCost(Enum):
AGG_SIG = 1200000 # the cost of one G1 subgroup check + aggregated signature validation
CREATE_COIN = 1800000
ASSERT_MY_COIN_ID = 0
ASSERT_MY_PARENT_ID = 0
ASSERT_MY_PUZZLEHASH = 0
ASSERT_MY_AMOUNT = 0
ASSERT_SECONDS_RELATIVE = 0
ASSERT_SECONDS_ABSOLUTE = 0
ASSERT_HEIGHT_RELATIVE = 0
Expand Down
6 changes: 6 additions & 0 deletions chia/consensus/cost_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def calculate_cost_of_program(program: SerializedProgram, npc_result: NPCResult,
total_cost += len(cvp_list) * ConditionCost.ASSERT_HEIGHT_RELATIVE.value
elif condition is ConditionOpcode.ASSERT_MY_COIN_ID:
total_cost += len(cvp_list) * ConditionCost.ASSERT_MY_COIN_ID.value
elif condition is ConditionOpcode.ASSERT_MY_PARENT_ID:
total_cost += len(cvp_list) * ConditionCost.ASSERT_MY_PARENT_ID.value
elif condition is ConditionOpcode.ASSERT_MY_PUZZLEHASH:
total_cost += len(cvp_list) * ConditionCost.ASSERT_MY_PUZZLEHASH.value
elif condition is ConditionOpcode.ASSERT_MY_AMOUNT:
total_cost += len(cvp_list) * ConditionCost.ASSERT_MY_AMOUNT.value
elif condition is ConditionOpcode.RESERVE_FEE:
total_cost += len(cvp_list) * ConditionCost.RESERVE_FEE.value
elif condition is ConditionOpcode.CREATE_COIN_ANNOUNCEMENT:
Expand Down

0 comments on commit e76c400

Please sign in to comment.