Skip to content

Commit

Permalink
Sync with dev
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Dec 3, 2021
2 parents 506f0c6 + 78e35f3 commit e94f95e
Show file tree
Hide file tree
Showing 216 changed files with 2,830 additions and 2,920 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
58 changes: 2 additions & 56 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
2 changes: 1 addition & 1 deletion contracts/scripts/deploy-testnet-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function main() {
const parser = new ArgumentParser({
version: '0.1.0',
addHelp: true,
description: 'Deploy contracts and publish them on Etherscan/Tesseracts'
description: 'Deploy contracts and publish them on Etherscan'
});
parser.addArgument('--publish', {
required: false,
Expand Down
2 changes: 1 addition & 1 deletion contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function main() {
const parser = new ArgumentParser({
version: '0.1.0',
addHelp: true,
description: 'Deploy contracts and publish them on Etherscan/Tesseracts'
description: 'Deploy contracts and publish them on Etherscan'
});
parser.addArgument('--deployerPrivateKey', { required: false, help: 'Wallet used to deploy contracts.' });
parser.addArgument('--governor', { required: false, help: 'governor address' });
Expand Down
2 changes: 1 addition & 1 deletion contracts/scripts/upgrade-testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function main() {
const parser = new ArgumentParser({
version: '0.1.0',
addHelp: true,
description: 'Deploy new contracts and upgrade testnet proxy Tesseracts'
description: 'Deploy new contracts and upgrade testnet proxy'
});
parser.addArgument('--deployerPrivateKey', { required: false, help: 'Wallet used to deploy contracts.' });
parser.addArgument('--governor', { required: false, help: 'governor address' });
Expand Down
20 changes: 19 additions & 1 deletion contracts/scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import { ethers } from 'ethers';
import { ParamType } from '@ethersproject/abi';
import * as chalk from 'chalk';

const warning = chalk.bold.yellow;

export function web3Url() {
return process.env.ETH_CLIENT_WEB3_URL.split(',')[0] as string;
}

export function web3Provider() {
return new ethers.providers.JsonRpcProvider(web3Url());
const provider = new ethers.providers.JsonRpcProvider(web3Url());

// Check that `CHAIN_ETH_NETWORK` variable is set. If not, it's most likely because
// the variable was renamed. As this affects the time to deploy contracts in localhost
// scenario, it surely deserves a warning.
const network = process.env.CHAIN_ETH_NETWORK;
if (!network) {
console.log(warning('Network variable is not set. Check if contracts/scripts/utils.ts is correct'));
}

// Short polling interval for local network
if (network === 'localhost') {
provider.pollingInterval = 100;
}

return provider;
}

export function storedBlockInfoParam(): ParamType {
Expand Down
20 changes: 1 addition & 19 deletions contracts/src.ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { deployContract } from 'ethereum-waffle';
import { ethers, Signer, providers } from 'ethers';
import { formatEther, Interface } from 'ethers/lib/utils';
import * as fs from 'fs';
import {
encodeConstructorArgs,
encodeProxyContstuctorArgs,
publishAbiToTesseracts,
publishSourceCodeToEtherscan
} from './publish-utils';
import { encodeConstructorArgs, encodeProxyContstuctorArgs, publishSourceCodeToEtherscan } from './publish-utils';
import {
Governance,
GovernanceFactory,
Expand Down Expand Up @@ -405,19 +400,6 @@ export class Deployer {
this.addresses.RegenesisMultisig = regenesisMultisigContract.address;
}

public async publishSourcesToTesseracts() {
console.log('Publishing ABI for UpgradeGatekeeper');
await publishAbiToTesseracts(this.addresses.UpgradeGatekeeper, this.contracts.upgradeGatekeeper);
console.log('Publishing ABI for ZkSync (proxy)');
await publishAbiToTesseracts(this.addresses.ZkSync, this.contracts.zkSync);
console.log('Publishing ABI for Verifier (proxy)');
await publishAbiToTesseracts(this.addresses.Verifier, this.contracts.verifier);
console.log('Publishing ABI for Governance (proxy)');
await publishAbiToTesseracts(this.addresses.Governance, this.contracts.governance);
console.log('Publishing ABI for ForcedExit');
await publishAbiToTesseracts(this.addresses.ForcedExit, this.contracts.forcedExit);
}

public async publishSourcesToEtherscan() {
console.log('Publishing sourcecode for UpgradeGatekeeper', this.addresses.UpgradeGatekeeper);
await publishSourceCodeToEtherscan(
Expand Down
20 changes: 0 additions & 20 deletions contracts/src.ts/publish-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,6 @@ export async function publishSourceCodeToEtherscan(
}
}

export async function publishAbiToTesseracts(address: string, contractCode) {
const network = process.env.CHAIN_ETH_NETWORK;
if (network !== 'localhost') {
throw new Error('Only localhost network is supported by Tesseracts');
}
const req = {
contract_source: JSON.stringify(contractCode.abi),
contract_compiler: 'abi-only',
contract_name: '',
contract_optimized: false
};

const config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
};
await Axios.post(`http://localhost:8000/${address}/contract`, qs.stringify(req), config);
}

export function encodeConstructorArgs(contractCode, args) {
const iface = contractCode.abi.filter((i) => i.type === 'constructor');
if (iface.length === 0) {
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
Loading

0 comments on commit e94f95e

Please sign in to comment.