Skip to content

Commit

Permalink
Merge branch 'dev' into vlad-bochok-zks-227-make-the-fee-seller-scrip…
Browse files Browse the repository at this point in the history
…t-resend-stuck
  • Loading branch information
vladbochok committed Feb 18, 2021
2 parents e6906b5 + 7ad1862 commit bfd92ea
Show file tree
Hide file tree
Showing 100 changed files with 2,106 additions and 1,081 deletions.
5 changes: 4 additions & 1 deletion Cargo.lock

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

4 changes: 4 additions & 0 deletions changelog/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ All notable changes to the core components will be documented in this file.

### Changed

- The token name is now set for each scenario separately instead of the network section of the loadtest configuration.
- Rejected transactions are now stored in the database for 2 weeks only.

### Added

- Added a stressing dev fee ticker scenario to the loadtest.
- Added a `--sloppy` mode to the `dev-fee-ticker-server` to simulate bad networks with the random delays and fails.

### Fixed

## Release 2021-02-02
Expand Down
6 changes: 6 additions & 0 deletions changelog/infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,23 @@ components, the logs will have the following format:

### Removed

- (`ci/Dockerfile`): `dockerci/Dockerfile` file with folder was removed , because it is outdated.

### Changed

- (`fee-seller`): migrating to zksync V0.9.0.

### Added

- (`reading-tool`): tool for reading test config.

### Fixed

- (`fee-seller`): Sends all Ethereum transactions with sequential nonce starting with the next available not finalized
nonce. Thereby resend stuck transactions after the next time you run the script.

- (`explorer`): Bug with 'Click to copy' button for account address.

## Release 2021-02-02

### Removed
Expand Down
25 changes: 25 additions & 0 deletions changelog/js-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,33 @@ All notable changes to `zksync.js` will be documented in this file.

### Added

- Method for calculation of transaction hash.

### Changed

### Deprecated

- `Signer.transferSignBytes` method
- `Signer.withdrawSignBytes` method
- `Signer.forcedExitSignBytes` method
- `Signer.changePubKeySignBytes` method

### Fixed

## Version 0.9.0 (15.02.2021)

### Added

- Support of the new contracts upgrade functionality.
- BatchBuilder class for convenient batches creating.
- `zksync-crypto` release 0.4.5.

### Changed

### Deprecated

- WebSocket provider.

### Fixed

## Version 0.8.4
Expand Down
17 changes: 16 additions & 1 deletion changelog/rust-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@ All notable changes to `zksync_rs` will be documented in this file.

## Unreleased

**Version 0.2.2** is being developed.
### Added

### Changed

### Deprecated

### Fixed

## Version 0.3.0 (15.02.2021)

### Added

- Constructor of RpcProvider from address and network.
- Support of the new contracts upgrade functionality.

## Version 0.2.2

### Added

Expand Down
55 changes: 6 additions & 49 deletions core/bin/data_restore/src/contract/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use web3::api::Eth;
use web3::contract::Options;
use web3::types::{Address, BlockId, BlockNumber, U256};
use web3::types::{Address, BlockId, U256};
use web3::Transport;

