From cd3ca85821672d75125269b38fc6684ee305f763 Mon Sep 17 00:00:00 2001 From: Naohiro Yoshida Date: Wed, 27 Nov 2024 17:53:10 +0900 Subject: [PATCH 1/9] reuse rlp to make hash Signed-off-by: Naohiro Yoshida --- light-client/src/client.rs | 2 +- light-client/src/header/eth_header.rs | 67 +-------------------------- 2 files changed, 2 insertions(+), 67 deletions(-) diff --git a/light-client/src/client.rs b/light-client/src/client.rs index 60e9f68..5ebe356 100644 --- a/light-client/src/client.rs +++ b/light-client/src/client.rs @@ -606,7 +606,7 @@ mod test { fn test_error_create_client() { let client_state = hex!("0a272f6962632e6c69676874636c69656e74732e7061726c69612e76312e436c69656e745374617465124d08381214151f3951fa218cac426edfe078fa9e5c6dcea5001a2000000000000000000000000000000000000000000000000000000000000000002205109b9ea90f2a040880a305320410c0843d").to_vec(); let consensus_state = hex!("0a2a2f6962632e6c69676874636c69656e74732e7061726c69612e76312e436f6e73656e7375735374617465126c0a2056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b42110de82d5a8061a209c59cf0b5717cb6e2bd8620b7f3481605c8abcd45636bdf45c86db06338f0c5e22207a1dede35f5c835fecdc768324928cd0d9d9161e8529e1ba1e60451f3a9d088a").to_vec(); - let client = ParliaLightClient::default(); + let client = ParliaLightClient; let mock_consensus_state = BTreeMap::new(); let ctx = MockClientReader { client_state: None, diff --git a/light-client/src/header/eth_header.rs b/light-client/src/header/eth_header.rs index 0355878..0cde856 100644 --- a/light-client/src/header/eth_header.rs +++ b/light-client/src/header/eth_header.rs @@ -415,72 +415,7 @@ impl TryFrom for ETHHeader { return Err(Error::UnexpectedNonce(number)); } - // create block hash - let mut stream = RlpStream::new(); - stream.begin_unbounded_list(); - stream.append(&parent_hash); - stream.append(&uncle_hash); - stream.append(&coinbase); - stream.append(&root.to_vec()); - stream.append(&tx_hash); - stream.append(&receipt_hash); - stream.append(&bloom); - stream.append(&difficulty); - stream.append(&number); - stream.append(&gas_limit); - stream.append(&gas_used); - stream.append(×tamp); - stream.append(&extra_data); - stream.append(&mix_digest); - stream.append(&nonce); - - if base_fee_per_gas.is_some() - || withdrawals_hash.is_some() - || blob_gas_used.is_some() - || excess_blob_gas.is_some() - || parent_beacon_root.is_some() - { - if let Some(v) = base_fee_per_gas { - stream.append(&v); - } else { - stream.append_empty_data(); - } - } - if withdrawals_hash.is_some() - || blob_gas_used.is_some() - || excess_blob_gas.is_some() - || parent_beacon_root.is_some() - { - if let Some(v) = &withdrawals_hash { - stream.append(v); - } else { - stream.append_empty_data(); - } - } - if blob_gas_used.is_some() || excess_blob_gas.is_some() || parent_beacon_root.is_some() { - if let Some(v) = blob_gas_used { - stream.append(&v); - } else { - stream.append_empty_data(); - } - } - if excess_blob_gas.is_some() || parent_beacon_root.is_some() { - if let Some(v) = excess_blob_gas { - stream.append(&v); - } else { - stream.append_empty_data(); - } - } - if parent_beacon_root.is_some() { - if let Some(v) = &parent_beacon_root { - stream.append(v); - } else { - stream.append_empty_data(); - } - } - stream.finalize_unbounded_list(); - let buffer_vec: Vec = stream.out().to_vec(); - let hash: Hash = keccak_256(&buffer_vec); + let hash: Hash = keccak_256(value.header.as_slice()); let epoch = if number % BLOCKS_PER_EPOCH == 0 { let (validators, turn_length) = get_validator_bytes_and_turn_length(&extra_data)?; From a535ba8ad4dc1be47218c84f2dfe49076f833806 Mon Sep 17 00:00:00 2001 From: Naohiro Yoshida Date: Mon, 2 Dec 2024 08:29:59 +0900 Subject: [PATCH 2/9] calc seal hash with requests_hash Signed-off-by: Naohiro Yoshida --- light-client/src/header/eth_header.rs | 8 ++++++++ light-client/src/header/vote_attestation.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/light-client/src/header/eth_header.rs b/light-client/src/header/eth_header.rs index 0cde856..ba3d7e1 100644 --- a/light-client/src/header/eth_header.rs +++ b/light-client/src/header/eth_header.rs @@ -58,6 +58,7 @@ pub struct ETHHeader { pub blob_gas_used: Option, pub excess_blob_gas: Option, pub parent_beacon_root: Option>, + pub requests_hash: Option>, // calculated by RawETHHeader pub hash: Hash, @@ -133,6 +134,11 @@ impl ETHHeader { stream.append_empty_data(); } stream.append(parent_beacon_root); + + // https://github.com/bnb-chain/bsc/blob/e2f2111a85fecabb4782099338aca21bf58bde09/core/types/block.go#L776 + if let Some(value) = &self.requests_hash { + stream.append(value); + } } } stream.finalize_unbounded_list(); @@ -378,6 +384,7 @@ impl TryFrom for ETHHeader { let blob_gas_used: Option = rlp.try_next_as_val().map(Some).unwrap_or(None); let excess_blob_gas: Option = rlp.try_next_as_val().map(Some).unwrap_or(None); let parent_beacon_root: Option> = rlp.try_next_as_val().map(Some).unwrap_or(None); + let requests_hash: Option> = rlp.try_next_as_val().map(Some).unwrap_or(None); // Check that the extra-data contains the vanity, validators and signature let extra_size = extra_data.len(); @@ -445,6 +452,7 @@ impl TryFrom for ETHHeader { withdrawals_hash, blob_gas_used, parent_beacon_root, + requests_hash, hash, epoch, }) diff --git a/light-client/src/header/vote_attestation.rs b/light-client/src/header/vote_attestation.rs index fb05570..e6aa6fc 100644 --- a/light-client/src/header/vote_attestation.rs +++ b/light-client/src/header/vote_attestation.rs @@ -242,6 +242,7 @@ mod test { blob_gas_used: None, excess_blob_gas: None, parent_beacon_root: None, + requests_hash: None, hash: [0u8; 32], epoch: None, }; From e1a5feb4ee8d3feeaf992ad74621be06b8593c31 Mon Sep 17 00:00:00 2001 From: Naohiro Yoshida Date: Tue, 21 Jan 2025 16:28:37 +0900 Subject: [PATCH 3/9] add test Signed-off-by: Naohiro Yoshida --- light-client/src/header/eth_header.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/light-client/src/header/eth_header.rs b/light-client/src/header/eth_header.rs index ba3d7e1..0e1eaa7 100644 --- a/light-client/src/header/eth_header.rs +++ b/light-client/src/header/eth_header.rs @@ -470,9 +470,12 @@ pub(crate) mod test { use rlp::RlpStream; use rstest::*; - use crate::fixture::{localnet, Network}; + use crate::fixture::localnet::Localnet; + use crate::fixture::{decode_header, localnet, Network}; use crate::header::epoch::Epoch; + use crate::misc::ChainId; use alloc::boxed::Box; + use hex_literal::hex; use parlia_ibc_proto::ibc::lightclients::parlia::v1::EthHeader as RawETHHeader; fn to_raw(header: ÐHeader) -> RawETHHeader { @@ -814,4 +817,19 @@ pub(crate) mod test { err => unreachable!("{:?}", err), } } + #[test] + fn test_success_bep466_header() { + let header = hex!("f90370a04a99d244666a287d9aaa1a81aa5bba573f156865369023eaa53a4ba8bb303ad1a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794e04db2de85453e0936b441c339a26d10cfa71b50a0d0a25a7c6b93d5d2e8f7e2075d2886fa62840f31c127b880b7cd503e2d364163a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000282071b8402625a008084678f4827b90111d883010503846765746888676f312e32332e35856c696e75780000002f5b9772f8ae0fb860959e5c417ecd8a5e5ddabd85485cf2cc4433f26beea076d77bbc6f461e4129881b8772bdae5fdd6ca927b571662ac5750d4abeca4f44a4406ab3254e0d98e6ee92b5b6396122853b45db2d18d24fb79e8397e253ca10a2a03b3b18e5961173b5f848820719a0e5ef3de482ecc3de5aea0efb17457d7edc5b1a39fc97c29cc5780b4665c9ca2082071aa04a99d244666a287d9aaa1a81aa5bba573f156865369023eaa53a4ba8bb303ad180aba9a203cbc9ac6e2eabbc44b15f7c526ec5f9d570a0addc005d5958d8415f760794e65762057ff9956dce68034d30cca6d9cc2ac3eb35f699d47c74931c470a01a0000000000000000000000000000000000000000000000000000000000000000088000000000000000080a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b4218080a00000000000000000000000000000000000000000000000000000000000000000a0e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855").to_vec(); + let header = decode_header(header); + let chain_id = localnet().network(); + + let prev_epoch = hex!("f90484a0cdbf04705a1f6ed4989217c1e89f4c0ab22b3122df2f48c09e2fef3d0aa4b5b4a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794b2e42bc54d19116d2348ac83461e2e0915d508ada08b3fad7b45691957d1bf905d2601a14e12d48d1da89205d22b4eb582af803e3da0629579638c8423e2836b6ad04eed7a7dcda123a3f4b6d2ab488121fac9df6c10a03cd1ebc99cd975182c58de47be968c97658cff4c465e20654185f408a851403cb9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028207088402625a008229a884678f47eeb90223d883010503846765746888676f312e32332e35856c696e75780000002f5b9772048fdaaa7e6631e438625ca25c857a3727ea28e565b5ad484c80ff8ed9a2aff68923f36e8975c377abd0c62a8a66ac0d2519b3eb4c14951312006c9e8b3829dc68cab6bcf0a7876ea32e7a748c697d01345145485561305b24958ec28bac0db09ee3e6cfc1769fd72b493a6c44118598abb600bec65e66aafd23acd46e0d1e0bda9d8101dbbdbf369fd9a13701eafb76870cb220843b8c6476824bfa15ad21d1bf47e3df7d8d99b105a24ebca95a84b035e6af22880b9eaf1d6a4a233920a57ecf09f8a6b89d7f5ca3cfe6484fe04db2de85453e0936b441c339a26d10cfa71b50b611e87c256a23edc8b7e55558abe1a7ff94262bacb53d600e657270ee6af9172c5a31c24498a162147dd7e1bfdcef9107f8ae0fb860a70e55ed7260c28c69880ca12370872c2059f0540ca88c1cb7a6ba772ed6e7f62a5e11c31e117ea483a4c6b46cf213681092f5273512ad15e030f52c3485838801a5ae99ece187028adbf6f543b34bd4a48199dc9b58ea47b16d06049a370a65f848820706a0ab18ec6cce429c9918cb4f354ffda5c0119871589de4829c9871ee7eddbce0ed820707a0cdbf04705a1f6ed4989217c1e89f4c0ab22b3122df2f48c09e2fef3d0aa4b5b48099019414f8ca7f80176785458468355225878402b80bbe64de4de083cbd909163b1c8dd0564e07516e6bbd0ec64381847f8f3d94d75992fd04243b538ba9348d01a0000000000000000000000000000000000000000000000000000000000000000088000000000000000080a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b4218080a00000000000000000000000000000000000000000000000000000000000000000a0e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855").to_vec(); + let prev_epoch = decode_header(prev_epoch); + + header + .verify_seal(&prev_epoch.epoch.unwrap(), &chain_id) + .unwrap(); + assert!(&header.requests_hash.is_some()); + assert_eq!(32, header.requests_hash.unwrap().len()); + } } From 37f4bd94f1685b28cb587e64c4cee2e9fde0568c Mon Sep 17 00:00:00 2001 From: Naohiro Yoshida Date: Tue, 28 Jan 2025 18:59:27 +0900 Subject: [PATCH 4/9] check pascal timestamp Signed-off-by: Naohiro Yoshida --- .github/workflows/ci.yaml | 7 ++++++ light-client/build.rs | 7 ++++-- light-client/src/errors.rs | 4 +++ light-client/src/header/eth_header.rs | 36 ++++++++++++++++++++++++--- light-client/src/header/hardfork.rs | 5 ++-- 5 files changed, 52 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 45d0b19..1bcd007 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,3 +49,10 @@ jobs: env: MINIMUM_TIMESTAMP_SUPPORTED: 1731495592 MINIMUM_HEIGHT_SUPPORTED: 100 + - uses: actions-rs/cargo@v1 + name: unit-test-dev-test-pascal + with: + command: test + args: --release --features=dev --manifest-path light-client/Cargo.toml --lib test::dev_test_pascal + env: + PASCAL_TIMESTAMP: 1 \ No newline at end of file diff --git a/light-client/build.rs b/light-client/build.rs index f326f41..212916c 100644 --- a/light-client/build.rs +++ b/light-client/build.rs @@ -20,11 +20,14 @@ fn main() { std::env::var("MINIMUM_TIMESTAMP_SUPPORTED").unwrap_or_else(|_| "0".to_string()); let minimum_height_supported = std::env::var("MINIMUM_HEIGHT_SUPPORTED").unwrap_or_else(|_| "0".to_string()); + let pascal_timestamp = + std::env::var("PASCAL_TIMESTAMP").unwrap_or_else(|_| "0".to_string()); writeln!( file, - "pub const MINIMUM_TIMESTAMP_SUPPORTED: u64 = {};\npub const MINIMUM_HEIGHT_SUPPORTED: u64 = {};", + "pub const MINIMUM_TIMESTAMP_SUPPORTED: u64 = {};\npub const MINIMUM_HEIGHT_SUPPORTED: u64 = {};\npub const PASCAL_TIMESTAMP: u64 = {};", minimum_time_stamp_supported, - minimum_height_supported + minimum_height_supported, + pascal_timestamp ) .unwrap(); } diff --git a/light-client/src/errors.rs b/light-client/src/errors.rs index fc843c2..1d49691 100644 --- a/light-client/src/errors.rs +++ b/light-client/src/errors.rs @@ -98,6 +98,7 @@ pub enum Error { UnexpectedUntrustedValidatorsHashInEpoch(Height, Height, Hash, Hash), UnexpectedCurrentValidatorsHashInEpoch(Height, Height, Hash, Hash), UnexpectedUntrustedValidators(BlockNumber, BlockNumber), + MissingRequestsHash(BlockNumber), // Vote attestation UnexpectedTooManyHeadersToFinalize(BlockNumber, usize), @@ -384,6 +385,9 @@ impl core::fmt::Display for Error { Error::UnexpectedRevisionHeight(e1) => { write!(f, "UnexpectedRevisionHeight : {}", e1) } + Error::MissingRequestsHash(e1) => { + write!(f, "MissingRequestsHash : {}", e1) + } } } } diff --git a/light-client/src/header/eth_header.rs b/light-client/src/header/eth_header.rs index 0e1eaa7..6040ad8 100644 --- a/light-client/src/header/eth_header.rs +++ b/light-client/src/header/eth_header.rs @@ -11,7 +11,7 @@ use parlia_ibc_proto::ibc::lightclients::parlia::v1::EthHeader as RawETHHeader; use crate::errors::Error; use crate::header::epoch::Epoch; - +use crate::header::hardfork::PASCAL_TIMESTAMP; use crate::header::vote_attestation::VoteAttestation; use crate::misc::{Address, BlockNumber, ChainId, Hash, RlpIterator, Validators}; @@ -431,6 +431,10 @@ impl TryFrom for ETHHeader { None }; + if PASCAL_TIMESTAMP > 0 && timestamp >= PASCAL_TIMESTAMP && requests_hash.is_none() { + return Err(Error::MissingRequestsHash(number)); + } + Ok(Self { parent_hash, uncle_hash, @@ -470,10 +474,9 @@ pub(crate) mod test { use rlp::RlpStream; use rstest::*; - use crate::fixture::localnet::Localnet; use crate::fixture::{decode_header, localnet, Network}; use crate::header::epoch::Epoch; - use crate::misc::ChainId; + use alloc::boxed::Box; use hex_literal::hex; use parlia_ibc_proto::ibc::lightclients::parlia::v1::EthHeader as RawETHHeader; @@ -832,4 +835,31 @@ pub(crate) mod test { assert!(&header.requests_hash.is_some()); assert_eq!(32, header.requests_hash.unwrap().len()); } + + #[cfg(feature = "dev")] + mod dev_test_pascal { + use crate::errors::Error; + use crate::fixture::{decode_header, localnet}; + use crate::header::eth_header::ETHHeader; + use hex_literal::hex; + use parlia_ibc_proto::ibc::lightclients::parlia::v1::EthHeader; + + #[test] + fn test_error_missing_request_hash() { + // number = 401 + let raw_header = localnet().epoch_header_plus_1_rlp(); + let raw_header = EthHeader { header: raw_header }; + let result = ETHHeader::try_from(raw_header).unwrap_err(); + match result { + Error::MissingRequestsHash(_) => {} + _ => unreachable!(), + } + } + + #[test] + fn test_success_after_bep466() { + let header = hex!("f90370a04a99d244666a287d9aaa1a81aa5bba573f156865369023eaa53a4ba8bb303ad1a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794e04db2de85453e0936b441c339a26d10cfa71b50a0d0a25a7c6b93d5d2e8f7e2075d2886fa62840f31c127b880b7cd503e2d364163a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000282071b8402625a008084678f4827b90111d883010503846765746888676f312e32332e35856c696e75780000002f5b9772f8ae0fb860959e5c417ecd8a5e5ddabd85485cf2cc4433f26beea076d77bbc6f461e4129881b8772bdae5fdd6ca927b571662ac5750d4abeca4f44a4406ab3254e0d98e6ee92b5b6396122853b45db2d18d24fb79e8397e253ca10a2a03b3b18e5961173b5f848820719a0e5ef3de482ecc3de5aea0efb17457d7edc5b1a39fc97c29cc5780b4665c9ca2082071aa04a99d244666a287d9aaa1a81aa5bba573f156865369023eaa53a4ba8bb303ad180aba9a203cbc9ac6e2eabbc44b15f7c526ec5f9d570a0addc005d5958d8415f760794e65762057ff9956dce68034d30cca6d9cc2ac3eb35f699d47c74931c470a01a0000000000000000000000000000000000000000000000000000000000000000088000000000000000080a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b4218080a00000000000000000000000000000000000000000000000000000000000000000a0e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855").to_vec(); + decode_header(header); + } + } } diff --git a/light-client/src/header/hardfork.rs b/light-client/src/header/hardfork.rs index 2b2db29..15b40ff 100644 --- a/light-client/src/header/hardfork.rs +++ b/light-client/src/header/hardfork.rs @@ -1,2 +1,3 @@ -pub const MINIMUM_TIMESTAMP_SUPPORTED: u64 = 0; -pub const MINIMUM_HEIGHT_SUPPORTED: u64 = 0; +pub const MINIMUM_TIMESTAMP_SUPPORTED: u64 = 1731495592; +pub const MINIMUM_HEIGHT_SUPPORTED: u64 = 100; +pub const PASCAL_TIMESTAMP: u64 = 1; From fc45dd9039c9403d5c658ce709b73d199ca99914 Mon Sep 17 00:00:00 2001 From: Naohiro Yoshida Date: Tue, 28 Jan 2025 19:46:17 +0900 Subject: [PATCH 5/9] fix clippy Signed-off-by: Naohiro Yoshida --- light-client/src/header/eth_header.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/light-client/src/header/eth_header.rs b/light-client/src/header/eth_header.rs index 6040ad8..921f43f 100644 --- a/light-client/src/header/eth_header.rs +++ b/light-client/src/header/eth_header.rs @@ -431,6 +431,7 @@ impl TryFrom for ETHHeader { None }; + #[allow(clippy::absurd_extreme_comparisons)] if PASCAL_TIMESTAMP > 0 && timestamp >= PASCAL_TIMESTAMP && requests_hash.is_none() { return Err(Error::MissingRequestsHash(number)); } From 8ed26c7366f26e882ebf02cc4353fe53b20f73e6 Mon Sep 17 00:00:00 2001 From: Naohiro Yoshida Date: Tue, 28 Jan 2025 20:32:00 +0900 Subject: [PATCH 6/9] split namespace Signed-off-by: Naohiro Yoshida --- .github/workflows/ci.yaml | 4 ++-- light-client/src/client.rs | 2 +- light-client/src/client_state.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1bcd007..3505b52 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,10 +42,10 @@ jobs: command: test args: --release --features=std --manifest-path light-client/Cargo.toml - uses: actions-rs/cargo@v1 - name: unit-test-dev-test + name: unit-test-dev-test-min with: command: test - args: --release --features=dev --manifest-path light-client/Cargo.toml --lib test::dev_test + args: --release --features=dev --manifest-path light-client/Cargo.toml --lib test::dev_test_min env: MINIMUM_TIMESTAMP_SUPPORTED: 1731495592 MINIMUM_HEIGHT_SUPPORTED: 100 diff --git a/light-client/src/client.rs b/light-client/src/client.rs index 5ebe356..515af09 100644 --- a/light-client/src/client.rs +++ b/light-client/src/client.rs @@ -1156,7 +1156,7 @@ mod test { } #[cfg(feature = "dev")] - mod dev_test { + mod dev_test_min { use crate::client::test::MockClientReader; use crate::client::ParliaLightClient; use crate::client_state::ClientState; diff --git a/light-client/src/client_state.rs b/light-client/src/client_state.rs index 60fe11f..ac1ba33 100644 --- a/light-client/src/client_state.rs +++ b/light-client/src/client_state.rs @@ -706,7 +706,7 @@ mod test { } } #[cfg(feature = "dev")] - mod dev_test { + mod dev_test_min { use crate::client_state::ClientState; use crate::consensus_state::ConsensusState; use crate::errors::Error; From 83efdf15a31ad033e839348ce19095fc6fd6a0df Mon Sep 17 00:00:00 2001 From: Naohiro Yoshida Date: Tue, 28 Jan 2025 20:43:08 +0900 Subject: [PATCH 7/9] tweak Signed-off-by: Naohiro Yoshida --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3505b52..6281bc9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -55,4 +55,6 @@ jobs: command: test args: --release --features=dev --manifest-path light-client/Cargo.toml --lib test::dev_test_pascal env: + MINIMUM_TIMESTAMP_SUPPORTED: 1 + MINIMUM_HEIGHT_SUPPORTED: 1 PASCAL_TIMESTAMP: 1 \ No newline at end of file From 53e24ebd1ac459f19b127ad8822f07f6975d3cae Mon Sep 17 00:00:00 2001 From: Naohiro Yoshida Date: Fri, 31 Jan 2025 14:00:52 +0900 Subject: [PATCH 8/9] reset as default Signed-off-by: Naohiro Yoshida --- light-client/src/header/hardfork.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/light-client/src/header/hardfork.rs b/light-client/src/header/hardfork.rs index 15b40ff..bae22b9 100644 --- a/light-client/src/header/hardfork.rs +++ b/light-client/src/header/hardfork.rs @@ -1,3 +1,3 @@ -pub const MINIMUM_TIMESTAMP_SUPPORTED: u64 = 1731495592; -pub const MINIMUM_HEIGHT_SUPPORTED: u64 = 100; -pub const PASCAL_TIMESTAMP: u64 = 1; +pub const MINIMUM_TIMESTAMP_SUPPORTED: u64 = 0; +pub const MINIMUM_HEIGHT_SUPPORTED: u64 = 0; +pub const PASCAL_TIMESTAMP: u64 = 0; From e0cc787a33a223b10ae1f0201a86cbc1621a299c Mon Sep 17 00:00:00 2001 From: Naohiro Yoshida Date: Fri, 31 Jan 2025 14:09:33 +0900 Subject: [PATCH 9/9] add the build parameter description to readme Signed-off-by: Naohiro Yoshida --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bee54f7..c2537dc 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,14 @@ This is available in dev feature only. ```sh BSC_BLOCKS_PER_EPOCH=20 cargo build --features=dev -``` \ No newline at end of file +``` + +### Build Parameters + +Parameters can be specified to check for acceptable headers at build time. + +| Name | Description | +| --- |-------------------------------------------------------------------------------------------------------------------------------------------------| +| `MINIMUM_TIMESTAMP_SUPPORTED` | Timestamp of the lowest header this light client will accept | +| `MINIMUM_HEIGHT_SUPPORTED` | Height of the lowest header this light client will accept | +| `PASCAL_TIMESTAMP` | Timestamp of the first Pascal Hardfork header, used to check the header structure after Pascal Hardfork; if 0 is specified, no check is made. | \ No newline at end of file