Skip to content

Add availability endpoint to axum API#4216

Open
ss-es wants to merge 18 commits intomainfrom
ss/axum-2
Open

Add availability endpoint to axum API#4216
ss-es wants to merge 18 commits intomainfrom
ss/axum-2

Conversation

@ss-es
Copy link
Copy Markdown
Contributor

@ss-es ss-es commented Apr 23, 2026

This PR migrates the availability endpoint to Axum, with a copy of the old endpoint served at v1/availability and newer protobuf-specified endpoints served at v2/data and v2/consensus.

You can skip test_api.rs (this is just to render an example UI without having to compile espresso-node) and espresso.api.v2.rs (this is automatically generated).

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request expands the Espresso API by implementing the Data and Consensus APIs for v2 and the Availability API for v1. These changes introduce endpoints for retrieving namespace proofs, incorrect encoding proofs, state certificates, and stake tables, along with their corresponding proto definitions and Axum routing logic. The review feedback identifies a critical recurring logic error across several new handlers in crates/espresso/node/src/api/state.rs, where the join! macro is used twice on the same set of futures. This pattern is invalid as the first join! resolves the futures, causing subsequent calls to with_timeout or a second join! to fail during compilation.

Comment thread crates/espresso/node/src/api/state.rs Outdated
Comment thread crates/espresso/node/src/api/state.rs Outdated
Comment thread crates/espresso/node/src/api/state.rs Outdated
Comment thread crates/espresso/node/src/api/state.rs Outdated
Comment thread crates/espresso/api/src/axum.rs Outdated
Comment thread crates/espresso/api/src/axum.rs Outdated
Comment thread crates/serialization/api/proto/v2/consensus.proto Outdated
Comment thread crates/serialization/api/proto/v2/consensus.proto Outdated
@github-actions
Copy link
Copy Markdown
Contributor

Unable to build without Cargo.lock file.

This means that after this change 3rd party projects may have
difficulties using crates in this repo as a dependency. If this
isn't easy to fix please open an issue so we can fix it later.

For the first failing build see: https://github.com/EspressoSystems/espresso-network/actions/runs/24975975015

To reproduce locally run

cargo generate-lockfile
cargo check --all-targets

This PR can still be merged.

.await
.map(Json)
.map_err(ApiError::Internal)
};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part here feels a bit verbose and could probably be condensed. exploring options in the next PR.


// Fetch block and VID common data
let ds = &*self.data_source;
let timeout = std::time::Duration::from_millis(500);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems a bit weird, but the existing incorrect_encoding_proof path uses get_block_for_ns_proof which (I believe) does essentially the same thing

})?;

// Store the fetched certificate
ds.insert_state_cert(epoch, cert.clone()).await?;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this mirrors the existing get_state_cert in espresso/node/src/api/endpoints/availability.rs, though maybe we should revisit the behaviour

@ss-es ss-es marked this pull request as ready for review April 27, 2026 06:42
@ss-es ss-es requested a review from lukaszrzasik as a code owner April 27, 2026 06:42
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 27, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant