Skip to content

Commit

Permalink
Merge pull request #14 from SCMusson/bump_versions
Browse files Browse the repository at this point in the history
Bump versions
  • Loading branch information
nielstron authored Oct 17, 2024
2 parents 3ab945e + 6dd0eee commit 4809cc0
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 37 deletions.
3 changes: 3 additions & 0 deletions plutus_bench/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ def epoch_latest_parameters(self, **kwargs):
k: self._protocol_param.cost_models[k]
for k in self._protocol_param.cost_models
},
"min_fee_ref_script_cost_per_byte": self._protocol_param.min_fee_reference_scripts[
"min_fee_ref_script_cost_per_byte"
],
}

@request_wrapper
Expand Down
1 change: 1 addition & 0 deletions plutus_bench/protocol_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,5 @@
"verifySchnorrSecp256k1Signature-memory-arguments": 10,
},
},
min_fee_reference_scripts={"min_fee_ref_script_cost_per_byte": 15},
)
2 changes: 1 addition & 1 deletion plutus_bench/to_script_context_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ def to_tx_info(
]
+ tx.transaction_witness_set.plutus_data
},
{pycardano.datum_hash(r): r for r in tx.transaction_witness_set.redeemer},
{pycardano.todo_datum_hash(r): r for r in tx.transaction_witness_set.redeemer},
to_tx_id(tx_body.id),
)
50 changes: 39 additions & 11 deletions plutus_bench/tx_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ def to_tx_in_info(i: pycardano.TransactionInput, o: pycardano.TransactionOutput)
)


def to_redeemer_purpose(r: pycardano.Redeemer, tx_body: pycardano.TransactionBody):
def to_redeemer_purpose(
r: Union[pycardano.RedeemerKey, pycardano.Redeemer],
tx_body: pycardano.TransactionBody,
):
v = r.tag
if v == pycardano.RedeemerTag.SPEND:
spent_input = tx_body.inputs[r.index]
Expand Down Expand Up @@ -182,6 +185,7 @@ def to_tx_info(
]
if tx.transaction_witness_set.plutus_data:
datums += tx.transaction_witness_set.plutus_data

redeemers = (
tx.transaction_witness_set.redeemer
if tx.transaction_witness_set.redeemer
Expand All @@ -208,7 +212,11 @@ def to_tx_info(
if tx_body.required_signers
else []
),
{to_redeemer_purpose(r, tx_body): r.data for r in redeemers},
(
{to_redeemer_purpose(k, tx_body): v.data for k, v in redeemers.items()}
if isinstance(redeemers, pycardano.RedeemerMap)
else {to_redeemer_purpose(r, tx_body): r.data for r in redeemers}
),
{pycardano.datum_hash(d).payload: d for d in datums},
to_tx_id(tx_body.id),
)
Expand All @@ -218,7 +226,7 @@ def to_tx_info(
class ScriptInvocation:
script: pycardano.ScriptType
datum: Optional[pycardano.Datum]
redeemer: pycardano.Redeemer
redeemer: Union[pycardano.Redeemer, pycardano.RedeemerMap]
script_context: ScriptContext


Expand Down Expand Up @@ -248,6 +256,19 @@ def generate_script_contexts(tx_builder: pycardano.TransactionBuilder):
)


def as_redeemer(
r: Union[pycardano.Redeemer, pycardano.RedeemerKey], redeemers: pycardano.Redeemers
):
if isinstance(r, pycardano.RedeemerKey):
v = redeemers[r]
new_r = pycardano.Redeemer(data=v.data, ex_units=v.ex_units)
new_r.tag = r.tag
new_r.index = r.index
return new_r
else:
return r


def generate_script_contexts_resolved(
tx: pycardano.Transaction,
resolved_inputs: List[UTxO],
Expand All @@ -266,10 +287,14 @@ def generate_script_contexts_resolved(
if not isinstance(spending_input.output.address.payment_part, ScriptHash):
continue
try:
spending_redeemer = next(
r
for r in tx.transaction_witness_set.redeemer
if r.index == i and r.tag == RedeemerTag.SPEND
# Redeemers is Union[RedeemerMap, List[Redeemer]]
spending_redeemer = as_redeemer(
next(
r
for r in tx.transaction_witness_set.redeemer
if r.index == i and r.tag == RedeemerTag.SPEND
),
tx.transaction_witness_set.redeemer,
)
except (StopIteration, TypeError):
raise ValueError(
Expand Down Expand Up @@ -318,10 +343,13 @@ def generate_script_contexts_resolved(
)
for i, minting_script_hash in enumerate(tx.transaction_body.mint or []):
try:
minting_redeemer = next(
r
for r in tx.transaction_witness_set.redeemer
if r.index == i and r.tag == RedeemerTag.MINT
minting_redeemer = as_redeemer(
next(
r
for r in tx.transaction_witness_set.redeemer
if r.index == i and r.tag == RedeemerTag.MINT
),
tx.transaction_witness_set,
)
except StopIteration:
raise ValueError(
Expand Down
42 changes: 19 additions & 23 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ packages = [{include = "plutus_bench"}]

[tool.poetry.dependencies]
python = ">=3.10, <3.12"
uplc = "^1.0.4"
pycardano = {git = "https://github.com/Python-Cardano/pycardano", branch = "main"}
uplc = "^1.0.7"
pycardano = "^0.12.0"
fastapi = "^0.110.1"
uvicorn = "^0.29.0"
starlette = "^0.37.2"
Expand Down

0 comments on commit 4809cc0

Please sign in to comment.