-
Notifications
You must be signed in to change notification settings - Fork 1
adds beacon api #81
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
Open
0w3n-d
wants to merge
40
commits into
main
Choose a base branch
from
od/beacon_api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
adds beacon api #81
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
578f8a9
adds beacon api
0w3n-d 0021e4e
Merge branch 'main' into od/beacon_api
Bronek d096b51
Documentation of planned Beacon API work
Bronek 87c400b
Merge branch 'main' into od/beacon_api
Bronek b977f93
Extract HTTP server byte machine into silver_httpcore
Bronek 42d86da
Move HTTP client machine into silver_httpcore; delete dead IPC transport
Bronek e7cbd99
Table-based dispatch for beacon_api routes
Bronek 96a900c
Rename crates/engine to crates/engine_api
Bronek 36f291e
Consolidate API access into the client_server tile
Bronek bd42255
Harden API transport: zero-alloc hot-path test, conn cap, lazy buffers
Bronek cc94b7f
Add inbound and outbound API deadlines (CL-114, CL-115)
Bronek e68926d
Support multiple simultaneous beacon-api binds
Bronek 828ebdb
Refresh ADRs 0002 and 0004 for team decisions of 2026-08-18
Bronek bbfee39
httpcore: negotiation headers, query decoding, 400 on provable garbage
Bronek 89d6bcd
Widen Response: any status, extra headers, indexed errors
Bronek 29ee6f2
Spec-flavour JSON writers for beacon-api responses
Bronek 89850ce
Thread NodeStatus and spec config into the beacon API
Bronek 69331e5
Merge branch 'main' into od/beacon_api
Bronek 24b5755
Doc: ClientServer consumes beacon_events and sync_target for node status
Bronek da35584
Serve the beacon-API bootstrap statics: node/version+health, config/*
Bronek c2207e2
Serve beacon/genesis and per-state fork + finality checkpoints
Bronek c4c6517
Publish the head's execution status on BeaconStateEvent::Status
Bronek 040d5d4
Merge branch 'main' into od/beacon_api
Bronek bb57694
Serve node/syncing and node/peer_count
Bronek 0c5652c
Serve the validator registry
Bronek 6ec5f7a
Amend ADR-0004 for the validator registry's cost
Bronek cb01bc0
Publish the head block's root beside the state it produced
Bronek 0d7f348
Serve block roots and the head's header
Bronek 3c06453
Serve proposer and sync-committee duties
Bronek 93cf03a
Serve the validator client's receipt POSTs
Bronek 714b011
Merge branch 'main' into od/beacon_api
Bronek d894b38
Rename the client_server tile to application_boundary
Bronek ef618e5
Linger on a refused request instead of resetting it
Bronek bfed02b
Derive the network's name from its genesis fork version
Bronek b8f688f
Correct client-behaviour claims and the v2 dependent root
Bronek d5e32b0
Amend ADRs, mark as accepted
Bronek 9c25c25
Share one readiness loop between the tile's two HTTP tenants
Bronek b0c4dca
Stub the endpoints that outrun the data the node keeps
Bronek 36d9bc6
Drop the head-root plumbing the stubs orphaned
Bronek 6d19683
Merge branch 'main' into od/beacon_api
Bronek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| [package] | ||
| name = "silver_application_boundary" | ||
| edition.workspace = true | ||
| repository.workspace = true | ||
| rust-version.workspace = true | ||
| version.workspace = true | ||
|
|
||
| [dependencies] | ||
| flux.workspace = true | ||
| silver_beacon_api.workspace = true | ||
| silver_beacon_state_data.workspace = true | ||
| silver_common.workspace = true | ||
| silver_config.workspace = true | ||
| silver_engine_api.workspace = true | ||
| silver_httpcore.workspace = true | ||
|
|
||
| [dev-dependencies] | ||
| hex.workspace = true | ||
| serde_json.workspace = true | ||
| silver_engine_api = { workspace = true, features = ["test-el"] } | ||
| tempfile = "3" | ||
|
|
||
| [lints] | ||
| workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| use std::time::Duration; | ||
|
|
||
| use flux::{spine::SpineAdapter, tile::Tile}; | ||
| use silver_beacon_api::{BeaconApi, SlotStatus}; | ||
| use silver_beacon_state_data::{BeaconStateReader, SpecConfig}; | ||
| use silver_common::{ | ||
| BeaconStateEvent, Enr, Identify, Keypair, SilverSpine, SyncUpdate, TProducer, TRandomAccess, | ||
| }; | ||
| use silver_config::EngineConfig; | ||
| use silver_engine_api::EngineApi; | ||
| use silver_httpcore::{Bind, Readiness, TokenRange}; | ||
|
|
||
| /// A tenant added here takes the next share of a raised `TENANTS`, which keeps | ||
| /// every share disjoint without a base to compute. | ||
| const TENANTS: usize = 2; | ||
| const BEACON_TOKENS: TokenRange = TokenRange::share(0, TENANTS); | ||
| const ENGINE_TOKENS: TokenRange = TokenRange::share(1, TENANTS); | ||
|
|
||
| pub struct ApplicationBoundaryTile { | ||
| readiness: Readiness, | ||
| pub beacon: BeaconApi, | ||
| engine: EngineApi, | ||
| } | ||
|
|
||
| impl Tile<SilverSpine> for ApplicationBoundaryTile { | ||
| fn loop_body(&mut self, adapter: &mut SpineAdapter<SilverSpine>) { | ||
| self.engine.intake(adapter); | ||
| self.readiness.wait(Duration::ZERO); | ||
| self.engine.spin(adapter, self.readiness.events()); | ||
| self.refresh_node_status(adapter); | ||
| if self.beacon.pump(self.readiness.events()) { | ||
| adapter.mark_work(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl ApplicationBoundaryTile { | ||
| #[allow(clippy::too_many_arguments)] | ||
| pub fn new( | ||
| binds: &[Bind], | ||
| max_connections: usize, | ||
| idle_timeout: Duration, | ||
| keypair: &Keypair, | ||
| local_enr: Enr, | ||
| identify: &Identify, | ||
| spec: &SpecConfig, | ||
| state: BeaconStateReader, | ||
| engine_config: EngineConfig, | ||
| gossip_consumer: TRandomAccess, | ||
| rpc_consumer: TRandomAccess, | ||
| resp_producer: TProducer, | ||
| ) -> Self { | ||
| // A batch too small for every socket the tile can register leaves the | ||
| // rest of a busy iteration's readiness for the next one. | ||
| let sockets = | ||
| binds.len() + max_connections + EngineApi::max_sockets(engine_config.max_connections); | ||
|
|
||
| let readiness = Readiness::new(sockets); | ||
| let beacon = BeaconApi::new( | ||
| readiness.registry(), | ||
| BEACON_TOKENS, | ||
| binds, | ||
| max_connections, | ||
| idle_timeout, | ||
| keypair, | ||
| local_enr, | ||
| identify, | ||
| spec, | ||
| state, | ||
| ); | ||
| let engine = EngineApi::new( | ||
| readiness.registry(), | ||
| ENGINE_TOKENS, | ||
| engine_config, | ||
| gossip_consumer, | ||
| rpc_consumer, | ||
| resp_producer, | ||
| ); | ||
| Self { readiness, beacon, engine } | ||
| } | ||
|
|
||
| fn refresh_node_status(&mut self, adapter: &mut SpineAdapter<SilverSpine>) { | ||
| let status = self.beacon.node_status_mut(); | ||
|
|
||
| // Consumed every iteration, and never behind the engine's capacity | ||
| // gate: a consumer's first `consume` jumps its cursor to the | ||
| // producer's write head, so a queue left unread while the pool is | ||
| // saturated loses everything published in the meantime. | ||
| adapter.consume(|event: BeaconStateEvent, _| { | ||
| if let BeaconStateEvent::Status { | ||
| latest_block_slot, wall_slot, head_optimistic, .. | ||
| } = event | ||
| { | ||
| status.slots = | ||
| Some(SlotStatus { head_slot: latest_block_slot, wall_slot, head_optimistic }); | ||
| } | ||
| }); | ||
| adapter.consume(|update: SyncUpdate, _| { | ||
| status.syncing = !matches!(update, SyncUpdate::Following); | ||
| }); | ||
|
|
||
| status.el = self.engine.sync_status(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 have no idea what this comment means - what is a tenant and what is a 'TENANTS'?