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

Add stylus programSize and programMemoryFootprint precompiles #120

Merged
merged 11 commits into from
Sep 6, 2023

Conversation

joshuacolvin0
Copy link
Member

@joshuacolvin0 joshuacolvin0 commented Aug 21, 2023

@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Merging #120 (6c21383) into stylus (d1ec217) will decrease coverage by 0.04%.
Report is 1 commits behind head on stylus.
The diff coverage is 68.42%.

@@            Coverage Diff             @@
##           stylus     #120      +/-   ##
==========================================
- Coverage   56.47%   56.44%   -0.04%     
==========================================
  Files         276      276              
  Lines       42665    42684      +19     
==========================================
- Hits        24094    24091       -3     
- Misses      16111    16118       +7     
- Partials     2460     2475      +15     

@cla-bot cla-bot bot added the s label Sep 6, 2023
Copy link
Contributor

@rachel-bousfield rachel-bousfield left a comment

Choose a reason for hiding this comment

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

Nice work, just some minor things :)

Comment on lines 92 to 96
programMemoryFootprint, err := arbWasm.ProgramMemoryFootprint(nil, programAddress)
Require(t, err)
if programMemoryFootprint != 1 {
Fatal(t, "unexpected memory footprint", programMemoryFootprint)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets move this to the memory test, which has an example that's known to be 120 pages :)

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

Comment on lines 87 to 91
programSize, err := arbWasm.ProgramSize(nil, programAddress)
Require(t, err)
if programSize < 5000 || programSize > 20000 {
Fatal(t, "unexpected size", programSize)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we know the exact size and could check against it

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

Comment on lines 336 to 346
func (p Programs) CodehashSize(codeHash common.Hash) (uint32, error) {
program, err := p.deserializeProgram(codeHash)
// wasmSize represents the number of half kb units, return as bytes
return uint32(program.wasmSize) * 512, err
}

func (p Programs) CodehashMemoryFootprint(codeHash common.Hash) (uint16, error) {
program, err := p.deserializeProgram(codeHash)
return program.footprint, err
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's name these ProgramSize and ProgramMemoryFootprint, but still have them take codehashes

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@joshuacolvin0
Copy link
Member Author

LGTM

Copy link
Contributor

@rachel-bousfield rachel-bousfield left a comment

Choose a reason for hiding this comment

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

Looks good!

@rachel-bousfield rachel-bousfield merged commit f47fec1 into stylus Sep 6, 2023
7 checks passed
@rachel-bousfield rachel-bousfield deleted the footprint-precompile branch September 6, 2023 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants