Skip to content

Commit

Permalink
All from 53edd2a to current dev (244724b)
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Dec 9, 2021
1 parent 893a716 commit 30a7efb
Show file tree
Hide file tree
Showing 192 changed files with 4,103 additions and 2,157 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ jobs:

- name: run-services
run: |
ci_run zk server &>server.log &
ci_run zk server core &>server.log &
ci_run zk server api &>api.log &
ci_run sleep 10
ci_run zk dummy-prover run &>dummy_prover.log &
ci_run sleep 100
Expand All @@ -133,6 +134,7 @@ jobs:
if: always()
run: |
ci_run cat server.log
ci_run cat api.log
ci_run cat dummy_prover.log
circuit-tests:
Expand Down
33 changes: 1 addition & 32 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ members = [
"core/bin/prover",
"core/bin/parse_pub_data",
"core/bin/block_revert",
"core/bin/mint_nft_nonce_migration",
"core/bin/token_kind_migration",
"core/bin/tx_filters_migration",

# Server micro-services
"core/bin/zksync_api",
Expand Down
17 changes: 12 additions & 5 deletions core/bin/block_revert/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use web3::{
contract::Options,
types::{TransactionReceipt, U256, U64},
};
use zksync_config::ZkSyncConfig;
use zksync_config::{ContractsConfig, ETHClientConfig, ETHSenderConfig};
use zksync_eth_client::EthereumGateway;
use zksync_storage::StorageProcessor;
use zksync_types::{aggregated_operations::stored_block_info, block::Block, BlockNumber, H256};
Expand Down Expand Up @@ -165,7 +165,7 @@ async fn revert_blocks_on_contract(
.sign_prepared_tx(data, Options::with(|f| f.gas = Some(U256::from(gas_limit))))
.await
.map_err(|e| format_err!("Revert blocks send err: {}", e))?;
let receipt = send_raw_tx_and_wait_confirmation(&client, signed_tx.raw_tx).await?;
let receipt = send_raw_tx_and_wait_confirmation(client, signed_tx.raw_tx).await?;
storage.ethereum_schema().get_next_nonce().await
.expect("Ethereum tx has been sent but updating operator nonce in storage has failed. You need to update it manually");
ensure!(
Expand Down Expand Up @@ -226,18 +226,25 @@ struct Opt {
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let opt = Opt::from_args();
let mut config = ZkSyncConfig::from_env();

let key_without_prefix = opt
.operator_private_key
.strip_prefix("0x")
.unwrap_or_else(|| opt.operator_private_key.as_str());

config.eth_sender.sender.operator_private_key =
let contracts = ContractsConfig::from_env();
let eth_client_config = ETHClientConfig::from_env();
let mut eth_sender_config = ETHSenderConfig::from_env();

eth_sender_config.sender.operator_private_key =
H256::from_str(key_without_prefix).expect("Cannot deserialize private key");

let mut storage = StorageProcessor::establish_connection().await?;
let client = EthereumGateway::from_config(&config);
let client = EthereumGateway::from_config(
&eth_client_config,
&eth_sender_config,
contracts.contract_addr,
);

let last_commited_block = storage
.chain()
Expand Down
4 changes: 2 additions & 2 deletions core/bin/data_restore/src/contract/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn get_genesis_account(genesis_transaction: &Transaction) -> Result<Account,
const ENCODED_INIT_PARAMETERS_WIDTH: usize =
6 * INPUT_DATA_ADDRESS_BYTES_WIDTH + INPUT_DATA_ROOT_HASH_BYTES_WIDTH;

let input_data = get_input_data_from_ethereum_transaction(&genesis_transaction)?;
let input_data = get_input_data_from_ethereum_transaction(genesis_transaction)?;

// Input for contract constructor contains the bytecode of the contract and
// encoded arguments after it.
Expand Down Expand Up @@ -55,7 +55,7 @@ pub fn get_genesis_account(genesis_transaction: &Transaction) -> Result<Account,
})?;
match &decoded_init_parameters[fee_account_address_argument_id] {
ethabi::Token::Address(genesis_operator_address) => {
Some(Account::default_with_address(&genesis_operator_address))
Some(Account::default_with_address(genesis_operator_address))
}
_ => None,
}
Expand Down
4 changes: 2 additions & 2 deletions core/bin/data_restore/src/contract/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub(super) fn rollup_ops_blocks_from_bytes_inner(
if let ethabi::Token::FixedBytes(root_hash) =
&prev_stored[previous_block_root_hash_argument_id]
{
H256::from_slice(&root_hash)
H256::from_slice(root_hash)
} else {
panic!("can't parse root hash param: {:#?}", prev_stored);
}
Expand Down Expand Up @@ -107,7 +107,7 @@ pub(super) fn rollup_ops_blocks_from_bytes_inner(
contract_version: None,
});

previous_block_root_hash = H256::from_slice(&root_hash);
previous_block_root_hash = H256::from_slice(root_hash);
} else {
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
Expand Down
3 changes: 1 addition & 2 deletions core/bin/data_restore/src/events_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ impl EventsState {
&mut self,
genesis_transaction: &Transaction,
) -> Result<u64, anyhow::Error> {
let genesis_block_number =
get_block_number_from_ethereum_transaction(&genesis_transaction)?;
let genesis_block_number = get_block_number_from_ethereum_transaction(genesis_transaction)?;
self.last_watched_eth_block_number = genesis_block_number;
Ok(genesis_block_number)
}
Expand Down
3 changes: 1 addition & 2 deletions core/bin/data_restore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ pub const ETH_BLOCKS_STEP: u64 = 10_000;
pub const END_ETH_BLOCKS_OFFSET: u64 = 40;

pub async fn add_tokens_to_storage(interactor: &mut StorageInteractor<'_>, eth_network: &str) {
let genesis_tokens =
get_genesis_token_list(&eth_network).expect("Initial token list not found");
let genesis_tokens = get_genesis_token_list(eth_network).expect("Initial token list not found");
for (id, token) in (1..).zip(genesis_tokens) {
let add_token_log = format!(
"Adding token: {}, id:{}, address: {}, decimals: {}",
Expand Down
1 change: 1 addition & 0 deletions core/bin/data_restore/src/storage_interactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct CachedTreeState {
pub nfts: HashMap<TokenId, NFT>,
}

#[allow(clippy::large_enum_variant)]
pub enum StorageInteractor<'a> {
Database(DatabaseStorageInteractor<'a>),
InMemory(InMemoryStorageInteractor),
Expand Down
2 changes: 1 addition & 1 deletion core/bin/data_restore/src/tree_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ impl TreeState {
last_unprocessed_prior_op,
self.current_unprocessed_priority_op,
),
&available_block_chunk_sizes,
available_block_chunk_sizes,
gas_limit,
gas_limit,
ops_block.previous_block_root_hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub(crate) fn rendered_key(
map.insert("omega".to_owned(), to_json(render_scalar_to_hex(&omega)));

for (i, c) in vk.gate_setup_commitments.iter().enumerate() {
let rendered = render_g1_affine_to_hex::<NodeEngine>(&c);
let rendered = render_g1_affine_to_hex::<NodeEngine>(c);

for (j, rendered) in rendered.iter().enumerate() {
map.insert(
Expand All @@ -52,7 +52,7 @@ pub(crate) fn rendered_key(
}

for (i, c) in vk.gate_selectors_commitments.iter().enumerate() {
let rendered = render_g1_affine_to_hex::<NodeEngine>(&c);
let rendered = render_g1_affine_to_hex::<NodeEngine>(c);

for (j, rendered) in rendered.iter().enumerate() {
map.insert(
Expand All @@ -63,7 +63,7 @@ pub(crate) fn rendered_key(
}

for (i, c) in vk.permutation_commitments.iter().enumerate() {
let rendered = render_g1_affine_to_hex::<NodeEngine>(&c);
let rendered = render_g1_affine_to_hex::<NodeEngine>(c);

for (j, rendered) in rendered.iter().enumerate() {
map.insert(
Expand Down Expand Up @@ -106,7 +106,7 @@ pub(crate) fn rendered_key_single_proof(
let omega = domain.generator;
map.insert("omega".to_owned(), to_json(render_scalar_to_hex(&omega)));
for (i, c) in vk.selector_commitments.iter().enumerate() {
let rendered = render_g1_affine_to_hex::<NodeEngine>(&c);
let rendered = render_g1_affine_to_hex::<NodeEngine>(c);

for (j, rendered) in rendered.iter().enumerate() {
map.insert(
Expand All @@ -116,7 +116,7 @@ pub(crate) fn rendered_key_single_proof(
}
}
for (i, c) in vk.next_step_selector_commitments.iter().enumerate() {
let rendered = render_g1_affine_to_hex::<NodeEngine>(&c);
let rendered = render_g1_affine_to_hex::<NodeEngine>(c);

for (j, rendered) in rendered.iter().enumerate() {
map.insert(
Expand All @@ -126,7 +126,7 @@ pub(crate) fn rendered_key_single_proof(
}
}
for (i, c) in vk.permutation_commitments.iter().enumerate() {
let rendered = render_g1_affine_to_hex::<NodeEngine>(&c);
let rendered = render_g1_affine_to_hex::<NodeEngine>(c);
for (j, rendered) in rendered.iter().enumerate() {
map.insert(
format!("permutation_commitment_{}_{}", i, j),
Expand Down
18 changes: 0 additions & 18 deletions core/bin/mint_nft_nonce_migration/Cargo.toml

This file was deleted.

13 changes: 0 additions & 13 deletions core/bin/mint_nft_nonce_migration/src/main.rs

This file was deleted.

2 changes: 1 addition & 1 deletion core/bin/parse_pub_data/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {
"not enough bytes in the pubdata for current op"
);
let (current_op, unparsed) = unparsed_data.split_at(op_data_len);
let op = ZkSyncOp::from_public_data(&current_op).expect("failed to parse pubdata");
let op = ZkSyncOp::from_public_data(current_op).expect("failed to parse pubdata");
println!("{:#?}", op);
unparsed_data = unparsed;
}
Expand Down
4 changes: 1 addition & 3 deletions core/bin/prover/src/dummy_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ impl ProverConfig for DummyProverConfig {

#[derive(Debug)]
pub struct DummyProver {
config: DummyProverConfig,
precomputed_proofs: PrecomputedSampleProofs,
}

impl ProverImpl for DummyProver {
type Config = DummyProverConfig;

fn create_from_config(config: Self::Config) -> Self {
fn create_from_config(_config: Self::Config) -> Self {
Self {
config,
precomputed_proofs: load_precomputed_proofs()
.expect("Failed to load precomputed proofs"),
}
Expand Down
2 changes: 1 addition & 1 deletion core/bin/prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async fn heartbeat_future_handle<CLIENT>(
vlog::debug!("Starting sending heartbeats for job with ID: {}", job_id);

client
.working_on(job_id, &prover_name)
.working_on(job_id, prover_name)
.await
.map_err(|e| vlog::warn!("Failed to send heartbeat: {}", e))
.unwrap_or_default();
Expand Down
2 changes: 1 addition & 1 deletion core/bin/prover/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn test_data_for_prover() -> JobRequestData {
account_id: empty_account_id,
};

let deposit_witness = DepositWitness::apply_tx(&mut witness_accum.account_tree, &deposit_op);
let deposit_witness = DepositWitness::apply_tx(witness_accum.account_tree, &deposit_op);
let deposit_operations = deposit_witness.calculate_operations(());
let pub_data_from_witness = deposit_witness.get_pubdata();
let offset_commitment = deposit_witness.get_offset_commitment_data();
Expand Down
6 changes: 3 additions & 3 deletions core/bin/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ zksync_prometheus_exporter = { path = "../../lib/prometheus_exporter", version =
zksync_config = { path = "../../lib/config", version = "1.0" }
zksync_storage = { path = "../../lib/storage", version = "1.0" }
zksync_gateway_watcher = { path = "../../lib/gateway_watcher", version = "1.0" }
zksync_utils = { path = "../../lib/utils", version = "1.0" }
zksync_types = { path = "../../lib/types", version = "1.0" }

anyhow = "1.0"
structopt = "0.3.20"
ctrlc = { version = "3.1", features = ["termination"] }
futures = "0.3"
tokio = { version = "1", features = ["full"] }
serde = "1.0.90"

vlog = { path = "../../lib/vlog", version = "1.0" }

[dev-dependencies]
zksync_crypto = { path = "../../lib/crypto", version = "1.0" }
zksync_types = { path = "../../lib/types", version = "1.0" }
zksync_prover = { path = "../prover", version = "1.0" }
zksync_utils = { path = "../../lib/utils", version = "1.0" }

num = { version = "0.3.1", features = ["serde"] }
serde = "1.0.90"
serde_json = "1.0.0"
Loading

0 comments on commit 30a7efb

Please sign in to comment.