Skip to content

Commit

Permalink
chore: Some additional fixes from review to kl-factory (#1745)
Browse files Browse the repository at this point in the history
## What ❔

<!-- What are the changes this PR brings about? -->
<!-- Example: This PR adds a PR template to the repo. -->
<!-- (For bigger PRs adding more context is appreciated) -->

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `zk spellcheck`.
- [ ] Linkcheck has been run via `zk linkcheck`.
  • Loading branch information
StanislavBreadless committed Apr 21, 2024
1 parent f09f4b7 commit 919fc1e
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 150 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
run: |
ci_run zk
- name: Run zk linkcheck - DISABLED (flaky)
- name: Run zk linkcheck
run: |
ls
# ci_run zk linkcheck
ci_run zk linkcheck
3 changes: 1 addition & 2 deletions core/lib/basic_types/src/protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ impl ProtocolVersionId {
}

pub fn is_pre_shared_bridge(&self) -> bool {
// TODO: review this when we actually deploy shared bridge
false
self <= &Self::Version22
}

pub fn is_1_4_0(&self) -> bool {
Expand Down
1 change: 0 additions & 1 deletion core/lib/basic_types/src/vm_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub enum VmVersion {
impl VmVersion {
/// Returns the latest supported VM version.
pub const fn latest() -> VmVersion {
// kl to do delete local vm version
Self::Vm1_5_0
}
}
8 changes: 4 additions & 4 deletions core/tests/loadnext/src/sdk/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl<S: EthereumSigner> EthereumProvider<S> {
l1_token_address: Address,
bridge: Option<Address>,
) -> Result<Address, ClientError> {
// kl to do. This should be moved to the shared bridge, which does not have `l2_token_address` on L1. Use L2 contracts instead.
// TODO(EVM-571): This should be moved to the shared bridge, which does not have `l2_token_address` on L1. Use L2 contracts instead.
let bridge = bridge.unwrap_or(self.default_bridges.l1_erc20_default_bridge.unwrap());
let args = CallFunctionArgs::new("l2TokenAddress", l1_token_address)
.for_contract(bridge, self.l1_bridge_abi.clone());
Expand All @@ -198,7 +198,7 @@ impl<S: EthereumSigner> EthereumProvider<S> {
erc20_approve_threshold: U256,
bridge: Option<Address>,
) -> Result<bool, ClientError> {
// kl to do. This should be moved to the shared bridge,
// TODO(EVM-571): This should be moved to the shared bridge,
let bridge = bridge.unwrap_or(self.default_bridges.l1_erc20_default_bridge.unwrap());
let current_allowance = self
.client()
Expand Down Expand Up @@ -226,7 +226,7 @@ impl<S: EthereumSigner> EthereumProvider<S> {
max_erc20_approve_amount: U256,
bridge: Option<Address>,
) -> Result<H256, ClientError> {
// kl to do. This should be moved to the shared bridge,
// TODO(EVM-571): This should be moved to the shared bridge,
let bridge = bridge.unwrap_or(self.default_bridges.l1_erc20_default_bridge.unwrap());
let contract_function = self
.erc20_abi
Expand Down Expand Up @@ -526,7 +526,7 @@ impl<S: EthereumSigner> EthereumProvider<S> {
)
.await?
} else {
// kl to do. This should be moved to the shared bridge, and the `requestL2Transaction` method
// TODO(EVM-571): This should be moved to the shared bridge, and the `requestL2Transaction` method
let bridge_address =
bridge_address.unwrap_or(self.default_bridges.l1_erc20_default_bridge.unwrap());
let contract_function = self
Expand Down
1 change: 0 additions & 1 deletion core/tests/ts-integration/src/context-owner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ export class TestContextOwner {
this.reporter.message(`Operator address is ${this.mainEthersWallet.address}`);

const requiredL2ETHAmount = this.requiredL2ETHPerAccount().mul(accountsAmount);
// kl todo, for non eth based chains, we need to check different
const actualL2ETHAmount = await this.mainSyncWallet.getBalance();
this.reporter.message(`Operator balance on L2 is ${ethers.utils.formatEther(actualL2ETHAmount)} ETH`);

Expand Down
4 changes: 2 additions & 2 deletions docs/guides/advanced/how_l2_messaging_works.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ transmitted to L1 for final verification.
[zkevm_assembly_parse]:
https://github.com/matter-labs/era-zkEVM-assembly/blob/v1.3.2/src/assembly/instruction/log.rs#L32
[executor_sol]:
https://github.com/matter-labs/era-contracts/blob/c9a0b23c8bd06cc78c094814b3b4365cedae9ba7/ethereum/contracts/state-transition/chain-deps/facets/Executor.sol#L26
https://github.com/matter-labs/era-contracts/blob/b04dcaf2256a9b2626eeaefbf1b281f0119d30ab/l1-contracts/contracts/state-transition/chain-deps/facets/Executor.sol#L21
[mainet_executor]: https://etherscan.io/address/0x389a081BCf20e5803288183b929F08458F1d863D
[sepolia_tx]: https://sepolia.etherscan.io/tx/0x18c2a113d18c53237a4056403047ff9fafbf772cb83ccd44bb5b607f8108a64c
[mailbox_log_inclusion]:
https://github.com/matter-labs/era-contracts/blob/c9a0b23c8bd06cc78c094814b3b4365cedae9ba7/ethereum/contracts/state-transition/chain-deps/facets/Mailbox.sol#L54
https://github.com/matter-labs/era-contracts/blob/b04dcaf2256a9b2626eeaefbf1b281f0119d30ab/l1-contracts/contracts/state-transition/chain-deps/facets/Mailbox.sol#L70
134 changes: 1 addition & 133 deletions infrastructure/zk/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ export async function deployERC20AndWeth({
{ "name": "DAI", "symbol": "DAI", "decimals": 18 },
{ "name": "wBTC", "symbol": "wBTC", "decimals": 8, "implementation": "RevertTransferERC20" },
{ "name": "BAT", "symbol": "BAT", "decimals": 18 },
{ "name": "GNT", "symbol": "GNT", "decimals": 18 },
{ "name": "MLTT", "symbol": "MLTT", "decimals": 18 },
{ "name": "DAIK", "symbol": "DAIK", "decimals": 18 },
{ "name": "wBTCK", "symbol": "wBTCK", "decimals": 8, "implementation": "RevertTransferERC20" },
{ "name": "BATK", "symbol": "BATS", "decimals": 18 },
{ "name": "GNTK", "symbol": "GNTS", "decimals": 18 },
{ "name": "MLTTK", "symbol": "MLTTS", "decimals": 18 },
{ "name": "DAIL", "symbol": "DAIL", "decimals": 18 },
{ "name": "wBTCL", "symbol": "wBTCP", "decimals": 8, "implementation": "RevertTransferERC20" },
{ "name": "BATL", "symbol": "BATW", "decimals": 18 },
{ "name": "GNTL", "symbol": "GNTW", "decimals": 18 },
{ "name": "MLTTL", "symbol": "MLTTW", "decimals": 18 },
{ "name": "Wrapped Ether", "symbol": "WETH", "decimals": 18, "implementation": "WETH9"}
]' ${args.join(' ')} > ./etc/tokens/${destinationFile}.json`);
const WETH = getTokens(destinationFile).find((token) => token.symbol === 'WETH')!;
Expand Down Expand Up @@ -105,21 +93,13 @@ export async function tokenInfo(address: string) {

// installs all dependencies
export async function yarn() {
await utils.spawn('yarn');
}

export async function deployTestkit(genesisRoot: string) {
await utils.spawn(`yarn l1-contracts deploy-testkit --genesis-root ${genesisRoot}`);
await utils.spawn('yarn install --frozen-lockfile');
}

export async function revertReason(txHash: string, web3url?: string) {
await utils.spawn(`yarn l1-contracts ts-node scripts/revert-reason.ts ${txHash} ${web3url || ''}`);
}

export async function exitProof(...args: string[]) {
await utils.spawn(`cargo run --example generate_exit_proof --release -- ${args.join(' ')}`);
}

export async function catLogs(exitCode?: number) {
utils.allowFailSync(() => {
console.log('\nSERVER LOGS:\n', fs.readFileSync('server.log').toString());
Expand Down Expand Up @@ -202,14 +182,6 @@ command
await tokenInfo(address);
});

command
.command('deploy-testkit')
.description('deploy testkit contracts')
.requiredOption('--genesis-root <hash>')
.action(async (cmd: Command) => {
await deployTestkit(cmd.genesisRoot);
});

command
.command('revert-reason <tx_hash> [web3_url]')
.description('get the revert reason for ethereum transaction')
Expand Down Expand Up @@ -243,107 +215,3 @@ command
});

command.command('snapshots-creator').action(snapshots_creator);

command
.command('cross-en-checker')
.description('run the cross external nodes checker. See Checker Readme the default run mode and configuration.')
.option(
'--mode <mode>',
'`Rpc` to run only the RPC checker; `PubSub` to run only the PubSub checker; `All` to run both.'
)
.option(
'--env <env>',
`Provide the env the checker will test in to use the default urls for that env. 'Local', 'Stage, 'Testnet', or 'Mainnet'`
)
.option('--main_node_http_url <url>', 'Manually provide the HTTP URL of the main node')
.option('--instances_http_urls <urls>', 'Manually provide the HTTP URLs of the instances to check')
.option('--main_node_ws_url <url>', 'Manually provide the WS URL of the main node')
.option('--instances_ws_urls <urls>', 'Manually provide the WS URLs of the instances to check')
.option(
'--rpc_mode <rpc_mode>',
'The mode to run the RPC checker in. `Triggered` to run once; `Continuous` to run forever.'
)
.option(
'--start_miniblock <start_miniblock>',
'Check all miniblocks starting from this. If not set, then check from genesis. Inclusive.'
)
.option(
'--finish_miniblock <finish_miniblock>',
'For Triggered mode. If not set, then check all available miniblocks. Inclusive.'
)
.option(
'--max_transactions_to_check <max_transactions_to_check>',
'The maximum number of transactions to be checked at random in each miniblock.'
)
.option(
'--instance_poll_period <instance_poll_period>',
'For RPC mode. In seconds, how often to poll the instance node for new miniblocks.'
)
.option(
'--subscription_duration <subscription_duration>',
'For PubSub mode. Time in seconds for a subscription to be active. If not set, then the subscription will run forever.'
)
.action(async (cmd: Command) => {
interface Environment {
httpMain: string;
httpInstances: string;
wsMain: string;
wsInstances: string;
}

const nodeUrls: Record<string, Environment> = {
Local: {
httpMain: 'http://127.0.0.1:3050',
httpInstances: 'http://127.0.0.1:3060',
wsMain: 'ws://127.0.0.1:3051',
wsInstances: 'ws://127.0.0.1:3061'
},
Stage: {
httpMain: 'https://z2-dev-api.zksync.dev:443',
httpInstances: 'https://external-node-dev.zksync.dev:443',
wsMain: 'wss://z2-dev-api.zksync.dev:443/ws',
wsInstances: 'wss://external-node-dev.zksync.dev:443/ws'
},
Testnet: {
httpMain: 'https://zksync2-testnet.zksync.dev:443',
httpInstances: 'https://external-node-testnet.zksync.dev:443',
wsMain: 'wss://zksync2-testnet.zksync.dev:443/ws',
wsInstances: 'wss://external-node-testnet.zksync.dev:443/ws'
},
Mainnet: {
httpMain: 'https://zksync2-mainnet.zksync.io:443',
httpInstances: 'https://external-node-mainnet.zksync.dev:443',
wsMain: 'wss://zksync2-mainnet.zksync.io:443/ws',
wsInstances: 'wss://external-node-mainnet.zksync.dev:443/ws'
}
};

if (cmd.env && nodeUrls[cmd.env]) {
process.env.CHECKER_MAIN_NODE_HTTP_URL = nodeUrls[cmd.env].httpMain;
process.env.CHECKER_INSTANCES_HTTP_URLS = nodeUrls[cmd.env].httpInstances;
process.env.CHECKER_MAIN_NODE_WS_URL = nodeUrls[cmd.env].wsMain;
process.env.CHECKER_INSTANCES_WS_URLS = nodeUrls[cmd.env].wsInstances;
}

const envVarMap = {
mode: 'CHECKER_MODE',
rpc_mode: 'CHECKER_RPC_MODE',
main_node_http_url: 'CHECKER_MAIN_NODE_HTTP_URL',
instances_http_urls: 'CHECKER_INSTANCES_HTTP_URLS',
main_node_ws_url: 'CHECKER_MAIN_NODE_WS_URL',
instances_ws_urls: 'CHECKER_INSTANCES_WS_URLS',
start_miniblock: 'CHECKER_START_MINIBLOCK',
finish_miniblock: 'CHECKER_FINISH_MINIBLOCK',
max_transactions_to_check: 'CHECKER_MAX_TRANSACTIONS_TO_CHECK',
instance_poll_period: 'CHECKER_INSTANCE_POLL_PERIOD',
subscription_duration: 'CHECKER_SUBSCRIPTION_DURATION'
};

for (const [cmdOption, envVar] of Object.entries(envVarMap)) {
if (cmd[cmdOption]) {
process.env[envVar] = cmd[cmdOption];
}
}

await cross_en_checker();
});
4 changes: 2 additions & 2 deletions infrastructure/zk/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export async function server(rebuildTree: boolean, uring: boolean, components?:
if (components) {
options += ` --components=${components}`;
}
// await utils.spawn(`RUST_LOG=trace cargo run --bin zksync_server --release ${options}`);
await utils.spawn(`cargo run --bin zksync_server --release ${options}`);
}

Expand Down Expand Up @@ -64,7 +63,8 @@ async function create_genesis(cmd: string) {
}

export async function genesisFromSources() {
// we fix chainId as we need all chains to have the same chainId at genesis
// Note that that all the chains have the same chainId at genesis. It will be changed
// via an upgrade transaction during the registration of the chain.
await create_genesis('cargo run --bin zksync_server --release -- --genesis');
}

Expand Down
5 changes: 5 additions & 0 deletions infrastructure/zk/src/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import * as db from '../database';

export { integration };

export async function l1Contracts() {
await utils.spawn('yarn l1-contracts test');
}

export async function prover() {
process.chdir(process.env.ZKSYNC_HOME! + '/prover');
await utils.spawn('cargo test --release --workspace --locked');
Expand Down Expand Up @@ -35,6 +39,7 @@ export async function rust(options: string[]) {
export const command = new Command('test').description('run test suites').addCommand(integration.command);

command.command('prover').description('run unit-tests for the prover').action(prover);
command.command('l1-contracts').description('run unit-tests for the layer 1 smart contracts').action(l1Contracts);
command
.command('rust [command...]')
.allowUnknownOption()
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/zk/src/up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export function createVolumes() {
}

export async function up(runObservability: boolean, composeFile?: string) {
createVolumes();
if (composeFile) {
await utils.spawn(`docker compose -f ${composeFile} up -d`);
} else {
Expand All @@ -23,6 +22,7 @@ export async function up(runObservability: boolean, composeFile?: string) {
export const command = new Command('up')
.description('start development containers')
.option('--docker-file <dockerFile>', 'path to a custom docker file')
.option('--run-observability', 'whether to run observability stack')
.action(async (cmd) => {
await up(cmd.dockerFile);
await up(cmd.runObservability, cmd.dockerFile);
});

0 comments on commit 919fc1e

Please sign in to comment.