Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 1 addition & 10 deletions lean_client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Commit of lean specification. Allows to specify which spec version to use,
# when generating test vectors.
LEAN_SPEC_COMMIT ?= f12000bd68a9640cffdfbd9a07503c9112d32bee
LEAN_SPEC_COMMIT ?= 0f5b8e58e58c0e155ae8b95eabbbde0b9ad8840a
# Docker image name. Used for both release (with publish) and local builds.
DOCKER_REPO ?= sifrai/lean
# Image tag.
Expand Down Expand Up @@ -56,15 +56,6 @@ generate-test-vectors:
git remote add origin https://github.com/leanEthereum/leanSpec.git && \
git fetch --depth 1 origin $(LEAN_SPEC_COMMIT) && \
git switch --detach FETCH_HEAD
# Pre-download prod keys. The pinned leanSpec commit predates leanSpec PR #745,
# whose `download_keys` reads the still-open release URL. Remove once the pin
# moves past PR #745.
cd spec && \
KEYS_URL=$$(uv run python -c "from consensus_testing.keys import KEY_DOWNLOAD_URLS; print(KEY_DOWNLOAD_URLS['prod'])") && \
KEYS_DIR=packages/testing/src/consensus_testing/test_keys && \
mkdir -p $$KEYS_DIR && \
curl -sSL "$$KEYS_URL" -o /tmp/prod_scheme.tar.gz && \
tar -xzf /tmp/prod_scheme.tar.gz -C $$KEYS_DIR
cd spec && uv run fill --clean --fork=Lstar --scheme prod || echo "run failed"
@for d in ./spec/fixtures/consensus/*/; do \
f=$$(basename $$d); \
Expand Down
15 changes: 10 additions & 5 deletions lean_client/fork_choice/tests/fork_choice_test_vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ impl Into<State> for TestAnchorState {
let mut validators = Validators::default();
for test_validator in &self.validators.data {
let attestation_pubkey: PublicKey = test_validator
.attestation_pubkey
.attestation_public_key
.parse()
.expect("Failed to parse validator attestation_pubkey");
let proposal_pubkey: PublicKey = test_validator
.proposal_pubkey
.proposal_public_key
.as_deref()
.map(|s| {
s.parse()
Expand Down Expand Up @@ -183,10 +183,10 @@ struct TestDataWrapper<T> {
struct TestValidator {
#[allow(dead_code)]
#[serde(alias = "pubkey")]
attestation_pubkey: String,
attestation_public_key: String,
#[allow(dead_code)]
#[serde(default)]
proposal_pubkey: Option<String>,
proposal_public_key: Option<String>,
#[allow(dead_code)]
#[serde(default)]
index: u64,
Expand Down Expand Up @@ -443,7 +443,7 @@ fn verify_checks(
Ok(())
}

#[test_resources("test_vectors/fork_choice/*/fc/*/*.json")]
#[test_resources("test_vectors/fork_choice/*/fork_choice/*/*.json")]
fn forkchoice(spec_file: &str) {
let spec_path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("..")
Expand Down Expand Up @@ -472,6 +472,7 @@ fn forkchoice(spec_file: &str) {
let mut store = get_forkchoice_store(anchor_state, anchor_block, config, false, 1);
let mut cache = BlockCache::new();
let mut block_labels: HashMap<String, H256> = HashMap::new();
block_labels.insert("genesis".to_string(), store.head);

for (step_idx, step) in case.steps.into_iter().enumerate() {
match step {
Expand All @@ -480,6 +481,7 @@ fn forkchoice(spec_file: &str) {
checks,
block: test_block,
} => {
let block_root_label = test_block.block_root_label.clone();
let result = std::panic::catch_unwind(AssertUnwindSafe(|| {
let block: Block = test_block.into();
let signed_block = SignedBlock {
Expand Down Expand Up @@ -519,6 +521,9 @@ fn forkchoice(spec_file: &str) {
}

if valid && result.is_ok() {
if let Some(label) = block_root_label {
block_labels.insert(label, *result.as_ref().unwrap());
}
verify_checks(&store, &checks, &block_labels, step_idx).expect(&format!(
"Step: {step_idx}: Should be valid but checks failed"
));
Expand Down
2 changes: 1 addition & 1 deletion lean_client/http_api/src/test_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ fn hex_root(root: &ssz::H256) -> String {
fn build_signed_aggregated_attestation(
step: GossipAggregatedAttestationStep,
) -> Result<SignedAggregatedAttestation, String> {
let proof_hex = step.proof.proof_data.data.trim_start_matches("0x");
let proof_hex = step.proof.proof.data.trim_start_matches("0x");
let proof_bytes = hex::decode(proof_hex)
.map_err(|err| format!("invalid hex in aggregate proof_data: {err}"))?;
let proof_data = AggregatedSignature::new(&proof_bytes)
Expand Down
4 changes: 2 additions & 2 deletions lean_client/spec_test_fixtures/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ pub fn parse_root(hex_str: &str) -> H256 {
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TestAttestation {
pub validator_id: u64,
pub validator_index: u64,
pub data: TestAttestationData,
}

impl From<TestAttestation> for Attestation {
fn from(value: TestAttestation) -> Self {
Self {
validator_id: value.validator_id,
validator_id: value.validator_index,
data: value.data.into(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion lean_client/spec_test_fixtures/src/fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,5 @@ pub struct GossipAggregatedAttestationStep {
#[serde(rename_all = "camelCase")]
pub struct GossipProofJSON {
pub participants: TestAggregationBits,
pub proof_data: HexBytesJSON,
pub proof: HexBytesJSON,
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_status_disabled[fork_Lstar][fork_Lstar-api_endpoint]": {
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_status_disabled[fork_Lstar][fork_Lstar-api_endpoint_test]": {
"network": "Lstar",
"leanEnv": "prod",
"proofSetting": 0,
"endpoint": "/lean/v0/admin/aggregator",
"method": "GET",
"genesisParams": {
Expand All @@ -15,11 +16,12 @@
"is_aggregator": false
},
"_info": {
"hash": "0x3b98b021603b378eb62491911c54d587507891b267c9b824687041d0234e8a54",
"hash": "0x26ba6bceba166de59b0ac27306217f42a1de4f848c014f2e01445a59baf42b18",
"comment": "`leanSpec` generated test",
"testId": "tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_status_disabled[fork_Lstar]",
"description": "GET aggregator status on a node started with aggregator disabled.",
"fixtureFormat": "api_endpoint"
"description": "The aggregator-status endpoint reports the disabled role.\n\n Given\n -----\n - a node started with the aggregator role disabled.\n\n When\n ----\n - the aggregator-status endpoint is queried.\n\n Then\n ----\n - the response reports the aggregator as disabled.",
"fixtureFormat": "api_endpoint_test",
"keySetDigest": "0xc2b5fc4c1f1fbc181ddf07db3df985f79e1dcedcfb7df732ef20863d7cbcf491"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_status_enabled[fork_Lstar][fork_Lstar-api_endpoint]": {
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_status_enabled[fork_Lstar][fork_Lstar-api_endpoint_test]": {
"network": "Lstar",
"leanEnv": "prod",
"proofSetting": 0,
"endpoint": "/lean/v0/admin/aggregator",
"method": "GET",
"genesisParams": {
Expand All @@ -15,11 +16,12 @@
"is_aggregator": true
},
"_info": {
"hash": "0xa8fc1583df88a6f91d80ae8f49d79026d54a3770ebb864793fb4cf5a89215ffd",
"hash": "0x6ff2445b728cabec079a7064c2909f8ab9ef6455a8d06cc5ea63c95bac9108df",
"comment": "`leanSpec` generated test",
"testId": "tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_status_enabled[fork_Lstar]",
"description": "GET aggregator status on a node started with aggregator enabled.",
"fixtureFormat": "api_endpoint"
"description": "The aggregator-status endpoint reports the enabled role.\n\n Given\n -----\n - a node started with the aggregator role enabled.\n\n When\n ----\n - the aggregator-status endpoint is queried.\n\n Then\n ----\n - the response reports the aggregator as enabled.",
"fixtureFormat": "api_endpoint_test",
"keySetDigest": "0xc2b5fc4c1f1fbc181ddf07db3df985f79e1dcedcfb7df732ef20863d7cbcf491"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_activate[fork_Lstar][fork_Lstar-api_endpoint]": {
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_activate[fork_Lstar][fork_Lstar-api_endpoint_test]": {
"network": "Lstar",
"leanEnv": "prod",
"proofSetting": 0,
"endpoint": "/lean/v0/admin/aggregator",
"method": "POST",
"genesisParams": {
Expand All @@ -19,11 +20,12 @@
"previous": false
},
"_info": {
"hash": "0x72a90f46823f1ce8bf60364b7fa122c64e986e05b4b65203a37c3e8a63709e0a",
"hash": "0x2b25bf00c202e7c8faeda3980c5f77e542624f11b132133c4b398b98fea5e454",
"comment": "`leanSpec` generated test",
"testId": "tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_activate[fork_Lstar]",
"description": "POST enable=true flips the role from off to on.",
"fixtureFormat": "api_endpoint"
"description": "Posting enable turns the aggregator role on.\n\n Given\n -----\n - a node started with the aggregator role disabled.\n\n When\n ----\n - a request posts the role enabled.\n\n Then\n ----\n - the role flips from off to on.",
"fixtureFormat": "api_endpoint_test",
"keySetDigest": "0xc2b5fc4c1f1fbc181ddf07db3df985f79e1dcedcfb7df732ef20863d7cbcf491"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_deactivate[fork_Lstar][fork_Lstar-api_endpoint]": {
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_deactivate[fork_Lstar][fork_Lstar-api_endpoint_test]": {
"network": "Lstar",
"leanEnv": "prod",
"proofSetting": 0,
"endpoint": "/lean/v0/admin/aggregator",
"method": "POST",
"genesisParams": {
Expand All @@ -19,11 +20,12 @@
"previous": true
},
"_info": {
"hash": "0x7d85826b14c99758017b6bbd9065571b8ece7c93f10de4f8cf2b40c5a24be47f",
"hash": "0x2c0216e92809d15ca75ca67e4cfdf35de84c85a909a65febc53590ef5b41c072",
"comment": "`leanSpec` generated test",
"testId": "tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_deactivate[fork_Lstar]",
"description": "POST enable=false flips the role from on to off.",
"fixtureFormat": "api_endpoint"
"description": "Posting disable turns the aggregator role off.\n\n Given\n -----\n - a node started with the aggregator role enabled.\n\n When\n ----\n - a request posts the role disabled.\n\n Then\n ----\n - the role flips from on to off.",
"fixtureFormat": "api_endpoint_test",
"keySetDigest": "0xc2b5fc4c1f1fbc181ddf07db3df985f79e1dcedcfb7df732ef20863d7cbcf491"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_idempotent_disable[fork_Lstar][fork_Lstar-api_endpoint]": {
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_idempotent_disable[fork_Lstar][fork_Lstar-api_endpoint_test]": {
"network": "Lstar",
"leanEnv": "prod",
"proofSetting": 0,
"endpoint": "/lean/v0/admin/aggregator",
"method": "POST",
"genesisParams": {
Expand All @@ -19,11 +20,12 @@
"previous": false
},
"_info": {
"hash": "0xa362c80dd61cb27136726592f8640406b2b1ae788154fc67c8ccd14811b427af",
"hash": "0x3655d37a0465fe3ffb8becd9f131c05246fc72ee6ffbd14e1f08415419beb932",
"comment": "`leanSpec` generated test",
"testId": "tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_idempotent_disable[fork_Lstar]",
"description": "POST enable=false on an already-disabled node returns previous=false and is a no-op.",
"fixtureFormat": "api_endpoint"
"description": "Posting disable on an already-disabled node is a no-op.\n\n Given\n -----\n - a node started with the aggregator role disabled.\n\n When\n ----\n - a request posts the role disabled again.\n\n Then\n ----\n - the response reports the previous role as disabled.\n - the role stays off.",
"fixtureFormat": "api_endpoint_test",
"keySetDigest": "0xc2b5fc4c1f1fbc181ddf07db3df985f79e1dcedcfb7df732ef20863d7cbcf491"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_idempotent_enable[fork_Lstar][fork_Lstar-api_endpoint]": {
"tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_idempotent_enable[fork_Lstar][fork_Lstar-api_endpoint_test]": {
"network": "Lstar",
"leanEnv": "prod",
"proofSetting": 0,
"endpoint": "/lean/v0/admin/aggregator",
"method": "POST",
"genesisParams": {
Expand All @@ -19,11 +20,12 @@
"previous": true
},
"_info": {
"hash": "0xe7b6b4ab7035e2badbec1c6931bed854818d7d92c3b321eeab301f5b636254ab",
"hash": "0x1d015ed46f70d5379ecb19105a63b6368e4ebabff897bf3381a51afd0413c39a",
"comment": "`leanSpec` generated test",
"testId": "tests/consensus/lstar/api/test_api_endpoints.py::test_aggregator_toggle_idempotent_enable[fork_Lstar]",
"description": "POST enable=true on an already-enabled node returns previous=true and is a no-op.",
"fixtureFormat": "api_endpoint"
"description": "Posting enable on an already-enabled node is a no-op.\n\n Given\n -----\n - a node started with the aggregator role enabled.\n\n When\n ----\n - a request posts the role enabled again.\n\n Then\n ----\n - the response reports the previous role as enabled.\n - the role stays on.",
"fixtureFormat": "api_endpoint_test",
"keySetDigest": "0xc2b5fc4c1f1fbc181ddf07db3df985f79e1dcedcfb7df732ef20863d7cbcf491"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"tests/consensus/lstar/api/test_api_endpoints.py::test_finalized_state_4v[fork_Lstar][fork_Lstar-api_endpoint]": {
"tests/consensus/lstar/api/test_api_endpoints.py::test_finalized_state_4v[fork_Lstar][fork_Lstar-api_endpoint_test]": {
"network": "Lstar",
"leanEnv": "prod",
"proofSetting": 0,
"endpoint": "/lean/v0/states/finalized",
"method": "GET",
"genesisParams": {
Expand All @@ -13,11 +14,12 @@
"expectedContentType": "application/octet-stream",
"expectedBody": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dba9671bac9513c9482f1416a53aabd2c6ce90d5a5f865ce5a55c775325c91360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e4000000e4000000e5000000a5020000a5020000016c9dc94cb124fd7eac91680ca6f7c131d7b02f1629ca842b0e714d557da1276b2e5f3d110aab9d6eb8c10c7d1ba0f93cd849c82e4f0098552e05e766afeb0d021742f626de106215bd0c5a5d2516fc75dc3ffc121159b63b6664354dc4eb353631b54a5ad0cc7b140000000000000000adc304243eb9f60ad1016e6610f11420dba97e450171971dda35bf50d4f14117ad3b9f06083c9d05f73d5e12f9e9ce1e7aa65866e2508c4edcc47c50505281470653e6555fe9785380e97c427e99b677f949b125d17f2c58a45c1b5349f20c27db10ea78d2fceb37010000000000000044095a46c1dd521b2e37c626b3401045f2a41713b034d95e9888fb34a15c280a8045b7043b6cca1c3353a6089ae5aa027c548d4bd72b9b4bf39f805d637c855bb3266b373aa97e262cea76359b84e70805268b520cbe62284be2f81da2069b0c5298912169fa935f0200000000000000c6ce413056aff1787a8d01575b11781c08ab595fea7cb46372fd8376e054f829da06c251d8e13643e751d9737d52e4474fddab5cd763f750d84c1840a6e2fb16b9f5e13f372e1f4646588a0d0ab96e483b42161f47858d5acb6d3a6bdae7e65a672cd2233fe77c16030000000000000001",
"_info": {
"hash": "0x107db041baa4bf2cdd23d1fc571df5b1f0debc6a5abad75df141232a7d0fb7c1",
"hash": "0xb9f25cfd5ee2e76f9b917e3781e6632c55e629b89812660d2bd73ffc0e247de0",
"comment": "`leanSpec` generated test",
"testId": "tests/consensus/lstar/api/test_api_endpoints.py::test_finalized_state_4v[fork_Lstar]",
"description": "Full SSZ-encoded finalized state for a 4-validator genesis.",
"fixtureFormat": "api_endpoint"
"description": "The finalized-state endpoint returns the serialized state with four validators.\n\n Given\n -----\n - a node started from a 4-validator genesis.\n\n When\n ----\n - the finalized-state endpoint is queried.\n\n Then\n ----\n - the response is the full serialized finalized state.",
"fixtureFormat": "api_endpoint_test",
"keySetDigest": "0xc2b5fc4c1f1fbc181ddf07db3df985f79e1dcedcfb7df732ef20863d7cbcf491"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"tests/consensus/lstar/api/test_api_endpoints.py::test_fork_choice_4v[fork_Lstar][fork_Lstar-api_endpoint]": {
"tests/consensus/lstar/api/test_api_endpoints.py::test_fork_choice_4v[fork_Lstar][fork_Lstar-api_endpoint_test]": {
"network": "Lstar",
"leanEnv": "prod",
"proofSetting": 0,
"endpoint": "/lean/v0/fork_choice",
"method": "GET",
"genesisParams": {
Expand Down Expand Up @@ -34,11 +35,12 @@
"validator_count": 4
},
"_info": {
"hash": "0x6a60ed6bcf22ecb2f33b7f9d51b74a604ee4f66fdeace924d745a1db529d1d02",
"hash": "0xc240ad1c60861af12270b1c7974efa2854e5a6bf28b9f8b312763cad18ca0eda",
"comment": "`leanSpec` generated test",
"testId": "tests/consensus/lstar/api/test_api_endpoints.py::test_fork_choice_4v[fork_Lstar]",
"description": "Fork choice tree at genesis: single node, zero attestation weights.",
"fixtureFormat": "api_endpoint"
"description": "The fork-choice endpoint returns a single-node tree at genesis.\n\n Given\n -----\n - a node started from a 4-validator genesis.\n\n When\n ----\n - the fork-choice endpoint is queried.\n\n Then\n ----\n - the tree holds a single node.\n - the attestation weights are zero.",
"fixtureFormat": "api_endpoint_test",
"keySetDigest": "0xc2b5fc4c1f1fbc181ddf07db3df985f79e1dcedcfb7df732ef20863d7cbcf491"
}
}
}
Loading
Loading