Skip to content

Commit

Permalink
feat: custom call (#43)
Browse files Browse the repository at this point in the history
* feat: call contract by service

* chore: refactor code

* chore: add test

* fix: fix verify batch

* fix: fix clippy

* chore: add GEN_PROOF env

* chore: add proof file

* chore: change name

* fix: fix verify
  • Loading branch information
BC-A authored Sep 27, 2024
1 parent 80b9154 commit 00e4e61
Show file tree
Hide file tree
Showing 14 changed files with 1,159 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ uuid = { version = "1.2", features = ["v4", "fast-rng", "macro-diagnostics"] }

# eth
alloy-chains = { version = "0.1" }
reqwest = "0.12.5"
reqwest = { version = "0.12.5", features = ["json", "blocking"] }

[dev-dependencies]
pretty_assertions = "1.4.0"
Expand Down
5 changes: 2 additions & 3 deletions configs/custom_node_config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[tx_filter_config]
bridge_contract_address = "0x2222222222"
bridge_asset_selector = "0x2222222222"

bridge_contract_address = "0x17435ccE3d1B4fA2e5f8A08eD921D57C6762A180"
bridge_asset_selector = "0xcd586579"
22 changes: 22 additions & 0 deletions proof/proof.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"pi_a": {
"x": "17417480591305158925649477501478755112960263076414890363431950352106756703156",
"y": "3861645839258872471588434820677153286443622533258823533716073415753807193362"
},
"pi_b": {
"x": [
"1888192340250615284162548953478000113552765573288627153885483983991945077778",
"12839537089607918006526648939966606447200305496614910310480973165133791671186"
],
"y": [
"9356128563962693123369145196078200120594297064426889980828801354429599038284",
"8356895530159769835834895094470393417156532106130004017665561138310422920909"
]
},
"pi_c": {
"x": "4689980742433253475969746726233113733646868104702109866973549391946972020034",
"y": "7120799072200037615976388306327185991018815509189704120496254138703976052472"
},
"protocol": "groth16",
"curve": "BN128"
}
3 changes: 3 additions & 0 deletions proof/public_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"14190879858911742134402832400201910146341202868841835779272582838585145689449"
]
2 changes: 1 addition & 1 deletion scripts/launch-pos-eigen-zeth-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ZETH_LOG_FILE="${PROJECT_PATH}/tmp/zeth.log"
BEACON_LOG_FILE="${PROJECT_PATH}/tmp/beacon.log"
VALIDATOR_LOG_FILE="${PROJECT_PATH}/tmp/validator.log"

DEFAULT_SETTLEMENT="ethereum" # default settlement layer
DEFAULT_SETTLEMENT="custom" # default settlement layer
DEFAULT_SETTLEMENT_CONFIG_FILE="${PROJECT_PATH}/configs/settlement.toml"
DEFAULT_CUSTOM_NODE_CONFIG_FILE="${PROJECT_PATH}/configs/custom_node_config.toml"
DEFAULT_DATABASE_CONFIG_FILE="${PROJECT_PATH}/configs/database.toml"
Expand Down
9 changes: 9 additions & 0 deletions src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::custom_reth;
use crate::custom_reth::TxFilterConfig;
use crate::db::lfs;
use crate::operator::Operator;
use crate::settlement::custom::CustomSettlementConfig;
use crate::settlement::ethereum::EthereumSettlementConfig;
use crate::settlement::worker::WorkerConfig;
use crate::settlement::NetworkSpec;
Expand Down Expand Up @@ -141,6 +142,7 @@ impl fmt::Display for SettlementLayer {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
SettlementLayer::Ethereum => write!(f, "ethereum"),
SettlementLayer::Custom => write!(f, "custom"),
}
}
}
Expand All @@ -149,6 +151,7 @@ impl fmt::Display for SettlementLayer {
#[non_exhaustive]
pub enum SettlementLayer {
Ethereum,
Custom,
}

impl RunCmd {
Expand All @@ -174,6 +177,12 @@ impl RunCmd {
)?)
}
},
SettlementLayer::Custom => {
log::info!("Using Custom SettlementLayer");
NetworkSpec::Custom(CustomSettlementConfig {
service_url: GLOBAL_ENV.bridge_service_addr.clone(),
})
}
};

let tx_filter_config = match &self.custom_node_conf {
Expand Down
4 changes: 4 additions & 0 deletions src/config/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct GlobalEnv {
pub chain_id: u64,
pub program_name: String,
pub bridge_service_addr: String,
pub debug_proof: bool,
}

/// GLOBAL_ENV is a global variable that holds the environment variables,
Expand All @@ -28,4 +29,7 @@ pub static GLOBAL_ENV: Lazy<GlobalEnv> = Lazy::new(|| GlobalEnv {
.to_lowercase(),
bridge_service_addr: std::env::var("BRIDGE_SERVICE_ADDR")
.unwrap_or("http://localhost:8001".to_string()),
debug_proof: std::env::var("DEBUG_PROOF")
.unwrap_or_else(|_| String::from("FALSE"))
.eq_ignore_ascii_case("FALSE"),
});
1 change: 1 addition & 0 deletions src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub(crate) mod keys {
pub const KEY_LAST_PROVEN_BLOCK_NUMBER: &[u8] = b"LAST_PROVEN_BLOCK_NUMBER";
pub const KEY_LAST_VERIFIED_BLOCK_NUMBER: &[u8] = b"LAST_VERIFIED_BLOCK_NUMBER";
pub const KEY_PROVE_STEP_RECORD: &[u8] = b"PROVE_STEP_RECORD";
pub const KEY_LAST_VERIFIED_BATCH_NUMBER: &[u8] = b"LAST_VERIFIED_BATCH_NUMBER";
}

pub(crate) mod prefix {
Expand Down
Loading

0 comments on commit 00e4e61

Please sign in to comment.