Comments (8)
In C, you will be able to allocate a blob on the stack with the new definition like this:
uint8_t blob[s->bytes_per_blob];But I'm not a huge fan of this and I think it might have some portability issues.
Don't do this. Not only does this indeed have portability issues: Automatic storage duration (i.e. in practise stack-allocated) VLAs are optional even in C23 (Note VLAs as types are fine, e.g. as argument types. This still can take malloc-allocated or fixed-size array from callers).
Furthermore, the behaviour/error handling when running out of stack-memory is generally not robust: You cannot portably guard against this beforehand, I don't think you can catch it and if you are unlucky, it's a security issue (if mem_needed > stack_availiable + guard_page_size, assume bad things may happen unless you can prove otherwise).
from c-kzg-4844.
For Teku, it will simplify the java bindings (no need of two libs) and allows us to run the consensus reference tests without doing too many hacky changes. So overall I am happy with this change. Is there a possibility of doing another audit after this change?
from c-kzg-4844.
it would definitely be amazing for supporting minimal setups 👍
from c-kzg-4844.
Nim is flexible enough to handle multiple configurations thanks to it's powerful metaprogramming. But this changes clearly will make Nimbus code cleaner.
from c-kzg-4844.
Super helpful in lighthouse as well since we don't have to resort to importing the same library twice
from c-kzg-4844.
Minor: Reduce the amount of heavy 128kb blobs on the stack (our sizes are not a problem for modern computers)
Slightly more complicated memory management because of dynamic heap usage instead of static stack usage
I don't think these two sentences make sense. Whether the blobs are in the stack or the heap doesn't depend on the library definition, but depends on the library users and bindings. For example, if I have a definition of
typedef struct {
uint8_t bytes[BYTES_PER_BLOB];
} Blob;
It doesn't mean immediately that the blobs will always be on the stack. If the user wants it to be on the stack, they can do so.
Blob blob;
If the user wants it to be on the heap, they can also do so.
Blob *blob = malloc(sizeof(Blob));
The same reason can be applied to the new blob definition. (uint8_t *blob
)
from c-kzg-4844.
@ppopth you're right. With our current definition of Blob
, you can allocate a blob on the stack or heap. I think this point stems from the Rust bindings, where the Blob
definition being used (see below) is difficult to directly allocate on the heap. They needed to do something like this to accommodate.
#[repr(C)]
pub struct Blob {
bytes: [u8; BYTES_PER_BLOB],
}
In C, you will be able to allocate a blob on the stack with the new definition like this:
uint8_t blob[s->bytes_per_blob];
But I'm not a huge fan of this and I think it might have some portability issues.
from c-kzg-4844.
This is no longer necessary. As of #377, mainnet & minimal use the same trusted setup.
from c-kzg-4844.
Related Issues (20)
- Rust benchmarks are broken HOT 2
- Consider using a char buffer instead of FILE HOT 5
- Can I just compile as a lib in C? HOT 3
- Some ops seem exceedingly slow on Apple M2 HOT 11
- Crashes with SIGILL on Linux/amd64 i7 CPU HOT 3
- Add library prefix to all ckzg symbols HOT 7
- Broken CI in rust-windows because of rust-1.7.0 HOT 1
- Stack overflow in Rust benchmarks on Windows HOT 1
- Nodejs does not support browsers HOT 5
- Problems with cross-platform docker images HOT 6
- Release Rust bindings on crates.io HOT 3
- Support new function ckzg_load_trusted_setup_from_bytes HOT 3
- Rust binding can't cross compile on Apple Silicon HOT 3
- Rust bindings lack flexibility with current structure of build script HOT 3
- Rust build.rs: Pass -D__BLST_NO_ASM__ on non-x86-64/non-aarch64 ISAs HOT 7
- Python bindings' load_trusted_setup() segfaults if file does not exist HOT 1
- Blob value in argument to context.VerifyBlobKZGProof HOT 1
- [rust] Add compute_* verify_* functionsfor KzgSettings HOT 3
- no pypi source packages HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c-kzg-4844.