Skip to content

Comments

fix(avm)!: last_child id constraints#16568

Merged
IlyasRidhuan merged 1 commit intonextfrom
ir/08-25-fix_avm_last_child_id_constraints
Aug 29, 2025
Merged

fix(avm)!: last_child id constraints#16568
IlyasRidhuan merged 1 commit intonextfrom
ir/08-25-fix_avm_last_child_id_constraints

Conversation

@IlyasRidhuan
Copy link
Contributor

@IlyasRidhuan IlyasRidhuan commented Aug 25, 2025

Adds the constraints for the last_child_id introduced in #16531. It has similar behaviour to other return data information stored in the context

Copy link
Contributor Author

IlyasRidhuan commented Aug 25, 2025

Copy link
Contributor

@dbanks12 dbanks12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, but a couple concerns

Comment on lines 231 to 232
#[ENTER_CALL_LAST_CHILD_ID]
NOT_LAST_EXEC * (sel_enter_call + sel_error) * last_child_id' = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the + sel_error? sel_enter_call implies sel_error == 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah so last_child_id of the next row should be 0 if we either enter a new call context or if we have an exceptional halt. Thinking about this some more i think there might be an issue with the other returndatas as well

  1. It might need to only be for nested exceptional halt, in a top level halt we do nothing anyways
  2. We zero out rd_size and rd_addr so that the parent context can't access a failed child context's memory via returndata. However, in our current execution flow we don't zero it out.

I'll think abit more about it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer zero out last_child_id if we exit a failing call

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the TS simulator, I think if a nested call exceptionally halts, its empty returndata becomes the parents "last child's returndata".
image

@IlyasRidhuan IlyasRidhuan changed the base branch from ir/08-19-fix_avm_handle_zero_copy_size to graphite-base/16568 August 27, 2025 15:01
@IlyasRidhuan IlyasRidhuan force-pushed the ir/08-25-fix_avm_last_child_id_constraints branch from 95932af to 9093797 Compare August 27, 2025 15:17
@IlyasRidhuan IlyasRidhuan changed the base branch from graphite-base/16568 to ir/08-19-fix_avm_handle_zero_copy_size August 27, 2025 15:17

check_relation<context>(trace);

// TODO: Migrate to check_interaction pattern once these lookups are added in a builder
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to clean up this todo as well

lookup_context_ctx_stack_return_settings>(trace);
}

TEST(ContextConstrainingTest, ContextSwitchingExceptionalHalt)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test to check correct reset during an exceptional halt

@IlyasRidhuan IlyasRidhuan force-pushed the ir/08-19-fix_avm_handle_zero_copy_size branch from 08e8cf0 to 9965aa8 Compare August 28, 2025 08:16
@IlyasRidhuan IlyasRidhuan force-pushed the ir/08-25-fix_avm_last_child_id_constraints branch from 9093797 to b3ed32f Compare August 28, 2025 08:16
Copy link
Contributor

@dbanks12 dbanks12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to unblock, but want to review for real later.

@IlyasRidhuan IlyasRidhuan changed the base branch from ir/08-19-fix_avm_handle_zero_copy_size to graphite-base/16568 August 28, 2025 20:35
@IlyasRidhuan IlyasRidhuan force-pushed the ir/08-25-fix_avm_last_child_id_constraints branch from b3ed32f to 8d6f1cd Compare August 29, 2025 09:35
@IlyasRidhuan IlyasRidhuan changed the base branch from graphite-base/16568 to next August 29, 2025 09:35
@IlyasRidhuan IlyasRidhuan added this pull request to the merge queue Aug 29, 2025
Merged via the queue into next with commit 34720e1 Aug 29, 2025
11 of 12 checks passed
@IlyasRidhuan IlyasRidhuan deleted the ir/08-25-fix_avm_last_child_id_constraints branch August 29, 2025 12:01
ludamad pushed a commit that referenced this pull request Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants