-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Feat] Announce new blocks via IPC #3002
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
base: staging
Are you sure you want to change the base?
Conversation
|
Have you thought about exposing a simple high-level function, such as
Somewhat of a tangent: For validators, snarkOS sync does not insert blocks into the ledger until they are confirmed by the next block. The goal is for clients to eventually move to the same, safer, mechanism. |
I'm not sure if this is desirable, as other potential mechanisms (e.g. the network) could be too slow to introduce at this stage, as it could slow down the validator. This way we can ensure that the announcements are near-instantaneous. |
|
I was thinking of something very simple, like adding a condition variable (or async fn wait_for_block_height(&self, next_height: u32) {
while self.current_block.read().height() < next_height {
self.block_notify.notified().await;
}
}One could then spawn a task in snarkOS, or whatever uses snarkVM, that waits on this function and executes some custom logic (like writing to a UNIX socket). |
|
Part of the design is to not have to have a dependency on snarkVM at all, it's a large library. |
Signed-off-by: ljedrz <[email protected]>
Signed-off-by: ljedrz <[email protected]>
921cedd to
15c0771
Compare
|
Rebased, now that the former base is in. It was clean, and there were no other changes. |
Signed-off-by: ljedrz <[email protected]>
niklaslong
left a comment
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.
LGTM! For visibility @ljedrz could you mention how your testing has impacted the validator in the following cases:
- the indexer is not connected to the validator but the feature is enabled
- similarly the indexer goes down mid-stream
- would a large block impact consensus at all (serialisation cost)?
Every time a block is baked, a
The same thing happens, there's just an additional initial
I've calculated the average serialization speed in a test run, and got ~857MiB/s (and this was in a backfilling run with parallel serialization, and small blocks, both of which were certain to decrease the calculated speed). This means that a 1MiB block would be serialized in ~1.1ms, and that's with a machine below validator specs. |
Co-authored-by: Kai Mast <[email protected]> Signed-off-by: ljedrz <[email protected]>
|
|
||
| #[cfg(feature = "announce-blocks")] | ||
| fn start_block_announcement_stream() -> Option<Stream> { | ||
| let path = std::env::var("BLOCK_ANNOUNCE_PATH") |
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.
Side note: We should probably have a unified source that documenst all the environment variables that are used.
|
I think we should document what functionality the new feature enables somewhere. You could use this README change from the You might want to add a note that this is an "unstable" feature and that the wire format can change in the future, just to be safe. |
Signed-off-by: ljedrz <[email protected]>
|
I filed a dedicated issue to later document this feature, so as to not cause any conflict with the changes linked by @kaimast. |
Signed-off-by: ljedrz <[email protected]>
Introduction
This is a proposal for a new feature which would allow freshly inserted blocks to be streamed via an IPC socket.
Use cases
The expected users are those who seek to receive information on new blocks as soon as possible (e.g. block explorers), and potentially (if only transmitting further, or with some manual deserialization) without even having to depend on snarkVM. This feature can also be used in test-related tools which produce blocks, e.g. in tandem with the
testchain-generator, for immediate consumption by other tools.Why not implement this in snarkOS?
Ledgeritself) so no other place requires the announcement code to be attached.try_advance_to_next_block, which then notifies other nodes via theBlockLocatorsmechanism, which means attaching this setup there would incur additional database queries and cloning (as theBlockis not readily available).Additional considerations
bincodecould be changed to some more commonserde-compatibleserialization format