GitHub Action
Anvil-ZKsync Action
This repository has been renamed from era-test-node-action
to anvil-zksync-action
. All references to the previous name have been updated to reflect this change.
This GitHub Action runs the anvil-zksync
with various options. It offers high configurability, making it easy to integrate anvil-zksync
into your CI/CD workflows on GitHub Actions.
anvil-zksync repo: matter-labs/anvil-zksync.
- Multiple Modes: Supports
run
andfork
modes for flexible testing scenarios. - Network Forking: Allows you to fork from any network (e.g.,
mainnet
,sepolia-testnet
) at a specific block height or transaction hash. - Detailed Logging: Configurable options to display calls, storage logs, VM details, and gas details.
- Hash Resolution: Enables ABI and topic name resolution for better readability.
- Customizable Gas Configuration: Set custom gas prices and scale factors for more accurate simulations.
- System Configuration: Override bytecodes and specify system contracts for advanced setups.
- Caching Mechanism: Supports in-memory or disk caching with options to reset or specify cache directories.
- Account Management: Configure the number of dev accounts, their balances, and derivation paths.
Run anvil-zksync
with default settings.
name: Run anvil-zksync
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run anvil-zksync
uses: dutterbutter/anvil-zksync-action@v1.1.0
Run anvil-zksync
in fork mode, forking from mainnet at a specific block height.
name: Run anvil-zksync
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run anvil-zksync with fork
uses: dutterbutter/anvil-zksync-action@v1.1.0
with:
mode: 'fork'
forkUrl: 'https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID'
forkBlockNumber: '12345678'
port: '8545'
chainId: '1'
debugMode: 'true'
showCalls: 'all'
showStorageLogs: 'write'
showVmDetails: 'all'
showGasDetails: 'all'
resolveHashes: 'true'
log: 'debug'
logFilePath: 'logs/anvil_zksync.log'
target: 'x86_64-unknown-linux-gnu'
releaseTag: 'latest'
Run anvil-zksync
and upload the log file as a GitHub Action artifact.
name: Run anvil-zksync
on:
pull_request:
branches: [main]
workflow_dispatch:
jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Run anvil-zksync
uses: dutterbutter/anvil-zksync-action@v1.1.0
with:
mode: 'fork'
forkUrl: 'https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID'
showCalls: 'user'
showStorageLogs: 'read'
showVmDetails: 'all'
showGasDetails: 'all'
resolveHashes: 'true'
log: 'info'
logFilePath: 'anvil_zksync.log'
target: 'x86_64-unknown-linux-gnu'
releaseTag: 'latest'
- name: Install Dependencies
run: yarn install
- name: Run Tests
run: |
yarn test:contracts
- name: Upload Anvil ZKSYNC Log
uses: actions/upload-artifact@v3
with:
name: anvil_zksync-log
path: anvil_zksync.log
Run anvil-zksync
with custom account configurations.
name: Run Anvil ZKSYNC Action
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run Anvil ZKSync with EVM Emulation
uses: dutterbutter/anvil-zksync-action@v1.1.0
with:
mode: 'run'
accounts: '20'
balance: '5000'
mnemonic: 'test test test test test test test test test test test junk'
derivationPath: "m/44'/60'/0'/0/"
autoImpersonate: 'true'
blockTime: '15'
log: 'debug'
logFilePath: 'anvil_zksync.log'
target: 'x86_64-unknown-linux-gnu'
releaseTag: 'latest'
Ensure that sensitive inputs like mnemonic
are stored securely using GitHub Secrets and not exposed in logs. For example, use the secrets
context to pass sensitive data:
- name: Run anvil-zksync
uses: dutterbutter/anvil-zksync-action@v1.1.0
with:
mnemonic: ${{ secrets.MNEMONIC }}
# ... other inputs
Description:
Release tag of anvil-zksync
to use.
- Required: No
- Default:
latest
- Example:
v1.0.0
Description:
Target architecture for the anvil-zksync
binary.
- Required: No
- Default:
x86_64-unknown-linux-gnu
- Options:
x86_64-unknown-linux-gnu
x86_64-apple-darwin
aarch64-apple-darwin
Description:
Mode to run anvil-zksync
in.
- Required: No
- Default:
run
- Options:
run
fork
Description:
The network URL to fork from (e.g., https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID
). Must be used alongside mode
set to fork
.
- Required: No
Description:
Fetch state from a specific block number over a remote endpoint. Must be used alongside mode
set to fork
.
- Required: No
- Example:
12345678
Description:
Fetch state from a specific transaction hash over a remote endpoint. Must be used alongside mode
set to fork
.
- Required: No
- Example:
0xabcdef123456...
Description:
Port to listen on.
- Required: No
- Default:
8011
- Example:
8545
Description:
The host IP address to listen on.
- Required: No
- Default:
127.0.0.1
- Example:
0.0.0.0
Description:
Specify the chain ID.
- Required: No
- Default:
260
- Example:
1
Description:
Enable debug mode for more verbose logging.
- Required: No
- Default:
false
- Options:
true
,false
Description:
Show call debug information.
- Required: No
- Default:
none
- Options:
none
user
system
all
Description:
Show call output information.
- Required: No
- Default:
false
- Options:
true
,false
Description:
Show storage log information.
- Required: No
- Default:
none
- Options:
none
read
write
paid
all
Description:
Show VM details information.
- Required: No
- Default:
none
- Options:
none
all
Description:
Show gas details information.
- Required: No
- Default:
none
- Options:
none
all
Description:
Enable ABI and topic name resolution for better readability.
- Required: No
- Default:
false
- Options:
true
,false
Description:
Log filter level.
- Required: No
- Default:
info
- Options:
debug
info
warn
error
Description:
Path to the log file.
- Required: No
- Default:
anvil_zksync.log
- Example:
logs/anvil_zksync.log
Description:
Run in offline mode.
- Required: No
- Default:
false
- Options:
true
,false
Description:
Enable health check endpoint.
- Required: No
- Default:
false
- Options:
true
,false
Description:
Output config file path.
- Required: No
- Default: Not set
- Example:
config.json
Description:
Custom L1 gas price (in wei).
- Required: No
- Default: Not set
- Example:
20000000000
Description:
Custom L2 gas price (in wei).
- Required: No
- Default: Not set
- Example:
1000000000
Description:
Custom L1 pubdata price (in wei).
- Required: No
- Default: Not set
- Example:
1000000000
Description:
Gas price estimation scale factor.
- Required: No
- Default: Not set
- Example:
1.2
Description:
Gas limit estimation scale factor.
- Required: No
- Default: Not set
- Example:
1.1
Description:
Directory to override bytecodes.
- Required: No
- Default: Not set
- Example:
bytecodes/
Description:
Option for system contracts.
- Required: No
- Default: Not set
- Options:
built-in
local
built-in-without-security
Description:
Enable EVM emulation.
- Required: No
- Default:
false
- Options:
true
,false
Description:
Cache type.
- Required: No
- Default:
disk
- Options:
none
memory
disk
Description:
Reset the local disk cache.
- Required: No
- Default:
false
- Options:
true
,false
Description:
Cache directory location for disk cache.
- Required: No
- Default:
.cache
- Example:
/tmp/cache
Description:
Number of dev accounts to generate and configure.
- Required: No
- Default:
10
- Example:
20
Description:
The balance of every dev account in Ether.
- Required: No
- Default:
10000
- Example:
5000
Description:
BIP39 mnemonic phrase for generating accounts.
- Required: No
- Default: Not set
- Example:
test test test test test test test test test test test junk
Description:
Automatically generate a BIP39 mnemonic phrase.
- Required: No
- Default:
12
(number of words) - Example:
24
Description:
Generate a BIP39 mnemonic from a given seed (unsafe for production).
- Required: No
- Default: Not set
- Example:
0x123456789abcdef...
Description:
Derivation path of the child key to be derived.
- Required: No
- Default:
m/44'/60'/0'/0/
- Example:
m/44'/60'/0'/0/1
Description:
Enable automatic impersonation on startup.
- Required: No
- Default:
false
- Options:
true
,false
Description:
Block time in seconds for interval sealing.
- Required: No
- Default: Not set
- Example:
15
If you encounter issues not covered in the troubleshooting section, feel free to open an issue in the repository.
Feel free to open issues or PRs if you find any problems or have suggestions for improvements. Your contributions are more than welcome!
This project is licensed under the MIT License - see the LICENSE file for details.
Happy Testing! 🚀