Skip to content
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

feat: Minimal External API Fetcher #2383

Merged
merged 36 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8035619
cg api. node framework draft.
shahar4 Jul 4, 2024
f0277a6
fmt
shahar4 Jul 4, 2024
d64b34a
coingecko client implementation
dimazhornyk Jul 4, 2024
7c5ac80
fixes
dimazhornyk Jul 4, 2024
1985476
tested implementation
dimazhornyk Jul 5, 2024
5de6ecb
resolve conflicts
dimazhornyk Jul 5, 2024
bbe9353
fixes
dimazhornyk Jul 5, 2024
6c03ef8
fix lint
dimazhornyk Jul 5, 2024
cff271b
fix linter
dimazhornyk Jul 5, 2024
3be18c9
fix Cargo.lock
dimazhornyk Jul 5, 2024
b299ead
fix prover
dimazhornyk Jul 5, 2024
c02f063
fix fmt
dimazhornyk Jul 5, 2024
06e013c
remove base_token_ratio_persister from CI runs
dimazhornyk Jul 5, 2024
d4d8109
run base token persister if CI is testing base token
shahar4 Jul 8, 2024
5b02cf7
layer to run from its own component or default resource is used
shahar4 Jul 8, 2024
b16d483
fix lint
shahar4 Jul 8, 2024
80c7bf9
removed unit tests and httpmock
shahar4 Jul 8, 2024
59cbe99
one req to cg, not two. BaseTokenAPIPrice to be ratio
shahar4 Jul 8, 2024
195541e
merge main
shahar4 Jul 8, 2024
a610f81
adjust to new framework changes
shahar4 Jul 8, 2024
4a0a4c2
explicit layer per resource. no-op layer based on config
shahar4 Jul 8, 2024
8db7e8c
lint and lock
shahar4 Jul 8, 2024
71370cc
prover cargo lock
shahar4 Jul 8, 2024
9b273d1
Cluster base token layers and improve API client layer creation
popzxc Jul 9, 2024
752ffdc
source non options. loop error non transient
shahar4 Jul 9, 2024
31e2c3c
fix missing config
shahar4 Jul 9, 2024
d2da2d4
change ethereum->eth
shahar4 Jul 9, 2024
b6f4899
Merge main.
shahar4 Jul 9, 2024
a65c4ff
added forced price client
shahar4 Jul 9, 2024
5fa5294
randomizing ratio
shahar4 Jul 9, 2024
a996202
comments and lint
shahar4 Jul 9, 2024
f9b4364
revert submodule update
shahar4 Jul 9, 2024
ae1f5c8
config unit test
shahar4 Jul 9, 2024
239f203
merge main
shahar4 Jul 9, 2024
981f45d
no-op client for CI
shahar4 Jul 9, 2024
14069fe
no-op client for CI for real now
shahar4 Jul 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci-core-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
base_token: ["Eth", "Custom"]
deployment_mode: ["Rollup", "Validium"]
env:
SERVER_COMPONENTS: "api,tree,eth,state_keeper,housekeeper,commitment_generator,vm_runner_protective_reads,vm_runner_bwip,da_dispatcher,base_token_ratio_persister${{ matrix.consensus && ',consensus' || '' }}"
SERVER_COMPONENTS: "api,tree,eth,state_keeper,housekeeper,commitment_generator,vm_runner_protective_reads,vm_runner_bwip,da_dispatcher${{ matrix.consensus && ',consensus' || '' }}${{ matrix.base_token == 'Custom' && ',base_token_ratio_persister' || '' }}"

runs-on: [matterlabs-ci-runner]
steps:
Expand Down Expand Up @@ -309,7 +309,7 @@ jobs:
runs-on: [matterlabs-ci-runner]

env:
SERVER_COMPONENTS: "api,tree,eth,state_keeper,housekeeper,commitment_generator,vm_runner_protective_reads,vm_runner_bwip,da_dispatcher,base_token_ratio_persister${{ matrix.consensus && ',consensus' || '' }}"
SERVER_COMPONENTS: "api,tree,eth,state_keeper,housekeeper,commitment_generator,vm_runner_protective_reads,vm_runner_bwip,da_dispatcher${{ matrix.consensus && ',consensus' || '' }}${{ matrix.base_token == 'Custom' && ',base_token_ratio_persister' || '' }}"
EXT_NODE_FLAGS: "${{ matrix.consensus && '-- --enable-consensus' || '' }}"

steps:
Expand Down
85 changes: 56 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ tracing-subscriber = "0.3"
tracing-opentelemetry = "0.21.0"
url = "2"
web3 = "0.19.0"
fraction = "0.15.3"

