Skip to content

Commit

Permalink
Merge pull request #1462 from matter-labs/dev
Browse files Browse the repository at this point in the history
Merge dev into breaking
  • Loading branch information
Deniallugo authored Mar 20, 2021
2 parents 857835e + b19c207 commit 9f1f10a
Show file tree
Hide file tree
Showing 119 changed files with 1,465 additions and 2,808 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@
!contracts/artifacts
!infrastructure/explorer/index.html
!infrastructure/explorer/dist
!infrastructure/fee-seller
!infrastructure/zk
!sdk/zksync-rs
187 changes: 187 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions changelog/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to the core components will be documented in this file.
- (`eth_client`): `web3` field was made private in `ETHDirectClient`. `testkit` and `loadtest` don't use it directly
now.
- (`api_server`): Make `submit_txs_batch` send only one signature request.
- Fast withdrawals now can trigger aggregated block execution.

### Added

Expand All @@ -26,9 +27,11 @@ All notable changes to the core components will be documented in this file.
- (`eth_client`): Added `get_tx`, `create_contract` methods to `EthereumGateway`, `get_web3_transport` method to
ETHDirectClient.
- (`api_server`): Support for accounts that don't have to pay fees (e.g. network service accounts) was added.
- Added `BlockMetadata` structure and corresponding table to track block data that is not related to protocol.

### Fixed

- (`zksync_api`): Internal error with tokens not listed on CoinGecko.
- Fix wrong block info cache behavior in the `api_server`.

## Release 2021-02-19
Expand Down
5 changes: 5 additions & 0 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export default {
optimizer: {
enabled: true,
runs: 200
},
outputSelection: {
'*': {
'*': ['storageLayout']
}
}
}
},
Expand Down
53 changes: 21 additions & 32 deletions contracts/scripts/read-variable.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Command } from 'commander';
import { web3Provider } from './utils';
import { BigNumber } from 'ethers';
import * as fs from 'fs';
import { ethers } from 'ethers';
import * as solc from 'solc';
import * as hre from 'hardhat';

const provider = web3Provider();

Expand Down Expand Up @@ -312,36 +311,26 @@ function getVariableName(fullName: string): string {
return variableName;
}

function compileAndGetStorage(file: string, contractName): any {
const contractCode = fs.readFileSync(file, {
encoding: 'utf-8'
async function getValue(address: string, contractName: string, name: string): Promise<any> {
// Mapping from Contract name to fully qualified name known to hardhat
// e.g ZkSync => cache/solpp-generated-contracts/ZkSync.sol
const contractMap = {};
const allContracts = await hre.artifacts.getAllFullyQualifiedNames();
allContracts.forEach((fullName) => {
const [file, contract] = fullName.split(':');
contractMap[contract] = {
fullName,
file
};
});
const sourceFiles = {};
sourceFiles[`${contractName}.sol`] = { content: contractCode };
const input = {
language: 'Solidity',
sources: sourceFiles,
settings: {
outputSelection: {
'*': {
'*': ['storageLayout']
}
}
}
};
const output = JSON.parse(solc.compile(JSON.stringify(input)));
if (output.contracts === undefined) {
throw new Error(JSON.stringify(output.errors));
}
types = output.contracts[`${contractName}.sol`][contractName].storageLayout.types;
return output.contracts[`${contractName}.sol`][contractName].storageLayout.storage;
}

async function getValue(address: string, contractName: string, name: string, file?: string): Promise<any> {
if (file === undefined) {
file = `${process.env.ZKSYNC_HOME}/contracts/contracts/${contractName}.sol`;
if (!(contractName in contractMap)) {
throw new Error(`Unknown contract name, available contracts: ${Object.keys(contractMap)}`);
}
const storage = compileAndGetStorage(file, contractName);
const buildInfo = await hre.artifacts.getBuildInfo(contractMap[contractName].fullName);
// @ts-ignore
const layout = buildInfo.output.contracts[contractMap[contractName].file][contractName].storageLayout;
types = layout.types;
const storage = layout.storage;

const variableName = getVariableName(name);
const params = parseName(name);
Expand All @@ -365,8 +354,8 @@ async function main() {
.command('read <address> <contractName> <variableName>')
.option('-f, --file <file>')
.description('Reads value of variable')
.action(async (address: string, contractName: string, variableName: string, cmd: Command) => {
console.log(JSON.stringify(await getValue(address, contractName, variableName, cmd.file), null, 4));
.action(async (address: string, contractName: string, variableName: string) => {
console.log(JSON.stringify(await getValue(address, contractName, variableName), null, 4));
});

await program.parseAsync(process.argv);
Expand Down
2 changes: 1 addition & 1 deletion core/bin/data_restore/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl ContractsConfig {
#[tokio::main]
async fn main() {
vlog::info!("Restoring zkSync state from the contract");
vlog::init();
let _sentry_guard = vlog::init();
let connection_pool = ConnectionPool::new(Some(1));
let config_opts = ETHClientConfig::from_env();

Expand Down
Loading

0 comments on commit 9f1f10a

Please sign in to comment.