Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with Hardhat node #6

Open
fomolabsdev opened this issue Apr 4, 2023 · 0 comments
Open

Usage with Hardhat node #6

fomolabsdev opened this issue Apr 4, 2023 · 0 comments

Comments

@fomolabsdev
Copy link

To debug complex contracts, I need to use some kind of logging in Solidity, like that of Hardhat.

I have tried using a modified version of the docker-compose.yaml configuration file:

version: '3.2'
services:
  postgres:
    network_mode: host
    image: "postgres:12"
    logging:
      driver: none
    ports:
      - "5432:5432"
    volumes:
      - type: bind
        source: ./volumes/postgres
        target: /var/lib/postgresql/data
    environment:
      - POSTGRES_HOST_AUTH_METHOD=trust
  zksync:
    network_mode: host
    stdin_open: true
    tty: true
    image: matterlabs/local-node:latest2.0
    depends_on:
      - postgres
    ports:
      - "3050:3050" # JSON RPC HTTP port
      - "3051:3051" # JSON RPC WS port
    volumes:
      - ./volumes/zksync/env/dev:/etc/env/dev
      - ./volumes/zksync/data:/var/lib/zksync/data
      - ./src:/contracts
    environment:
      - MNEMONIC=test test test test test test test test test test test junk
      - DATABASE_URL=postgres://postgres@localhost/zksync_local
      - ETH_CLIENT_WEB3_URL=http://localhost:8545

I also had to modify the deployZkSyncContract function to avoid a conflict with nonces:

    public async deployZkSyncContract(create2Salt: string, gasPrice?: BigNumberish, nonce?) {
        nonce = nonce ? parseInt(nonce) : await this.deployWallet.getTransactionCount();

        console.log('FOMOLABS')

        // deploy zkSync contract
        const independentZkSyncDeployPromises = [
            () => this.deployMailboxFacet(create2Salt, { gasPrice, nonce }),
            () => this.deployExecutorFacet(create2Salt, { gasPrice, nonce: nonce + 1 }),
            () => this.deployDiamondCutFacet(create2Salt, { gasPrice, nonce: nonce + 2 }),
            () => this.deployGovernanceFacet(create2Salt, { gasPrice, nonce: nonce + 3 }),
            () => this.deployGettersFacet(create2Salt, { gasPrice, nonce: nonce + 4 }),
            () => this.deployVerifier(create2Salt, { gasPrice, nonce: nonce + 5 }),
            () => this.deployDiamondInit(create2Salt, { gasPrice, nonce: nonce + 6 })
        ];

        //await Promise.all(independentZkSyncDeployPromises);
        for (const promise of independentZkSyncDeployPromises) {
            await promise()
        }
        
        nonce += 7;

        await this.deployDiamondProxy(create2Salt, { gasPrice, nonce });
    }

Everything seems to work correctly except for the DiamondInit deploy:

local-setup-zksync-1    | DiamondProxy deployed, gasUsed: 242262
local-setup-zksync-1    | Error: Error: Failed to deploy bytecode via create2 factory
local-setup-zksync-1    |     at Deployer.<anonymous> (/contracts/ethereum/src.ts/deploy.ts:205:19)
local-setup-zksync-1    |     at step (/contracts/ethereum/src.ts/deploy.ts:33:23)
local-setup-zksync-1    |     at Object.next (/contracts/ethereum/src.ts/deploy.ts:14:53)
local-setup-zksync-1    |     at fulfilled (/contracts/ethereum/src.ts/deploy.ts:5:58)
local-setup-zksync-1    |     at processTicksAndRejections (internal/process/task_queues.js:95:5)

Is there any way to fix this, or to use Hardhat's console.log tools? In the default log of docker compose up, it is impossible to see anything due to message flooding.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant