Skip to content

Commit afda7ac

Browse files
authored
fix: use extra pages available when deploying (#217)
* fix: use extra pages available when deploying * chore: fix audit issues
1 parent 97fb35c commit afda7ac

File tree

4 files changed

+45
-17
lines changed

4 files changed

+45
-17
lines changed

.github/workflows/check-python.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ jobs:
2323

2424
- name: Audit with pip-audit
2525
run: |
26-
# GHSA-4xh5-x5gv-qwph is safe to ignore since we are using a python version that is not affected
27-
# can remove once pip has fix
2826
# audit non dev dependencies, no exclusions
29-
poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt --ignore-vuln GHSA-4xh5-x5gv-qwph
27+
poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt
3028
3129
# audit all dependencies, with exclusions.
3230
# If a vulnerability is found in a dev dependency without an available fix,
3331
# it can be temporarily ignored by adding --ignore-vuln e.g.
3432
# --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency
35-
poetry run pip-audit --ignore-vuln GHSA-4xh5-x5gv-qwph
33+
poetry run pip-audit --ignore-vuln GHSA-4xh5-x5gv-qwph
3634
3735
- name: Check formatting with Ruff
3836
run: |

poetry.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/algokit_utils/applications/app_deployer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ def deploy(self, deployment: AppDeployParams) -> AppDeployResult:
317317

318318
existing_approval = base64.b64encode(existing_app_record.approval_program).decode()
319319
existing_clear = base64.b64encode(existing_app_record.clear_state_program).decode()
320-
existing_extra_pages = calculate_extra_program_pages(
321-
existing_app_record.approval_program, existing_app_record.clear_state_program
322-
)
320+
extra_pages = existing_app_record.extra_program_pages or 0
321+
322+
calculate_extra_program_pages(existing_app_record.approval_program, existing_app_record.clear_state_program)
323323

324324
new_approval = base64.b64encode(approval_program).decode()
325325
new_clear = base64.b64encode(clear_program).decode()
@@ -335,7 +335,7 @@ def deploy(self, deployment: AppDeployParams) -> AppDeployResult:
335335
< (deployment.create_params.schema.get("local_byte_slices", 0) if deployment.create_params.schema else 0)
336336
or existing_app_record.global_byte_slices
337337
< (deployment.create_params.schema.get("global_byte_slices", 0) if deployment.create_params.schema else 0)
338-
or existing_extra_pages < new_extra_pages
338+
or extra_pages < new_extra_pages
339339
)
340340

341341
if is_schema_break:

tests/applications/test_app_factory.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def test_deploy_app_update(factory: AppFactory) -> None:
240240
assert update_deploy_result.app.updated_round == confirmed_round
241241

242242

243-
def test_deploy_app_update_detects_extra_pages_as_breaking_change(
243+
def test_deploy_app_update_detects_extra_page_deficit_as_breaking_change(
244244
algorand: AlgorandClient, funded_account: SigningAccount
245245
) -> None:
246246
small_app_spec = (Path(__file__).parent.parent / "artifacts" / "extra_pages_test" / "small.arc56.json").read_text()
@@ -271,6 +271,36 @@ def test_deploy_app_update_detects_extra_pages_as_breaking_change(
271271
assert small_client.app_id != large_client.app_id
272272

273273

274+
def test_deploy_app_update_detects_extra_page_surplus_as_non_breaking_change(
275+
algorand: AlgorandClient, funded_account: SigningAccount
276+
) -> None:
277+
small_app_spec = (Path(__file__).parent.parent / "artifacts" / "extra_pages_test" / "small.arc56.json").read_text()
278+
large_app_spec = (Path(__file__).parent.parent / "artifacts" / "extra_pages_test" / "large.arc56.json").read_text()
279+
factory = algorand.client.get_app_factory(
280+
app_spec=small_app_spec,
281+
default_sender=funded_account.address,
282+
)
283+
small_client, create_deploy_result = factory.deploy(
284+
compilation_params={
285+
"updatable": True,
286+
},
287+
create_params=AppClientBareCallCreateParams(extra_program_pages=1),
288+
)
289+
assert create_deploy_result.operation_performed == OperationPerformed.Create
290+
assert create_deploy_result.create_result
291+
292+
factory._app_spec = Arc56Contract.from_json(large_app_spec) # noqa: SLF001
293+
large_client, update_deploy_result = factory.deploy(
294+
compilation_params={
295+
"updatable": True,
296+
},
297+
on_schema_break=OnSchemaBreak.AppendApp,
298+
on_update=OnUpdate.UpdateApp,
299+
)
300+
assert update_deploy_result.operation_performed == OperationPerformed.Update
301+
assert small_client.app_id == large_client.app_id
302+
303+
274304
def test_deploy_app_update_abi(factory: AppFactory) -> None:
275305
_, create_deploy_result = factory.deploy(
276306
compilation_params={

0 commit comments

Comments
 (0)