Skip to content

Commit 0f1ffb3

Browse files
committed
papyrus_base_layer: add ordered list of provider URLs to the config
1 parent 245a3cc commit 0f1ffb3

File tree

18 files changed

+90
-68
lines changed

18 files changed

+90
-68
lines changed

config/papyrus/default_config.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"base_layer.ordered_l1_endpoint_urls": {
3+
"description": "An ordered list of URLs for communicating with Ethereum. The list is used in order, cyclically, switching if the current one is non-operational.",
4+
"privacy": "Private",
5+
"value": "https://mainnet.infura.io/v3/YOUR_INFURA_API_KEY"
6+
},
27
"base_layer.prague_blob_gas_calc": {
38
"description": "If true use the blob gas calculcation from the Pectra upgrade. If false use the EIP 4844 calculation.",
49
"privacy": "Public",
@@ -236,10 +241,8 @@
236241
},
237242
"context.build_proposal_time_ratio_for_retrospective_block_hash": {
238243
"description": "The fraction (0.0 - 1.0) of the total build time allocated to waiting for the retrospective block hash to be available. The remaining time is used to build the proposal.",
239-
"value": {
240-
"$serde_json::private::Number": "0.7"
241-
},
242-
"privacy": "Public"
244+
"privacy": "Public",
245+
"value": 0.7
243246
},
244247
"context.builder_address": {
245248
"description": "The address of the contract that builds the block.",
@@ -338,10 +341,8 @@
338341
},
339342
"context.retrospective_block_hash_retry_interval_millis": {
340343
"description": "The interval between retrospective block hash retries.",
341-
"value": {
342-
"$serde_json::private::Number": "500"
343-
},
344-
"privacy": "Public"
344+
"privacy": "Public",
345+
"value": 500
345346
},
346347
"context.validate_proposal_margin_millis": {
347348
"description": "Safety margin (in ms) to make sure that consensus determines when to timeout validating a proposal.",

crates/apollo_base_layer_tests/src/anvil_base_layer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ curl -L \
9696
Starknet::deploy(anvil_client.clone()).await.unwrap();
9797

9898
let config = Self::config();
99-
let url = Self::url();
99+
let url =
100+
config.ordered_l1_endpoint_urls.first().expect("No endpoint URLs provided").clone();
100101
let root_client = anvil_client.root().clone();
101102
let contract = Starknet::new(config.starknet_contract_address, root_client);
102103

@@ -123,6 +124,7 @@ curl -L \
123124
pub fn config() -> EthereumBaseLayerConfig {
124125
EthereumBaseLayerConfig {
125126
starknet_contract_address: Self::DEFAULT_ANVIL_L1_DEPLOYED_ADDRESS.parse().unwrap(),
127+
ordered_l1_endpoint_urls: vec![Self::url()],
126128
..Default::default()
127129
}
128130
}

crates/apollo_base_layer_tests/tests/anvil_starts_with_no_contract.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ async fn anvil_starts_with_no_contract() {
1717
let anvil = Anvil::new()
1818
.try_spawn()
1919
.expect("Anvil not installed, see anvil base layer for installation instructions.");
20-
let url = anvil.endpoint_url();
21-
let base_layer_config = EthereumBaseLayerConfig::default();
22-
let base_layer = EthereumBaseLayerContract::new(base_layer_config.clone(), url.clone());
20+
let base_layer_config = EthereumBaseLayerConfig {
21+
ordered_l1_endpoint_urls: vec![anvil.endpoint_url()],
22+
..Default::default()
23+
};
24+
let base_layer = EthereumBaseLayerContract::new(base_layer_config.clone());
2325

2426
let sender_address = ARBITRARY_ANVIL_L1_ACCOUNT_ADDRESS;
2527
let receiver_address = OTHER_ARBITRARY_ANVIL_L1_ACCOUNT_ADDRESS;
2628
make_block_history_on_anvil(
2729
sender_address,
2830
receiver_address,
2931
base_layer_config.clone(),
30-
&url,
3132
NUM_L1_TRANSACTIONS,
3233
)
3334
.await;

crates/apollo_deployments/resources/testing_secrets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"base_layer_config.ordered_l1_endpoint_urls": "http://anvil-service.anvil.svc.cluster.local:8545",
23
"consensus_manager_config.network_config.secret_key": "0x0101010101010101010101010101010101010101010101010101010101010101",
34
"l1_endpoint_monitor_config.ordered_l1_endpoint_urls": "http://anvil-service.anvil.svc.cluster.local:8545",
45
"l1_gas_price_provider_config.eth_to_strk_oracle_config.url_header_list": "http://dummy-eth2strk-oracle-service.dummy-eth2strk-oracle.svc.cluster.local/eth_to_strk_oracle?timestamp=:9000",

crates/apollo_deployments/src/test_utils.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ pub(crate) const FIX_BINARY_NAME: &str = "deployment_generator";
1111

1212
#[derive(Serialize)]
1313
pub struct SecretsConfigOverride {
14+
#[serde(
15+
rename = "base_layer_config.ordered_l1_endpoint_urls",
16+
serialize_with = "serialize_slice_wrapper"
17+
)]
18+
base_layer_config_ordered_l1_endpoint_urls: Vec<Url>,
1419
#[serde(
1520
rename = "consensus_manager_config.network_config.secret_key",
1621
serialize_with = "serialize_optional_vec_u8_wrapper"
@@ -47,6 +52,10 @@ pub struct SecretsConfigOverride {
4752
impl Default for SecretsConfigOverride {
4853
fn default() -> Self {
4954
Self {
55+
base_layer_config_ordered_l1_endpoint_urls: vec![
56+
Url::parse("https://arbitrary.ordered_l1_endpoint_1.url").unwrap(),
57+
Url::parse("https://arbitrary.ordered_l1_endpoint_2.url").unwrap(),
58+
],
5059
consensus_manager_config_network_config_secret_key: None,
5160
l1_endpoint_monitor_config_ordered_l1_endpoint_urls: vec![
5261
Url::parse("https://arbitrary.ordered_l1_endpoint_1.url").unwrap(),

crates/apollo_integration_tests/src/bin/sequencer_simulator.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,33 +136,31 @@ async fn initialize_anvil_state(sender_address: Address, receiver_address: Addre
136136
sender_address, receiver_address
137137
);
138138

139-
let (base_layer_config, base_layer_url) = build_base_layer_config_for_testing();
139+
let base_layer_config = build_base_layer_config_for_testing();
140140

141-
let ethereum_base_layer_contract =
142-
EthereumBaseLayerContract::new(base_layer_config.clone(), base_layer_url.clone());
141+
let ethereum_base_layer_contract = EthereumBaseLayerContract::new(base_layer_config.clone());
143142
Starknet::deploy(ethereum_base_layer_contract.contract.provider().clone()).await.unwrap();
144143

145144
make_block_history_on_anvil(
146145
sender_address,
147146
receiver_address,
148147
base_layer_config,
149-
&base_layer_url,
150148
NUM_BLOCKS_NEEDED_ON_L1,
151149
)
152150
.await;
153151
}
154152

155-
fn build_base_layer_config_for_testing() -> (EthereumBaseLayerConfig, Url) {
153+
fn build_base_layer_config_for_testing() -> EthereumBaseLayerConfig {
156154
let starknet_contract_address: EthereumContractAddress =
157155
DEFAULT_ANVIL_L1_DEPLOYED_ADDRESS.parse().expect("Invalid contract address");
158156
let node_url = Url::parse(ANVIL_NODE_URL).expect("Failed to parse Anvil URL");
159157

160-
let base_layer_config = EthereumBaseLayerConfig {
158+
EthereumBaseLayerConfig {
159+
ordered_l1_endpoint_urls: vec![node_url.clone()],
161160
starknet_contract_address,
162161
prague_blob_gas_calc: true,
163162
..Default::default()
164-
};
165-
(base_layer_config, node_url)
163+
}
166164
}
167165

168166
#[derive(Parser, Debug)]

crates/apollo_integration_tests/src/flow_test_setup.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ impl FlowTestSetup {
132132
sender_address,
133133
receiver_address,
134134
base_layer_config.clone(),
135-
&base_layer_url,
136135
NUM_L1_TRANSACTIONS,
137136
)
138137
.await;

crates/apollo_integration_tests/src/integration_test_manager.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use mempool_test_utils::starknet_api_test_utils::{
3434
MultiAccountTransactionGenerator,
3535
};
3636
use papyrus_base_layer::test_utils::anvil_mine_blocks;
37-
use papyrus_base_layer::BaseLayerContract;
3837
use starknet_api::block::BlockNumber;
3938
use starknet_api::core::{ChainId, Nonce};
4039
use starknet_api::execution_resources::GasAmount;
@@ -309,7 +308,6 @@ impl IntegrationTestManager {
309308
anvil_mine_blocks(
310309
anvil_base_layer.ethereum_base_layer.config.clone(),
311310
MIN_EXPECTED_BLOCK_NUMBER,
312-
&anvil_base_layer.get_url().await.expect("Failed to get anvil url."),
313311
)
314312
.await;
315313

crates/apollo_l1_provider/tests/utils/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,8 @@ fn convert_call_data_to_u256(call_data: &[u8]) -> Vec<Uint<256, 4>> {
6666
#[allow(dead_code)]
6767
pub(crate) async fn setup_anvil_base_layer() -> AnvilBaseLayer {
6868
let mut base_layer = AnvilBaseLayer::new(None).await;
69-
anvil_mine_blocks(
70-
base_layer.ethereum_base_layer.config.clone(),
71-
NUMBER_OF_BLOCKS_TO_MINE,
72-
&base_layer.ethereum_base_layer.get_url().await.expect("Failed to get anvil url."),
73-
)
74-
.await;
69+
anvil_mine_blocks(base_layer.ethereum_base_layer.config.clone(), NUMBER_OF_BLOCKS_TO_MINE)
70+
.await;
7571
// We use a really long timeout because in the tests we sometimes advance the fake time by large
7672
// jumps (e.g., when the runtime yields, tokio moves the fake time to the next pending timer).
7773
base_layer.ethereum_base_layer.config.timeout_millis = Duration::from_secs(10000);

crates/apollo_node/resources/config_schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"privacy": "TemporaryValue",
55
"value": false
66
},
7+
"base_layer_config.ordered_l1_endpoint_urls": {
8+
"description": "An ordered list of URLs for communicating with Ethereum. The list is used in order, cyclically, switching if the current one is non-operational.",
9+
"privacy": "Private",
10+
"value": "https://mainnet.infura.io/v3/YOUR_INFURA_API_KEY"
11+
},
712
"base_layer_config.prague_blob_gas_calc": {
813
"description": "If true use the blob gas calculcation from the Pectra upgrade. If false use the EIP 4844 calculation.",
914
"privacy": "Public",

0 commit comments

Comments
 (0)