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

Lightshift - Rust precompile #1

Open
wants to merge 5 commits into
base: optimism
Choose a base branch
from

Conversation

jmoreira-ls
Copy link
Collaborator

This is the implementation of Black 76 precompile in Rust for Geth. This uses Lyra's implementation of Black 76 in Rust, in the cockpit repo.

Using the previous tests for the Solidity implementation, it is within acceptable margin of errors. The deviations are mainly due to the fact that the input values (in bytes) are integer, which need to be translated into floats to be able to use the third-party Rust packages.

The return values instead of being 256 bit unsigned integers, like the Solidity implementation, are 128 bit unsigned integers due to the Rust limits.

After benchmarking, we estimated that the gas cost for running this precompile is around 300. This was done by using the benchmark utility of Go and looking at the average mgas/s of the other precompiles. You can find our findings below:

Existing precompile benchmarks
Screenshot from 2024-09-06 11-44-23
Screenshot from 2024-09-06 11-50-26
Screenshot from 2024-09-06 11-52-45
Screenshot from 2024-09-06 11-55-45
Screenshot from 2024-09-06 11-59-19

Black 76 precompile benchmark
Screenshot from 2024-09-16 13-41-08

}

let (exponent, expiry_sec, discount, vol, fwd, strike) = extract_arguments(args);
// println!("EXPONENT {} | EXPIRY_SEC {} | DISCOUNT {} | VOL {} | FWD {} | STRIKE {}", exponent, expiry_sec, discount, vol, fwd, strike);
Copy link

@joshpwrk joshpwrk Oct 2, 2024

Choose a reason for hiding this comment

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

can remove this plus bunch of other comments in this file

@jmoreira-ls jmoreira-ls requested a review from joshpwrk October 8, 2024 06:37
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