-
Notifications
You must be signed in to change notification settings - Fork 53
feat: cache contracts before benching #254
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
Conversation
✅ Deploy Preview for contracts-stylus canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
Doesn't work 😢 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great to see that this now works!
At first glance it seems like a 20k reduction in gas usage? Nice!
I can't approve cause I opened the PR lol
benches/src/access_control.rs
Outdated
@@ -50,7 +50,9 @@ pub async fn bench() -> eyre::Result<Report> { | |||
.wallet(EthereumWallet::from(bob.signer.clone())) | |||
.on_http(bob.url().parse()?); | |||
|
|||
let contract_addr = deploy(&alice).await; | |||
let contract_addr = deploy(&alice).await?; | |||
crate::cache_contract(&alice, contract_addr)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this can be part of deploy
? And maybe change deploy
's signature to receive a enum CachePolicy { None, Bid(u64) }
which determines whether we cache or not? (this may seem overengineered, but it is forward-compatible)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also deploy_with_cache(&alice).await?
could make, sense since 0
bid is always acceptable on nitro test node.
But I was thinking to have it separate for now. And later add analytics of how contracts perform with cache and without it in the single report. Also to track improvements of caching separate from contracts
println!(); | ||
println!("{report}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
println!(); | |
println!("{report}"); | |
println!("\n{report}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kinda personal. For me add or remove another line is faster, then change a specific symbol:)
@@ -5,9 +5,14 @@ MYDIR=$(realpath "$(dirname "$0")") | |||
cd "$MYDIR" | |||
cd .. | |||
|
|||
NIGHTLY_TOOLCHAIN=${NIGHTLY_TOOLCHAIN:-nightly} | |||
NIGHTLY_TOOLCHAIN=${NIGHTLY_TOOLCHAIN:-nightly-2024-01-01} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use a more recent nightly like 2024-09-01
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alas, recent nightly versions do not work. That is another problem why we're pinned. Also I've checked that on stable not just binary size is bigger, but benchmarks perform %2-3 worse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this pr we will update nightly
till minimal working version everywhere in the project
I also think that panicking is fine here, since this is not user-facing, but not a strong opinion! |
Co-authored-by: alexfertel <[email protected]>
@alexfertel thanks for the review! It seems for me that caching doesn't make that big difference. But still |
@alexfertel this looks great! Thanks for continuing the work/review this. @qalisander WDYT? |
@ggonzalez94 yeah. I've been planning to do it. Check out gas benchmark report now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome! Just a few nits and a questions. But looks ready to go 🚀
Co-authored-by: Gustavo Gonzalez <[email protected]>
@ggonzalez94 @alexfertel It happened! Check out gas benchmarks now:) Just a small bug with pricing was fixed inside nitro node |
oooooh, they look much closer to the Solidity ones now! 🚀 Interesting that the merkle proof stayed the same. Overall looks great |
Merkle proof doesn't write to storage. The bug was connected with charging fees multiple times for on-chain storage access |
Use the
cargo stylus cache
to cache contracts in theCacheManager
before running benches.