-
Notifications
You must be signed in to change notification settings - Fork 431
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
Modify static buffer size via env var #1869
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1869 +/- ##
==========================================
- Coverage 52.97% 52.95% -0.02%
==========================================
Files 212 212
Lines 6728 6728
==========================================
- Hits 3564 3563 -1
- Misses 3164 3165 +1
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
Do you want to implement |
This is a |
But it seems you try to use the same idea with the build script but use the |
|
My concern is that with the env variable we introduce another means of configuring the ink! environment, besides the trait. And that mean is outside of the usual Rust primitives. It will be easy to overlook that the (hidden) I'm in favor of merging #1872. It's also not an ideal solution, but in my opinion given the circumstances the best choice: setting this variable in |
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.
On balance I think this is the lesser of two evils.
I don't think using an .env
file is a good idea though. Instead we should take a leaf out of cargo
s book and allow it to be configured by (in order of precedence):
- Command line arg e.g.
cargo contract build --static-buffer-size 16384
- Config in the contracts
Cargo.toml
using either a custom section or the[env]
section - Just using the env var itself if set
cargo clean must be run every time the buffer size is modified.
This can be solved in cargo-contract
by first checking the existing metadata for the existing buffer size, and running cargo clean
if the new value is different.
Note that a possible alternative implementation of this avoiding the #[from_env("INK_STATIC_BUFFER_SIZE")]
const BUFFER_SIZE: usize = 1 << 14; |
Agreed.
While it looks cleaner, it doesn't gives us much flexibility in terms of error reporting. However, I will test it out and see |
I am reaching out to seek an update on the status of the issue at hand. Could you kindly confirm if it has been successfully resolved? If so, I would be most grateful for your guidance on the specific changes required in my Ink contract. Additionally, I would like to know whether it is necessary to create a .env file in my contract folder. Your assistance and clarification on these matters would be greatly appreciated. |
This is a trivial solution addressing #1471 by introducing a build script to
ink_env
crate which read theINK_STATIC_BUFFER_SIZE
env var and appends the constant to a file. It has been tested to work.Because the value is baked into the
ink_env
binaries,cargo clean
must be run every time the buffer size is modified.Checklist:
.env
files in a contract project and propagate the env values to the coreink
cratesFollow-ups:
cargo-contract
to pass read contract's local.env
file and append the env vars to the build command.