-
Notifications
You must be signed in to change notification settings - Fork 97
Pharos Network Integration #628
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
dharjeezy
wants to merge
43
commits into
main
Choose a base branch
from
dami/pharos-network
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
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
61710ae
pharos verifier
dharjeezy 38fdd03
ismp pharos
dharjeezy 63b3f7c
update state proof verification for pharos staking contract
dharjeezy 883ae04
address more concerns
dharjeezy c62bbf1
get validator set from proof
dharjeezy 17b7d06
no need to proof the current epoch slot
dharjeezy d94a728
use a BTreeSet to store validators,
dharjeezy d81e9b4
prover implementation
dharjeezy 0751817
test for non epoch boundary consensus verification
dharjeezy fd7ced2
tesseract pharos
dharjeezy ff08841
pharos spv implementation
dharjeezy 5c648d5
use sp_io for hashing
dharjeezy 5eb6c40
non epoch boundary validator proof checks passes now
dharjeezy 73f7b45
tesseract integration test
dharjeezy 25dfb2d
Merge branch 'main' of github.com:polytope-labs/hyperbridge into dami…
dharjeezy 1052faf
integration test completed
dharjeezy 990b84f
skip pharos on lib
dharjeezy 80e4df3
trigger
dharjeezy b218d5f
address concerns,
dharjeezy 8fde1f6
dynamic BLS data slots
dharjeezy 75237e9
direct use of state root
dharjeezy 87c7f76
anyhow error variant
dharjeezy 5b50852
address error related concerns
dharjeezy ddcce64
fix wasm error
dharjeezy 535ec6e
switch to v2 staking contract, add support for non membership proofs
dharjeezy e2528df
merge main into dami/pharos-network
dharjeezy 371a98e
nits
dharjeezy c8a7852
get epoch length from the staking contract slot
dharjeezy c374d23
pharos evm client for state proof fetch
dharjeezy bbe6edc
address all findings
dharjeezy bf07643
account proof, CI test, deduplication
dharjeezy 0636c42
run ci on this branch
dharjeezy e8f3693
change workflow
dharjeezy 2ee6a58
some fixes to proof verification
Wizdave97 067319d
hack for rate limiting
dharjeezy c235554
some nits
Wizdave97 8758b2d
Merge branch 'dami/pharos-network' of github.com:polytope-labs/hyperb…
Wizdave97 83c3caf
always use key path to verify existence proofs
Wizdave97 cbbe522
some deduplication
Wizdave97 6e0668a
some fixes
seunlanlege 93e289e
fix hash_internal_node
seunlanlege 38ac08a
fix pharos tests
seunlanlege b1cee85
pull_request_target
seunlanlege 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
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,34 @@ | ||
| [package] | ||
| name = "pharos-primitives" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
| description = "Primitive types for Pharos consensus verifier" | ||
| authors = ["Polytope Labs <hello@polytope.technology>"] | ||
| publish = false | ||
|
|
||
| [dependencies] | ||
| codec = { workspace = true, features = ["derive"] } | ||
| alloy-primitives = { workspace = true } | ||
| alloy-rlp = { workspace = true } | ||
| alloy-rlp-derive = { workspace = true } | ||
| sync-committee-primitives = { workspace = true, default-features = false } | ||
| primitive-types = { workspace = true, features = ["serde_no_std", "impl-codec"] } | ||
| hex-literal = { workspace = true } | ||
| serde = { workspace = true, optional = true, features = ["derive"] } | ||
| anyhow = { workspace = true, default-features = false } | ||
| geth-primitives = { workspace = true, default-features = false } | ||
| ismp = { workspace = true, default-features = false } | ||
|
|
||
| [features] | ||
| default = ["std"] | ||
| std = [ | ||
| "codec/std", | ||
| "alloy-primitives/std", | ||
| "alloy-rlp/std", | ||
| "sync-committee-primitives/std", | ||
| "primitive-types/std", | ||
| "anyhow/std", | ||
| "serde", | ||
| "geth-primitives/std", | ||
| "ismp/std", | ||
| ] |
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,109 @@ | ||
| // Copyright (C) Polytope Labs Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! Constants and configuration for Pharos consensus. | ||
|
|
||
| use alloy_primitives::Address; | ||
|
|
||
| /// Re-export BLS types from sync-committee-primitives | ||
| pub use sync_committee_primitives::constants::{ | ||
| BlsPublicKey, BlsSignature, BLS_PUBLIC_KEY_BYTES_LEN, BLS_SIGNATURE_BYTES_LEN, | ||
| }; | ||
|
|
||
| /// The staking contract address where validator set is stored. | ||
| /// Address: 0x4100000000000000000000000000000000000000 | ||
| pub const STAKING_CONTRACT_ADDRESS: Address = | ||
| Address::new([0x41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); | ||
|
|
||
| /// Consensus ID for Pharos network | ||
| pub const PHAROS_CONSENSUS_ID: [u8; 4] = *b"PHAR"; | ||
|
|
||
| /// Mainnet epoch length in seconds (4 hours) | ||
| pub const MAINNET_EPOCH_LENGTH_SECS: u64 = 4 * 60 * 60; // 14400 seconds | ||
|
|
||
| /// Testnet (Atlantic) epoch length in seconds (0.5 hours) | ||
| pub const TESTNET_EPOCH_LENGTH_SECS: u64 = 30 * 60; // 1800 seconds | ||
|
|
||
| /// Configuration trait for Pharos network parameters. | ||
| pub trait Config: Clone + Send + Sync { | ||
| /// The epoch length in seconds | ||
| const EPOCH_LENGTH_SECS: u64; | ||
|
|
||
| /// The epoch length in blocks (derived from epoch length and block time) | ||
| const EPOCH_LENGTH_BLOCKS: u64; | ||
|
|
||
| /// The chain ID for this network | ||
| const CHAIN_ID: u64; | ||
|
|
||
| /// Network identifier | ||
| const ID: [u8; 4]; | ||
|
|
||
| /// Calculate the epoch number for a given block number | ||
| fn compute_epoch(block_number: u64) -> u64 { | ||
| block_number / Self::EPOCH_LENGTH_BLOCKS | ||
| } | ||
|
|
||
| /// Check if a block is an epoch boundary block (last block of an epoch). | ||
| /// | ||
| /// The epoch boundary is defined as the last block of an epoch, i.e., | ||
| /// `(block_number + 1) % epoch_length == 0`. | ||
| /// | ||
| /// At epoch boundaries, the validator set for the next epoch is finalized | ||
| fn is_epoch_boundary(block_number: u64) -> bool { | ||
| (block_number + 1) % Self::EPOCH_LENGTH_BLOCKS == 0 | ||
| } | ||
|
|
||
| /// Get the first block number of the next epoch | ||
| fn next_epoch_start(current_block: u64) -> u64 { | ||
| let current_epoch = Self::compute_epoch(current_block); | ||
| (current_epoch + 1) * Self::EPOCH_LENGTH_BLOCKS | ||
| } | ||
| } | ||
|
|
||
| /// Pharos Mainnet configuration | ||
| #[derive(Clone, Default, Debug)] | ||
| pub struct Mainnet; | ||
|
|
||
| impl Config for Mainnet { | ||
| /// 4 hours epoch length | ||
| const EPOCH_LENGTH_SECS: u64 = MAINNET_EPOCH_LENGTH_SECS; | ||
|
|
||
| /// With ~1 second finality (sub-second), assuming 1 block per second | ||
| /// 4 hours = 14400 blocks | ||
| const EPOCH_LENGTH_BLOCKS: u64 = 14400; | ||
|
|
||
| /// Mainnet chain ID - TBD | ||
| /// Placeholder based on testnet pattern | ||
| const CHAIN_ID: u64 = 688600; | ||
|
|
||
| const ID: [u8; 4] = PHAROS_CONSENSUS_ID; | ||
| } | ||
|
|
||
| /// Pharos Testnet configuration | ||
| #[derive(Clone, Default, Debug)] | ||
| pub struct Testnet; | ||
|
|
||
| impl Config for Testnet { | ||
| /// 0.5 hours epoch length | ||
| const EPOCH_LENGTH_SECS: u64 = TESTNET_EPOCH_LENGTH_SECS; | ||
|
|
||
| /// With ~1 second finality, 0.5 hours = 1800 blocks | ||
| const EPOCH_LENGTH_BLOCKS: u64 = 1800; | ||
|
|
||
| /// Pharos Testnet chain ID | ||
| const CHAIN_ID: u64 = 688689; | ||
|
|
||
| const ID: [u8; 4] = PHAROS_CONSENSUS_ID; | ||
| } | ||
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,23 @@ | ||
| // Copyright (C) Polytope Labs Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| #![cfg_attr(not(feature = "std"), no_std)] | ||
|
|
||
| extern crate alloc; | ||
|
|
||
| pub mod constants; | ||
| pub mod types; | ||
|
|
||
| pub use constants::*; | ||
| pub use types::*; |
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.
Uh oh!
There was an error while loading. Please reload this page.