Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulation: Lift log limits option in SimulateRequest #469

Merged
merged 23 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion algosdk/atomic_transaction_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,11 @@ def __init__(
*,
max_log_calls: Optional[int] = None,
ahangsu marked this conversation as resolved.
Show resolved Hide resolved
max_log_size: Optional[int] = None,
allow_empty_signatures: Optional[int] = None,
jasonpaulos marked this conversation as resolved.
Show resolved Hide resolved
) -> None:
self.max_log_calls = max_log_calls
self.max_log_size = max_log_size
self.allow_empty_signatures = allow_empty_signatures

@staticmethod
def from_simulation_result(
Expand All @@ -289,6 +291,10 @@ def from_simulation_result(
eval_override.max_log_calls = eval_override_dict["max-log-calls"]
if "max-log-size" in eval_override_dict:
eval_override.max_log_size = eval_override_dict["max-log-size"]
if "allow-empty-signatures" in eval_override_dict:
eval_override.allow_empty_signatures = eval_override_dict[
"allow-empty-signatures"
]

return eval_override

Expand Down Expand Up @@ -725,7 +731,8 @@ def simulate(

Args:
client (AlgodClient): Algod V2 client
request (models.SimulateReuqest): SimulateRequest with options in simulation.
request (models.SimulateRequest): SimulateRequest with options in simulation.
The request's transaction group will be overrwritten by the composer's group, only simulation related options will be used.

Returns:
SimulateAtomicTransactionResponse: Object with simulation results for this
Expand Down
4 changes: 4 additions & 0 deletions algosdk/v2client/models/simulate_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,24 @@ def dictify(self) -> Dict[str, Any]:
class SimulateRequest(object):
txn_groups: List[SimulateRequestTransactionGroup]
allow_more_logs: bool
allow_empty_signatures: bool

def __init__(
self,
*,
txn_groups: List[SimulateRequestTransactionGroup],
allow_more_logs: bool = False,
allow_empty_signatures: bool = False,
) -> None:
self.txn_groups = txn_groups
self.allow_more_logs = allow_more_logs
self.allow_empty_signatures = allow_empty_signatures

def dictify(self) -> Dict[str, Any]:
return {
"txn-groups": [
txn_group.dictify() for txn_group in self.txn_groups
],
"allow-more-logging": self.allow_more_logs,
"allow-empty-signatures": self.allow_empty_signatures,
}
20 changes: 11 additions & 9 deletions tests/steps/other_v2_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1446,13 +1446,14 @@ def simulate_transaction(context):

@then("the simulation should succeed without any failure message")
def simulate_transaction_succeed(context):
if hasattr(context, "simulate_response"):
assert "failure-message" not in context.simulate_response["txn-groups"]
else:
assert (
len(context.atomic_transaction_composer_return.failure_message)
== 0
)
resp = (
context.simulate_response
if hasattr(context, "simulate_response")
else context.atomic_transaction_composer_return.simulate_response
)

for group in resp["txn-groups"]:
assert "failure-message" not in group


@then("I simulate the current transaction group with the composer")
Expand Down Expand Up @@ -1488,8 +1489,8 @@ def allow_more_logs_in_request(context):
context.simulate_request.allow_more_logs = True


@then("I attach the simulate request to simulate the transaction group.")
def attach_sim_request_to_txn_group_simulation(context):
@then("I simulate the transaction group with the simulate request.")
def simulate_group_with_request(context):
context.atomic_transaction_composer_return = (
context.atomic_transaction_composer.simulate(
context.app_acl, context.simulate_request
Expand All @@ -1499,6 +1500,7 @@ def attach_sim_request_to_txn_group_simulation(context):

@then("I check the simulation result has power packs allow-more-logging.")
def power_pack_simulation_should_pass(context):
assert context.atomic_transaction_composer_return.eval_overrides
assert (
context.atomic_transaction_composer_return.eval_overrides.max_log_calls
)
Expand Down