Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
invocamanman committed Dec 9, 2021
1 parent f7cbfed commit 97e0c1a
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 67 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ coverage
artifacts/
docs/interfaces
docs/mocks
.vscode/launch.json
.vscode/launch.json
deploy_output.json
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"editor.formatOnSave": true,
"editor.formatOnSave": false,
"solidity.linter": "solhint",
"solidity.compileUsingRemoteVersion": "v0.8.9"
}
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,11 @@ Smart contract implementation which will be used by the zkEVM

- `contracts`: zkEVM contracts
- `docs`: specs and useful links
- `js`: complementary code in javascript
- `test`: test all repository code

## Install

```
git config --local core.hooksPath .githooks/
```

## Activate github hook
- `src`: js code to interact with the zkEVM, executor, zkEVMDB, sequencer and aggregator.
- `test`: test of all repository

```
npm run i
npm i
```

## Run tests
Expand All @@ -43,7 +35,7 @@ npm run lint
Autofix errors:

```
npm run lintFix
npm run lint:fix
```

## Deploy on hardhat
Expand All @@ -55,7 +47,7 @@ npm run deploy:PoE:hardhat
## Build dockers

```
npm run dockerContracts
npm run docker:contracts
```

A new docker `hermez-geth1.3:latest` will be created
Expand Down
28 changes: 28 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Docker deployment

By default the following mnemonic will be used to deploy the smart contracts `MNEMONIC="test test test test test test test test test test test junk"`.
Also the first 20 accounts of this mnemonic will be funded with ether.
The first account of the mnemonic will be the deployer of the smart contracts and therefore the holder of all the MATIC test tokens, which are necessary to pay the `sendBatch` transactions.
You can change the deployment `mnemonic` creating a `.env` file in the project root with the following variable:
`MNEMONIC=<YOUR_MENMONIC>`

## Requirements

- node version: 14.x
- npm version: 7.x
- docker
- docker-compose

## Build dockers

In project root execute:

```
npm i
npm run dockerContracts
```

A new docker `hermez-geth1.3:latest` will be created
This docker will contain a geth node with the deployed contracts
The deployment output can be found in: `docker/deploymentOutput/deploy_output.json`
To run the docker you can use: `docker run -p 8545:8545 hermez-geth1.3:latest`
7 changes: 0 additions & 7 deletions docker/deploymentOutput/deploy_output.json

This file was deleted.

4 changes: 2 additions & 2 deletions docker/docker-compose.geth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ services:
- ./gethData/geth_data:/geth_data
entrypoint:
- geth
- --rpc
- --rpcaddr
- --http
- --http.addr
- "0.0.0.0"
- --dev
- --dev.period
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
sudo rm -rf docker/gethData/geth_data
DEV_PERIOD=0 docker-compose -f docker/docker-compose.geth.yml up -d geth
sleep 5
node docker/scripts/fundAccounts.js
node docker/scripts/fund-accounts.js
npx hardhat run deployment/testnet/deployPoETestnet.js --network localhost
cp deployment/testnet/deploy_output.json docker/deploymentOutput
mkdir docker/deploymentOutput
mv deployment/testnet/deploy_output.json docker/deploymentOutput
docker-compose -f docker/docker-compose.geth.yml down
sudo docker build -t hermez-geth1.3 -f docker/Dockerfile.geth .
35 changes: 35 additions & 0 deletions docker/scripts/fund-accounts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* eslint-disable no-await-in-loop */

const ethers = require('ethers');
require('dotenv').config();

const DEFAULT_MNEMONIC = 'test test test test test test test test test test test junk';
const DEFAULT_NUM_ACCOUNTS = 20;

async function main() {
const MNEMONIC = process.env.MNEMONIC || DEFAULT_MNEMONIC;
const currentProvider = new ethers.providers.JsonRpcProvider('http://localhost:8545');
const signerNode = await currentProvider.getSigner();
const numAccountsToFund = process.env.NUM_ACCOUNTS || DEFAULT_NUM_ACCOUNTS;

for (let i = 0; i < numAccountsToFund; i++) {
const pathWallet = `m/44'/60'/0'/0/${i}`;
const accountWallet = ethers.Wallet.fromMnemonic(MNEMONIC, pathWallet);
const params = [{
from: await signerNode.getAddress(),
to: accountWallet.address,
value: '0x3635C9ADC5DEA00000',
}];
const tx = await currentProvider.send('eth_sendTransaction', params);
if (i === numAccountsToFund - 1) {
await currentProvider.waitForTransaction(tx);
}
}
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
36 changes: 0 additions & 36 deletions docker/scripts/fundAccounts.js

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"test": "npx hardhat test",
"docgen": "npx solidity-docgen --solc-module solc-0.8 -t ./docs/templates",
"deploy:PoE:hardhat": "npx hardhat run deployment/testnet/deployPoETestnet.js --network hardhat",
"lint": "npx eslint ./test && npx eslint ./src && npx eslint ./js",
"lintFix": "npx eslint ./test --fix && npx eslint ./src --fix && npx eslint ./js --fix",
"lint": "npx eslint ./test && npx eslint ./src && npx eslint ./js && npx eslint ./docker/scripts",
"lint:fix": "npx eslint ./test --fix && npx eslint ./src --fix && npx eslint ./js --fix && npx eslint ./docker/scripts --fix",
"compile": "npx hardhat compile",
"checkDeploy:PoE" :"npx hardhat node > /dev/null 2>&1 & npx hardhat run --network localhost deployment/testnet/deployPoETestnet.js && npx hardhat run --network localhost deployment/testnet/checkDeployment.js && pkill -f 'hardhat'",
"dockerContracts": "./docker/scripts/deployDocker.sh"
"check:deploy:PoE" :"npx hardhat node > /dev/null 2>&1 & npx hardhat run --network localhost deployment/testnet/deployPoETestnet.js && npx hardhat run --network localhost deployment/testnet/checkDeployment.js && pkill -f 'hardhat'",
"docker:contracts": "./docker/scripts/deploy-docker.sh"
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion test/contracts/proofOfEfficiency.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { expect } = require('chai');
const { ethers } = require('hardhat');

const { calculateCircuitInput } = require('./helpers/contractsHelpers');
const { calculateCircuitInput } = require('./helpers/contracts-helpers');

describe('Proof of efficiency', () => {
let deployer;
Expand Down

0 comments on commit 97e0c1a

Please sign in to comment.