use zksync_contracts::{
Expand All @@ -20,18 +20,10 @@ pub struct ZkSyncDeployedContract<T: Transport> {
pub web3_contract: web3::contract::Contract<T>,
pub abi: ethabi::Contract,
pub version: ZkSyncContractVersion,
pub from: BlockNumber,
pub to: BlockNumber,
}

impl<T: Transport> ZkSyncDeployedContract<T> {
/// Returns total number of verified blocks on Rollup contract
///
/// # Arguments
///
/// * `web3` - Web3 provider url
/// * `zksync_contract` - Rollup contract
///
pub async fn get_total_verified_blocks(&self) -> u32 {
use ZkSyncContractVersion::*;
let func = match self.version {
Expand All @@ -51,79 +43,44 @@ impl<T: Transport> ZkSyncDeployedContract<T> {
.as_u32()
}

pub fn version0(
eth: Eth<T>,
address: Address,
from: BlockNumber,
to: BlockNumber,
) -> ZkSyncDeployedContract<T> {
pub fn version0(eth: Eth<T>, address: Address) -> ZkSyncDeployedContract<T> {
let abi = zksync_contract_v0();
ZkSyncDeployedContract {
web3_contract: web3::contract::Contract::new(eth, address, abi.clone()),
abi,
version: ZkSyncContractVersion::V0,
from,
to,
}
}
pub fn version1(
eth: Eth<T>,
address: Address,
from: BlockNumber,
to: BlockNumber,
) -> ZkSyncDeployedContract<T> {
pub fn version1(eth: Eth<T>, address: Address) -> ZkSyncDeployedContract<T> {
let abi = zksync_contract_v1();
ZkSyncDeployedContract {
web3_contract: web3::contract::Contract::new(eth, address, abi.clone()),
abi,
version: ZkSyncContractVersion::V1,
from,
to,
}
}
pub fn version2(
eth: Eth<T>,
address: Address,
from: BlockNumber,
to: BlockNumber,
) -> ZkSyncDeployedContract<T> {
pub fn version2(eth: Eth<T>, address: Address) -> ZkSyncDeployedContract<T> {
let abi = zksync_contract_v2();
ZkSyncDeployedContract {
web3_contract: web3::contract::Contract::new(eth, address, abi.clone()),
abi,
version: ZkSyncContractVersion::V2,
from,
to,
}
}
pub fn version3(
eth: Eth<T>,
address: Address,
from: BlockNumber,
to: BlockNumber,
) -> ZkSyncDeployedContract<T> {
pub fn version3(eth: Eth<T>, address: Address) -> ZkSyncDeployedContract<T> {
let abi = zksync_contract_v3();
ZkSyncDeployedContract {
web3_contract: web3::contract::Contract::new(eth, address, abi.clone()),
abi,
version: ZkSyncContractVersion::V3,
from,
to,
}
}
pub fn version4(
eth: Eth<T>,
address: Address,
from: BlockNumber,
to: BlockNumber,
) -> ZkSyncDeployedContract<T> {
pub fn version4(eth: Eth<T>, address: Address) -> ZkSyncDeployedContract<T> {
let abi = zksync_contract();
ZkSyncDeployedContract {
web3_contract: web3::contract::Contract::new(eth, address, abi.clone()),
abi,
version: ZkSyncContractVersion::V4,
from,
to,
}
}
}
64 changes: 31 additions & 33 deletions core/bin/data_restore/src/contract/v4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn decode_commitment_parameters(input_data: Vec<u8>) -> anyhow::Result<Vec<Token
let commit_operation = ParamType::Tuple(vec![
Box::new(ParamType::FixedBytes(32)), // bytes32 encoded_root,
Box::new(ParamType::Bytes), // bytes calldata _publicData,
Box::new(ParamType::Uint(256)), // uint64 _timestamp,
Box::new(ParamType::Uint(256)), // uint256 _timestamp,
Box::new(ParamType::Array(Box::new(ParamType::Tuple(vec![
Box::new(ParamType::Bytes), // bytes eht_witness
Box::new(ParamType::Uint(32)), //uint32 public_data_offset
Expand All @@ -18,7 +18,7 @@ fn decode_commitment_parameters(input_data: Vec<u8>) -> anyhow::Result<Vec<Token
let stored_block = ParamType::Tuple(vec![
Box::new(ParamType::Uint(32)), // uint32 _block_number
Box::new(ParamType::Uint(64)), // uint32 _number_of_processed_prior_ops
Box::new(ParamType::FixedBytes(32)), //bytes32 processable_ops_hash
Box::new(ParamType::FixedBytes(32)), // bytes32 processable_ops_hash
Box::new(ParamType::Uint(256)), // uint256 timestamp
Box::new(ParamType::FixedBytes(32)), // bytes32 eth_encoded_root
Box::new(ParamType::FixedBytes(32)), // commitment
Expand All @@ -37,44 +37,42 @@ fn decode_commitment_parameters(input_data: Vec<u8>) -> anyhow::Result<Vec<Token

pub fn rollup_ops_blocks_from_bytes(data: Vec<u8>) -> anyhow::Result<Vec<RollupOpsBlock>> {
let fee_account_argument_id = 5;
let op_block_number_argument_id = 4;
let public_data_argument_id = 1;

let decoded_commitment_parameters = decode_commitment_parameters(data)?;
assert_eq!(decoded_commitment_parameters.len(), 2);

if let (ethabi::Token::Tuple(block), ethabi::Token::Array(operations)) = (
&decoded_commitment_parameters[0],
&decoded_commitment_parameters[1],
) {
// Destruct deserialized parts of transaction input data for getting operations
// Input data consists of stored block and operations
// Transform operations to RollupBlock
if let ethabi::Token::Array(operations) = &decoded_commitment_parameters[1] {
let mut blocks = vec![];
if let ethabi::Token::Uint(block_num) = block[0] {
for operation in operations {
if let ethabi::Token::Tuple(operation) = operation {
if let (ethabi::Token::Uint(fee_acc), ethabi::Token::Bytes(public_data)) = (
&operation[fee_account_argument_id],
&operation[public_data_argument_id],
) {
let ops = get_rollup_ops_from_data(public_data.as_slice())?;
blocks.push(RollupOpsBlock {
block_num: BlockNumber(block_num.as_u32()),
ops,
fee_account: AccountId(fee_acc.as_u32()),
})
} else {
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"can't parse operation parameters",
)
.into());
}
for operation in operations {
if let ethabi::Token::Tuple(operation) = operation {
if let (
ethabi::Token::Uint(fee_acc),
ethabi::Token::Bytes(public_data),
ethabi::Token::Uint(block_number),
) = (
&operation[fee_account_argument_id],
&operation[public_data_argument_id],
&operation[op_block_number_argument_id],
) {
let ops = get_rollup_ops_from_data(public_data.as_slice())?;
blocks.push(RollupOpsBlock {
block_num: BlockNumber(block_number.as_u32()),
ops,
fee_account: AccountId(fee_acc.as_u32()),
})
} else {
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"can't parse operation parameters",
)
.into());
}
}
} else {
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"can't parse block parameters",
)
.into());
}
Ok(blocks)
} else {
Expand Down Expand Up @@ -128,7 +126,7 @@ mod test {
let blocks = rollup_ops_blocks_from_bytes(input_data[4..].to_vec()).unwrap();
assert_eq!(blocks.len(), 1);
let block = blocks[0].clone();
assert_eq!(block.block_num, BlockNumber(24));
assert_eq!(block.block_num, BlockNumber(25));
assert_eq!(block.fee_account, AccountId(0));
assert_eq!(block.ops.len(), 5);
}
Expand Down
Loading

0 comments on commit bfd92ea

Please sign in to comment.