# Proc-macro
syn = "2.0"
Expand Down
10 changes: 6 additions & 4 deletions core/bin/zksync_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ use zksync_config::{
fri_prover_group::FriProverGroupConfig,
house_keeper::HouseKeeperConfig,
BasicWitnessInputProducerConfig, ContractsConfig, DatabaseSecrets,
FriProofCompressorConfig, FriProverConfig, FriProverGatewayConfig,
FriWitnessGeneratorConfig, FriWitnessVectorGeneratorConfig, L1Secrets, ObservabilityConfig,
PrometheusConfig, ProofDataHandlerConfig, ProtectiveReadsWriterConfig, Secrets,
ExternalPriceApiClientConfig, FriProofCompressorConfig, FriProverConfig,
FriProverGatewayConfig, FriWitnessGeneratorConfig, FriWitnessVectorGeneratorConfig,
L1Secrets, ObservabilityConfig, PrometheusConfig, ProofDataHandlerConfig,
ProtectiveReadsWriterConfig, Secrets,
},
ApiConfig, BaseTokenAdjusterConfig, ContractVerifierConfig, DADispatcherConfig, DBConfig,
EthConfig, EthWatchConfig, GasAdjusterConfig, GenesisConfig, ObjectStoreConfig, PostgresConfig,
Expand Down Expand Up @@ -43,7 +44,7 @@ struct Cli {
/// Comma-separated list of components to launch.
#[arg(
long,
default_value = "api,tree,eth,state_keeper,housekeeper,tee_verifier_input_producer,commitment_generator,da_dispatcher,base_token_ratio_persister"
default_value = "api,tree,eth,state_keeper,housekeeper,tee_verifier_input_producer,commitment_generator,da_dispatcher"
)]
components: ComponentsToRun,
/// Path to the yaml config. If set, it will be used instead of env vars.
Expand Down Expand Up @@ -230,5 +231,6 @@ fn load_env_config() -> anyhow::Result<TempConfigStore> {
commitment_generator: None,
pruning: None,
snapshot_recovery: None,
external_price_api_client_config: ExternalPriceApiClientConfig::from_env().ok(),
})
}
38 changes: 34 additions & 4 deletions core/bin/zksync_server/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ use zksync_node_api_server::{
};
use zksync_node_framework::{
implementations::layers::{
base_token_ratio_persister::BaseTokenRatioPersisterLayer,
base_token_ratio_provider::BaseTokenRatioProviderLayer,
base_token::{
base_token_ratio_persister::BaseTokenRatioPersisterLayer,
base_token_ratio_provider::BaseTokenRatioProviderLayer,
coingecko_client::CoingeckoClientLayer, forced_price_client::ForcedPriceClientLayer,
no_op_external_price_api_client::NoOpExternalPriceApiClientLayer,
},
circuit_breaker_checker::CircuitBreakerCheckerLayer,
commitment_generator::CommitmentGeneratorLayer,
consensus::MainNodeConsensusLayer,
Expand Down Expand Up @@ -516,6 +520,29 @@ impl MainNodeBuilder {
Ok(self)
}

fn add_external_api_client_layer(mut self) -> anyhow::Result<Self> {
let config = try_load_config!(self.configs.external_price_api_client_config);
match config.source.as_str() {
CoingeckoClientLayer::CLIENT_NAME => {
self.node.add_layer(CoingeckoClientLayer::new(config));
}
NoOpExternalPriceApiClientLayer::CLIENT_NAME => {
self.node.add_layer(NoOpExternalPriceApiClientLayer);
}
ForcedPriceClientLayer::CLIENT_NAME => {
self.node.add_layer(ForcedPriceClientLayer::new(config));
}
_ => {
anyhow::bail!(
"Unknown external price API client source: {}",
config.source
);
}
}

Ok(self)
}

fn add_vm_runner_bwip_layer(mut self) -> anyhow::Result<Self> {
let basic_witness_input_producer_config =
try_load_config!(self.configs.basic_witness_input_producer_config);
Expand All @@ -529,8 +556,9 @@ impl MainNodeBuilder {

fn add_base_token_ratio_persister_layer(mut self) -> anyhow::Result<Self> {
let config = try_load_config!(self.configs.base_token_adjuster);
let contracts_config = self.contracts_config.clone();
self.node
.add_layer(BaseTokenRatioPersisterLayer::new(config));
.add_layer(BaseTokenRatioPersisterLayer::new(config, contracts_config));

Ok(self)
}
Expand Down Expand Up @@ -669,7 +697,9 @@ impl MainNodeBuilder {
self = self.add_vm_runner_protective_reads_layer()?;
}
Component::BaseTokenRatioPersister => {
self = self.add_base_token_ratio_persister_layer()?;
self = self
.add_external_api_client_layer()?
.add_base_token_ratio_persister_layer()?;
}
Component::VmRunnerBwip => {
self = self.add_vm_runner_bwip_layer()?;
Expand Down
1 change: 1 addition & 0 deletions core/lib/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ zksync_crypto_primitives.workspace = true
zksync_consensus_utils.workspace = true
zksync_concurrency.workspace = true

url.workspace = true
anyhow.workspace = true
rand.workspace = true
secrecy.workspace = true
Expand Down
Loading
Loading