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

bugfix: fix inconsistent order of static entries between padding and … #295

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,28 @@ impl FrameTableBuilder {
// Prepare for the next slice. This will remove all the entries that are returned
fn flush(&mut self) -> specs::jtable::FrameTable {
let frame_table = {
/* self.current_returned.iter().rev(), why rev()?
*
* Support an image has start function, then initial_frame_entries should have two entries:
* * zkmain -> 0
* * start -> zkmain
* If we pad a slice, the inherited frame entries of the trivial slice should have two entries with ordering,
* but if first non-trivial slice terminating, 'current_returned' with 'inherited = true' will have
* two entires with reverse ordering, since frame it's a stack(pop from current_unreturned then push into current_returned).
* This crashes commitment checking between trivial slice's post image table and first non-trivial slice's pre image table.
*/
let inherited = self
.current_returned
.current_unreturned
.iter()
.chain(self.current_unreturned.iter())
.chain(self.current_returned.iter().rev())
.filter(|entry| entry.inherited)
.map(Into::into)
.collect::<Vec<InheritedFrameTableEntry>>();

let called = self
.current_returned
.current_unreturned
.iter()
.chain(self.current_unreturned.iter())
.chain(self.current_returned.iter())
.filter(|entry| !entry.inherited)
.map(Into::into)
.collect::<Vec<CalledFrameTableEntry>>();
Expand Down
Loading