Commit 3d908f6d authored by 贾浩@五瓣科技's avatar 贾浩@五瓣科技

init

parents
Pipeline #732 failed with stages
MNEMONIC="test test test test test test test test test test test junk"
INFURA_PROJECT_ID=""
ETHERSCAN_API_KEY=""
GASTOKEN_ADDR=""
zkproverjs/
\ No newline at end of file
module.exports = {
plugins: [
'mocha',
],
env: {
node: true,
mocha: true,
},
extends: 'airbnb-base',
rules: {
indent: ['error', 4],
'mocha/no-exclusive-tests': 'error',
'max-len': ['error', {
code: 140, comments: 200, ignoreStrings: true, ignoreTemplateLiterals: true,
}],
'no-unused-vars': [2, { varsIgnorePattern: 'export^' }],
'no-return-assign': [0],
'no-underscore-dangle': [0],
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'func-names': [0],
'class-methods-use-this': [0],
'no-bitwise': [0],
'no-param-reassign': 'off',
'no-console': [2, { allow: ['warn', 'error'] }],
'import/prefer-default-export': [0],
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
'multiline-comment-style': 'error',
'import/no-extraneous-dependencies': 'off'
},
};
#!/bin/bash
## To use this hook execute in the project root:
## git config --local core.hooksPath .githooks/
if npm run lint; then
npx hardhat compile --force
npm run docgen
git add docs
cp artifacts/contracts/PolygonZkEVMBridge.sol/PolygonZkEVMBridge.json compiled-contracts/
cp artifacts/contracts/PolygonZkEVMGlobalExitRoot.sol/PolygonZkEVMGlobalExitRoot.json compiled-contracts/
cp artifacts/contracts/PolygonZkEVMGlobalExitRootL2.sol/PolygonZkEVMGlobalExitRootL2.json compiled-contracts/
cp artifacts/contracts/lib/TokenWrapped.sol/TokenWrapped.json compiled-contracts/
cp artifacts/contracts/mocks/PolygonZkEVMBridgeMock.sol/PolygonZkEVMBridgeMock.json compiled-contracts/
cp artifacts/contracts/mocks/ERC20PermitMock.sol/ERC20PermitMock.json compiled-contracts/
cp artifacts/contracts/mocks/PolygonZkEVMGlobalExitRootL2Mock.sol/PolygonZkEVMGlobalExitRootL2Mock.json compiled-contracts/
cp artifacts/contracts/mocks/PolygonZkEVMGlobalExitRootMock.sol/PolygonZkEVMGlobalExitRootMock.json compiled-contracts/
cp artifacts/contracts/mocks/CDKValidiumMock.sol/CDKValidiumMock.json compiled-contracts/
cp artifacts/contracts/mocks/VerifierRollupHelperMock.sol/VerifierRollupHelperMock.json compiled-contracts/
cp artifacts/contracts/CDKValidium.sol/CDKValidium.json compiled-contracts/
cp artifacts/contracts/CDKDataCommittee.sol/CDKDataCommittee.json compiled-contracts/
cp artifacts/contracts/verifiers/FflonkVerifier.sol/FflonkVerifier.json compiled-contracts/
cp artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json compiled-contracts/
cp artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json compiled-contracts/
cp artifacts/contracts/deployment/CDKValidiumDeployer.sol/CDKValidiumDeployer.json compiled-contracts/
cp artifacts/contracts/CDKValidiumTimelock.sol/CDKValidiumTimelock.json compiled-contracts/
git add compiled-contracts
exit 0
else
exit 1
fi
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Main CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: setup
run: |
npm install -g npm@latest
npm i
- name: linter
run: npm run lint
- name: test
run: npm run test
coverage.json
.env
cache
build
yarn.lock
node_modules
coverage.json
coverage
.coverage_*
.openzeppelin
artifacts/
docs/interfaces
docs/mocks
.vscode/launch.json
deploy_output.json
deploy_parameters.json
deployments
upgrade_parameters.json
docker/gethData/
*.ignore/
\ No newline at end of file
{
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false,
"explicitTypes": "always"
}
}
]
}
\ No newline at end of file
module.exports = {
skipFiles: ['mocks', 'interfaces']
};
\ No newline at end of file
{
"extends": "solhint:recommended",
"rules": {
"mark-callable-contracts": "off",
"no-empty-blocks": "off",
"compiler-version": ["error", "0.8.20"],
"private-vars-leading-underscore": "error",
"bracket-align": "off",
"reason-string": "off",
"not-rely-on-time": "off",
"no-inline-assembly": "off",
"check-send-result": "off"
}
}
{
"editor.formatOnSave": false,
"solidity.linter": "solhint",
"solidity.compileUsingRemoteVersion": "v0.8.20+commit.e14f2714",
"solidity.remappings": ["@openzeppelin/=node_modules/@openzeppelin"],
}
This diff is collapsed.
# Polygon CDK Validium Contracts
### Core Contracts for the Polygon CDK Validium
The cdk-validium-contracts repository contains the smart contract implementations designed for use with CDK chains configured with Validium.
## Overview of Validium
For a full overview of the Polygon CDK Validium, please reference the [CDK documentation](https://wiki.polygon.technology/docs/cdk/).
The CDK Validium solution is made up of several components; start with the [CDK Validium Node](https://github.com/0xPolygon/cdk-validium-node). For quick reference, the complete list of components are outlined below:
| Component | Description |
| ----------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| [CDK Validium Node](https://github.com/0xPolygon/cdk-validium-node) | Node implementation for the CDK networks in Validium mode |
| [CDK Validium Contracts](https://github.com/0xPolygon/cdk-validium-contracts) | Smart contract implementation for the CDK networks in Validium mode |
| [CDK Data Availability](https://github.com/0xPolygon/cdk-data-availability) | Data availability implementation for the CDK networks |
| [Prover / Executor](https://github.com/0xPolygonHermez/zkevm-prover) | zkEVM engine and prover implementation |
| [Bridge Service](https://github.com/0xPolygonHermez/zkevm-bridge-service) | Bridge service implementation for CDK networks |
| [Bridge UI](https://github.com/0xPolygonHermez/zkevm-bridge-ui) | UI for the CDK networks bridge |
---
## Important Note
The private keys and mnemonics included in this repository are intended solely for internal testing. **Do not use them in production environments.**
## Prerequisites
- Node.js version: 16.x
- npm version: 7.x
## Repository Structure
- `contracts`: Core contracts
- `PolygonZkEVMBridge.sol`: Facilitates asset transfers between chains
- `PolygonZkEVMGlobalExitRoot.sol`: Manages the global exit root on L1
- `PolygonZkEVMGlobalExitRootL2.sol`: Manages the global exit root on L2
- `CDKValidium.sol`: Consensus algorithm for Validium CDK chains
- `docs`: Specifications and useful resources
- `test`: Contract test suites
## Activate Github Hook
To activate the GitHub hook, run the following command:
```bash
git config --local core.hooksPath .githooks/
```
## Install
```bash
npm i
```
## Run Tests
Execute the test suite with:
```bash
npm run test
```
## Linting
To check for linting errors, run:
```bash
npm run lint
```
To automatically fix linting errors, run:
```bash
npm run lint:fix
```
## Build Docker Image
To build the Docker image, run:
```bash
npm run docker:contracts
```
This will create a new Docker image named `hermeznetwork/geth-cdk-validium-contracts`, which includes a Geth node with the deployed contracts. The deployment output can be found at `docker/deploymentOutput/deploy_output.json`.
To run the Docker container, use:
```bash
docker run -p 8545:8545 hermeznetwork/geth-cdk-validium-contracts
```
## Note
For testing purposes, the following private keys are being used. These keys are not intended for production use:
- **Private key**: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
- **Address**: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
- **Private key**: 0xdfd01798f92667dbf91df722434e8fbe96af0211d4d1b82bbbbc8f1def7a814f
- **Address**: 0xc949254d682d8c9ad5682521675b8f43b102aec4
## License
The cdk-validium-contracts project is licensed under the [GNU Affero General Public License](LICENSE) free software license.
# Verify Deployed Smart Contracts
To verify that the smartcontracts of this repository are the same deployed on mainnet, you could follow the instructions described [document](verifyMainnetDeployment/verifyDeployment.md)
The smartcontract used to verify a proof, it's a generated contract from zkEVM Rom and Pil (constraints). To verify the deployment of this smartcontract you could follow the instructions described in this [document](verifyMainnetDeployment/verifyMainnetProofVerifier.md)
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"_format": "hh-sol-artifact-1",
"contractName": "PolygonZkEVMGlobalExitRoot",
"sourceName": "contracts/PolygonZkEVMGlobalExitRoot.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_rollupAddress",
"type": "address"
},
{
"internalType": "address",
"name": "_bridgeAddress",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "OnlyAllowedContracts",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "mainnetExitRoot",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "rollupExitRoot",
"type": "bytes32"
}
],
"name": "UpdateGlobalExitRoot",
"type": "event"
},
{
"inputs": [],
"name": "bridgeAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getLastGlobalExitRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "globalExitRootMap",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lastMainnetExitRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lastRollupExitRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "rollupAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "newRoot",
"type": "bytes32"
}
],
"name": "updateExitRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x60c060405234801561001057600080fd5b506040516103f83803806103f883398101604081905261002f91610062565b6001600160a01b0391821660a05216608052610095565b80516001600160a01b038116811461005d57600080fd5b919050565b6000806040838503121561007557600080fd5b61007e83610046565b915061008c60208401610046565b90509250929050565b60805160a0516103316100c76000396000818160e901526101bd015260008181610135015261017401526103316000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c806333d6247d1161005b57806333d6247d146100c75780633ed691ef146100dc5780635ec6a8df146100e4578063a3c573eb1461013057600080fd5b806301fd904414610082578063257b36321461009e578063319cf735146100be575b600080fd5b61008b60005481565b6040519081526020015b60405180910390f35b61008b6100ac3660046102e2565b60026020526000908152604090205481565b61008b60015481565b6100da6100d53660046102e2565b610157565b005b61008b6102a6565b61010b7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610095565b61010b7f000000000000000000000000000000000000000000000000000000000000000081565b60005460015473ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633036101a65750600182905581610222565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633036101f0576000839055829150610222565b6040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051602080820184905281830185905282518083038401815260609092019092528051910120600090600081815260026020526040812054919250036102a05760008181526002602052604080822042905551849184917f61014378f82a0d809aefaf87a8ac9505b89c321808287a6e7810f29304c1fce39190a35b50505050565b60006102dd600154600054604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b905090565b6000602082840312156102f457600080fd5b503591905056fea264697066735822122066368a84a416778eb0d212b7acdeed4f6b4a8b676fc470e5579fc4c25caed2f364736f6c63430008140033",
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061007d5760003560e01c806333d6247d1161005b57806333d6247d146100c75780633ed691ef146100dc5780635ec6a8df146100e4578063a3c573eb1461013057600080fd5b806301fd904414610082578063257b36321461009e578063319cf735146100be575b600080fd5b61008b60005481565b6040519081526020015b60405180910390f35b61008b6100ac3660046102e2565b60026020526000908152604090205481565b61008b60015481565b6100da6100d53660046102e2565b610157565b005b61008b6102a6565b61010b7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610095565b61010b7f000000000000000000000000000000000000000000000000000000000000000081565b60005460015473ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633036101a65750600182905581610222565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633036101f0576000839055829150610222565b6040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051602080820184905281830185905282518083038401815260609092019092528051910120600090600081815260026020526040812054919250036102a05760008181526002602052604080822042905551849184917f61014378f82a0d809aefaf87a8ac9505b89c321808287a6e7810f29304c1fce39190a35b50505050565b60006102dd600154600054604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b905090565b6000602082840312156102f457600080fd5b503591905056fea264697066735822122066368a84a416778eb0d212b7acdeed4f6b4a8b676fc470e5579fc4c25caed2f364736f6c63430008140033",
"linkReferences": {},
"deployedLinkReferences": {}
}
{
"_format": "hh-sol-artifact-1",
"contractName": "PolygonZkEVMGlobalExitRootL2",
"sourceName": "contracts/PolygonZkEVMGlobalExitRootL2.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_bridgeAddress",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "OnlyAllowedContracts",
"type": "error"
},
{
"inputs": [],
"name": "bridgeAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "globalExitRootMap",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lastRollupExitRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "newRoot",
"type": "bytes32"
}
],
"name": "updateExitRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x60a060405234801561001057600080fd5b5060405161024238038061024283398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b6080516101b16100916000396000818160a7015261010601526101b16000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220ea2171e2c85c8bff947affc409ef6fc6a8fe82fb8c174ddeda988651e595d66564736f6c63430008140033",
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220ea2171e2c85c8bff947affc409ef6fc6a8fe82fb8c174ddeda988651e595d66564736f6c63430008140033",
"linkReferences": {},
"deployedLinkReferences": {}
}
{
"_format": "hh-sol-artifact-1",
"contractName": "PolygonZkEVMGlobalExitRootL2Mock",
"sourceName": "contracts/mocks/PolygonZkEVMGlobalExitRootL2Mock.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_bridgeAddress",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "OnlyAllowedContracts",
"type": "error"
},
{
"inputs": [],
"name": "bridgeAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "globalExitRootMap",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lastRollupExitRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "newRoot",
"type": "bytes32"
}
],
"name": "setExitRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "globalExitRoot",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
}
],
"name": "setLastGlobalExitRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "newRoot",
"type": "bytes32"
}
],
"name": "updateExitRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x60a060405234801561001057600080fd5b506040516102b93803806102b983398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b60805161022761009260003960008181610100015261015f01526102276000f3fe608060405234801561001057600080fd5b50600436106100725760003560e01c806333d6247d1161005057806333d6247d146100c857806396e07459146100db578063a3c573eb146100fb57600080fd5b806301fd904414610077578063116c40c314610093578063257b3632146100a8575b600080fd5b61008060015481565b6040519081526020015b60405180910390f35b6100a66100a13660046101b6565b600155565b005b6100806100b63660046101b6565b60006020819052908152604090205481565b6100a66100d63660046101b6565b610147565b6100a66100e93660046101cf565b60009182526020829052604090912055565b6101227f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161008a565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146100a1576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000602082840312156101c857600080fd5b5035919050565b600080604083850312156101e257600080fd5b5050803592602090910135915056fea26469706673582212203dc131ea7b3c9a0e0d9f97c222b405f0086fc9beecf67bf79956cd48dcb6461d64736f6c63430008140033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100725760003560e01c806333d6247d1161005057806333d6247d146100c857806396e07459146100db578063a3c573eb146100fb57600080fd5b806301fd904414610077578063116c40c314610093578063257b3632146100a8575b600080fd5b61008060015481565b6040519081526020015b60405180910390f35b6100a66100a13660046101b6565b600155565b005b6100806100b63660046101b6565b60006020819052908152604090205481565b6100a66100d63660046101b6565b610147565b6100a66100e93660046101cf565b60009182526020829052604090912055565b6101227f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161008a565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146100a1576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000602082840312156101c857600080fd5b5035919050565b600080604083850312156101e257600080fd5b5050803592602090910135915056fea26469706673582212203dc131ea7b3c9a0e0d9f97c222b405f0086fc9beecf67bf79956cd48dcb6461d64736f6c63430008140033",
"linkReferences": {},
"deployedLinkReferences": {}
}
{
"_format": "hh-sol-artifact-1",
"contractName": "PolygonZkEVMGlobalExitRootMock",
"sourceName": "contracts/mocks/PolygonZkEVMGlobalExitRootMock.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_rollupAddress",
"type": "address"
},
{
"internalType": "address",
"name": "_bridgeAddress",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "OnlyAllowedContracts",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "mainnetExitRoot",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "rollupExitRoot",
"type": "bytes32"
}
],
"name": "UpdateGlobalExitRoot",
"type": "event"
},
{
"inputs": [],
"name": "bridgeAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getLastGlobalExitRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"name": "globalExitRootMap",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lastMainnetExitRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lastRollupExitRoot",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "rollupAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "globalExitRoot",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
}
],
"name": "setGlobalExitRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
}
],
"name": "setLastGlobalExitRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "newRoot",
"type": "bytes32"
}
],
"name": "updateExitRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x60c060405234801561001057600080fd5b5060405161049538038061049583398101604081905261002f91610062565b6001600160a01b0391821660a05216608052610095565b80516001600160a01b038116811461005d57600080fd5b919050565b6000806040838503121561007557600080fd5b61007e83610046565b915061008c60208401610046565b90509250929050565b60805160a0516103cd6100c860003960008181610142015261023701526000818161018e01526101ee01526103cd6000f3fe608060405234801561001057600080fd5b50600436106100a35760003560e01c806333d6247d116100765780635bcef6731161005b5780635bcef6731461011d5780635ec6a8df1461013d578063a3c573eb1461018957600080fd5b806333d6247d146101025780633ed691ef1461011557600080fd5b806301fd9044146100a8578063051a9e28146100c4578063257b3632146100d9578063319cf735146100f9575b600080fd5b6100b160005481565b6040519081526020015b60405180910390f35b6100d76100d236600461035c565b6101b0565b005b6100b16100e736600461035c565b60026020526000908152604090205481565b6100b160015481565b6100d761011036600461035c565b6101d1565b6100b1610320565b6100d761012b366004610375565b60009182526002602052604090912055565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100bb565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b80600260006101bd610320565b815260208101919091526040016000205550565b60005460015473ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163303610220575060018290558161029c565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016330361026a57600083905582915061029c565b6040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516020808201849052818301859052825180830384018152606090920190925280519101206000906000818152600260205260408120549192500361031a5760008181526002602052604080822042905551849184917f61014378f82a0d809aefaf87a8ac9505b89c321808287a6e7810f29304c1fce39190a35b50505050565b6000610357600154600054604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b905090565b60006020828403121561036e57600080fd5b5035919050565b6000806040838503121561038857600080fd5b5050803592602090910135915056fea2646970667358221220eeb4ec189dc407e366db39253f2dd748a5e379bc3232254e15b86d12d0001bc064736f6c63430008140033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100a35760003560e01c806333d6247d116100765780635bcef6731161005b5780635bcef6731461011d5780635ec6a8df1461013d578063a3c573eb1461018957600080fd5b806333d6247d146101025780633ed691ef1461011557600080fd5b806301fd9044146100a8578063051a9e28146100c4578063257b3632146100d9578063319cf735146100f9575b600080fd5b6100b160005481565b6040519081526020015b60405180910390f35b6100d76100d236600461035c565b6101b0565b005b6100b16100e736600461035c565b60026020526000908152604090205481565b6100b160015481565b6100d761011036600461035c565b6101d1565b6100b1610320565b6100d761012b366004610375565b60009182526002602052604090912055565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100bb565b6101647f000000000000000000000000000000000000000000000000000000000000000081565b80600260006101bd610320565b815260208101919091526040016000205550565b60005460015473ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163303610220575060018290558161029c565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016330361026a57600083905582915061029c565b6040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516020808201849052818301859052825180830384018152606090920190925280519101206000906000818152600260205260408120549192500361031a5760008181526002602052604080822042905551849184917f61014378f82a0d809aefaf87a8ac9505b89c321808287a6e7810f29304c1fce39190a35b50505050565b6000610357600154600054604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b905090565b60006020828403121561036e57600080fd5b5035919050565b6000806040838503121561038857600080fd5b5050803592602090910135915056fea2646970667358221220eeb4ec189dc407e366db39253f2dd748a5e379bc3232254e15b86d12d0001bc064736f6c63430008140033",
"linkReferences": {},
"deployedLinkReferences": {}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"_format": "hh-sol-artifact-1",
"contractName": "VerifierRollupHelperMock",
"sourceName": "contracts/mocks/VerifierRollupHelperMock.sol",
"abi": [
{
"inputs": [
{
"internalType": "bytes32[24]",
"name": "proof",
"type": "bytes32[24]"
},
{
"internalType": "uint256[1]",
"name": "pubSignals",
"type": "uint256[1]"
}
],
"name": "verifyProof",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x608060405234801561001057600080fd5b50610158806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80639121da8a14610030575b600080fd5b61004661003e366004610089565b600192915050565b604051901515815260200160405180910390f35b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008061032080848603121561009e57600080fd5b6103008401858111156100b057600080fd5b8493508561031f8601126100c357600080fd5b604051602080820182811067ffffffffffffffff821117156100e7576100e761005a565b6040529286019281888511156100fc57600080fd5b5b8484101561011457833581529281019281016100fd565b50949790965094505050505056fea2646970667358221220a11a5105bc567bff17c1e8f9a53599bf5e54cbcab278c0720598328bbf4639b864736f6c63430008140033",
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80639121da8a14610030575b600080fd5b61004661003e366004610089565b600192915050565b604051901515815260200160405180910390f35b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008061032080848603121561009e57600080fd5b6103008401858111156100b057600080fd5b8493508561031f8601126100c357600080fd5b604051602080820182811067ffffffffffffffff821117156100e7576100e761005a565b6040529286019281888511156100fc57600080fd5b5b8484101561011457833581529281019281016100fd565b50949790965094505050505056fea2646970667358221220a11a5105bc567bff17c1e8f9a53599bf5e54cbcab278c0720598328bbf4639b864736f6c63430008140033",
"linkReferences": {},
"deployedLinkReferences": {}
}
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
import "./interfaces/ICDKDataCommitteeErrors.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
contract CDKDataCommittee is
ICDKDataCommitteeErrors, OwnableUpgradeable {
/**
* @notice Struct which will store all the data of the committee members
* @param url string that represents the URL of the member to be used to access the data
* @param addr address of the member that will be used to sign
*/
struct Member {
string url;
address addr;
}
// Size of a signature in bytes
uint internal constant _SIGNATURE_SIZE = 65;
// Size of an address in bytes
uint internal constant _ADDR_SIZE = 20;
// Specifies the required amount of signatures from members in the data availability committee
uint public requiredAmountOfSignatures;
// Hash of the addresses of the committee
bytes32 public committeeHash;
// Register of the members of the committee
Member[] public members;
/**
* @dev Emitted when the committee is updated
* @param committeeHash hash of the addresses of the committee members
*/
event CommitteeUpdated(bytes32 committeeHash);
function initialize() external initializer {
// Initialize OZ contracts
__Ownable_init_unchained();
}
/**
* @notice Allows the admin to setup the members of the committee. Note that:
* The system will require N / M signatures where N => _requiredAmountOfSignatures and M => urls.length
* There must be the same amount of urls than addressess encoded in the addrsBytes
* A member is represented by the url and the address contained in urls[i] and addrsBytes[i*_ADDR_SIZE : i*_ADDR_SIZE + _ADDR_SIZE]
* @param _requiredAmountOfSignatures Required amount of signatures
* @param urls List of urls of the members of the committee
* @param addrsBytes Byte array that contains the addressess of the members of the committee
*/
function setupCommittee(
uint _requiredAmountOfSignatures,
string[] calldata urls,
bytes calldata addrsBytes
) external onlyOwner {
uint membersLength = urls.length;
if (membersLength < _requiredAmountOfSignatures) {
revert TooManyRequiredSignatures();
}
if (addrsBytes.length != membersLength * _ADDR_SIZE) {
revert UnexpectedAddrsBytesLength();
}
delete members;
address lastAddr;
for (uint i = 0; i < membersLength; i++) {
uint currentAddresStartingByte = i * _ADDR_SIZE;
address currentMemberAddr = address(bytes20(addrsBytes[
currentAddresStartingByte :
currentAddresStartingByte + _ADDR_SIZE
]));
if (bytes(urls[i]).length == 0) {
revert EmptyURLNotAllowed();
}
if (lastAddr >= currentMemberAddr) {
revert WrongAddrOrder();
}
lastAddr = currentMemberAddr;
members.push(Member({
url: urls[i],
addr: currentMemberAddr
}));
}
committeeHash = keccak256(addrsBytes);
requiredAmountOfSignatures = _requiredAmountOfSignatures;
emit CommitteeUpdated(committeeHash);
}
function getAmountOfMembers() public view returns(uint256) {
return members.length;
}
/**
* @notice Verifies that the given signedHash has been signed by requiredAmountOfSignatures committee members
* @param signedHash Hash that must have been signed by requiredAmountOfSignatures of committee members
* @param signaturesAndAddrs Byte array containing the signatures and all the addresses of the committee in ascending order
* [signature 0, ..., signature requiredAmountOfSignatures -1, address 0, ... address N]
* note that each ECDSA signatures are used, therefore each one must be 65 bytes
*/
function verifySignatures(
bytes32 signedHash,
bytes calldata signaturesAndAddrs
) external view {
// pre-check: byte array size
uint splitByte = _SIGNATURE_SIZE * requiredAmountOfSignatures;
if(
signaturesAndAddrs.length < splitByte ||
(signaturesAndAddrs.length - splitByte) % _ADDR_SIZE != 0
) {
revert UnexpectedAddrsAndSignaturesSize();
}
// hash the addresses part of the byte array and check that it's equal to committe hash
if (
keccak256(signaturesAndAddrs[splitByte:]) !=
committeeHash
) {
revert UnexpectedCommitteeHash();
}
// recover addresses from signatures and check that are part of the committee
uint lastAddrIndexUsed;
uint addrsLen = (signaturesAndAddrs.length - splitByte) / _ADDR_SIZE;
for (uint i = 0; i < requiredAmountOfSignatures; i++) {
address currentSigner = ECDSA.recover(
signedHash,
signaturesAndAddrs[i*_SIGNATURE_SIZE : i*_SIGNATURE_SIZE + _SIGNATURE_SIZE]
);
bool currentSignerIsPartOfCommittee = false;
for (uint j = lastAddrIndexUsed; j < addrsLen; j++) {
uint currentAddresStartingByte = splitByte + j*_ADDR_SIZE;
address committeeAddr = address(bytes20(signaturesAndAddrs[
currentAddresStartingByte :
currentAddresStartingByte + _ADDR_SIZE
]));
if (committeeAddr == currentSigner) {
lastAddrIndexUsed = j+1;
currentSignerIsPartOfCommittee = true;
break;
}
}
if (!currentSignerIsPartOfCommittee) {
revert CommitteeAddressDoesntExist();
}
}
}
}
\ No newline at end of file
This diff is collapsed.
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
import "@openzeppelin/contracts/governance/TimelockController.sol";
import "./CDKValidium.sol";
/**
* @dev Contract module which acts as a timelocked controller.
* This gives time for users of the controlled contract to exit before a potentially dangerous maintenance operation is applied.
* If emergency mode of the cdkValidium contract system is active, this timelock have no delay.
*/
contract CDKValidiumTimelock is TimelockController {
// CDKValidium address. Will be used to check if it's on emergency state.
CDKValidium public immutable cdkValidium;
/**
* @notice Constructor of timelock
* @param minDelay initial minimum delay for operations
* @param proposers accounts to be granted proposer and canceller roles
* @param executors accounts to be granted executor role
* @param admin optional account to be granted admin role; disable with zero address
* @param _cdkValidium cdkValidium address
**/
constructor(
uint256 minDelay,
address[] memory proposers,
address[] memory executors,
address admin,
CDKValidium _cdkValidium
) TimelockController(minDelay, proposers, executors, admin) {
cdkValidium = _cdkValidium;
}
/**
* @dev Returns the minimum delay for an operation to become valid.
*
* This value can be changed by executing an operation that calls `updateDelay`.
* If CDKValidium is on emergency state the minDelay will be 0 instead.
*/
function getMinDelay() public view override returns (uint256 duration) {
if (address(cdkValidium) != address(0) && cdkValidium.isEmergencyState()) {
return 0;
} else {
return super.getMinDelay();
}
}
}
This diff is collapsed.
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
import "./interfaces/IPolygonZkEVMGlobalExitRoot.sol";
import "./lib/GlobalExitRootLib.sol";
/**
* Contract responsible for managing the exit roots across multiple networks
*/
contract PolygonZkEVMGlobalExitRoot is IPolygonZkEVMGlobalExitRoot {
// PolygonZkEVMBridge address
address public immutable bridgeAddress;
// Rollup contract address
address public immutable rollupAddress;
// Rollup exit root, this will be updated every time a batch is verified
bytes32 public lastRollupExitRoot;
// Mainnet exit root, this will be updated every time a deposit is made in mainnet
bytes32 public lastMainnetExitRoot;
// Store every global exit root: Root --> timestamp
mapping(bytes32 => uint256) public globalExitRootMap;
/**
* @dev Emitted when the global exit root is updated
*/
event UpdateGlobalExitRoot(
bytes32 indexed mainnetExitRoot,
bytes32 indexed rollupExitRoot
);
/**
* @param _rollupAddress Rollup contract address
* @param _bridgeAddress PolygonZkEVMBridge contract address
*/
constructor(address _rollupAddress, address _bridgeAddress) {
rollupAddress = _rollupAddress;
bridgeAddress = _bridgeAddress;
}
/**
* @notice Update the exit root of one of the networks and the global exit root
* @param newRoot new exit tree root
*/
function updateExitRoot(bytes32 newRoot) external {
// Store storage variables into temporal variables since will be used multiple times
bytes32 cacheLastRollupExitRoot = lastRollupExitRoot;
bytes32 cacheLastMainnetExitRoot = lastMainnetExitRoot;
if (msg.sender == bridgeAddress) {
lastMainnetExitRoot = newRoot;
cacheLastMainnetExitRoot = newRoot;
} else if (msg.sender == rollupAddress) {
lastRollupExitRoot = newRoot;
cacheLastRollupExitRoot = newRoot;
} else {
revert OnlyAllowedContracts();
}
bytes32 newGlobalExitRoot = GlobalExitRootLib.calculateGlobalExitRoot(
cacheLastMainnetExitRoot,
cacheLastRollupExitRoot
);
// If it already exists, do not modify the timestamp
if (globalExitRootMap[newGlobalExitRoot] == 0) {
globalExitRootMap[newGlobalExitRoot] = block.timestamp;
emit UpdateGlobalExitRoot(
cacheLastMainnetExitRoot,
cacheLastRollupExitRoot
);
}
}
/**
* @notice Return last global exit root
*/
function getLastGlobalExitRoot() public view returns (bytes32) {
return
GlobalExitRootLib.calculateGlobalExitRoot(
lastMainnetExitRoot,
lastRollupExitRoot
);
}
}
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
import "./interfaces/IBasePolygonZkEVMGlobalExitRoot.sol";
/**
* Contract responsible for managing the exit roots for the L2 and global exit roots
* The special zkRom variables will be accessed and updated directly by the zkRom
*/
contract PolygonZkEVMGlobalExitRootL2 is IBasePolygonZkEVMGlobalExitRoot {
/////////////////////////////
// Special zkRom variables
////////////////////////////
// Store every global exit root: Root --> timestamp
// Note this variable is updated only by the zkRom
mapping(bytes32 => uint256) public globalExitRootMap;
// Rollup exit root will be updated for every PolygonZkEVMBridge call
// Note this variable will be readed by the zkRom
bytes32 public lastRollupExitRoot;
////////////////////
// Regular variables
///////////////////
// PolygonZkEVM Bridge address
address public immutable bridgeAddress;
/**
* @param _bridgeAddress PolygonZkEVMBridge contract address
*/
constructor(address _bridgeAddress) {
bridgeAddress = _bridgeAddress;
}
/**
* @notice Update the exit root of one of the networks and the global exit root
* @param newRoot new exit tree root
*/
function updateExitRoot(bytes32 newRoot) external {
if (msg.sender != bridgeAddress) {
revert OnlyAllowedContracts();
}
lastRollupExitRoot = newRoot;
}
}
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Create2.sol";
import "@openzeppelin/contracts/utils/Address.sol";
/**
* Contract responsible for deploying deterministic address contracts related with the CDKValidium
*/
contract CDKValidiumDeployer is Ownable {
/**
* @param _owner Owner
*/
constructor(address _owner) Ownable() {
_transferOwnership(_owner);
}
/**
* @dev Emitted when a contract is deployed
*/
event NewDeterministicDeployment(address newContractAddress);
/**
* @dev Emitted when a contract is called
*/
event FunctionCall();
/**
* @notice Allows to deploy a contract using create2
* @param amount Amount used in create2
* @param salt Salt used in create2
* @param initBytecode Init bytecode that will be use in create2
*/
function deployDeterministic(
uint256 amount,
bytes32 salt,
bytes memory initBytecode
) public payable onlyOwner {
address newContractAddress = Create2.deploy(amount, salt, initBytecode);
emit NewDeterministicDeployment(newContractAddress);
}
/**
* @notice Allows to deploy a contract using create2 and call it afterwards
* @param amount Amount used in create2
* @param salt Salt used in create2
* @param initBytecode Init bytecode that will be use in create2
* @param dataCall Data used in the call after deploying the smart contract
*/
function deployDeterministicAndCall(
uint256 amount,
bytes32 salt,
bytes memory initBytecode,
bytes memory dataCall
) public payable onlyOwner {
address newContractAddress = Create2.deploy(amount, salt, initBytecode);
Address.functionCall(newContractAddress, dataCall);
emit NewDeterministicDeployment(newContractAddress);
}
/**
* @param targetAddress Amount of contract deploy
* @param dataCall Data used to call the target smart contract
* @param amount Data used to call the target smart contract
*/
function functionCall(
address targetAddress,
bytes memory dataCall,
uint256 amount
) public payable onlyOwner {
Address.functionCallWithValue(targetAddress, dataCall, amount);
emit FunctionCall();
}
/**
* @param salt Salt used in create2
* @param bytecodeHash Init bytecode hashed, it contains the constructor parameters
*/
function predictDeterministicAddress(
bytes32 salt,
bytes32 bytecodeHash
) public view returns (address) {
return Create2.computeAddress(salt, bytecodeHash);
}
}
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
interface IBasePolygonZkEVMGlobalExitRoot {
/**
* @dev Thrown when the caller is not the allowed contracts
*/
error OnlyAllowedContracts();
function updateExitRoot(bytes32 newRollupExitRoot) external;
function globalExitRootMap(
bytes32 globalExitRootNum
) external returns (uint256);
}
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
/**
* @dev Define interface for PolygonZkEVM Bridge message receiver
*/
interface IBridgeMessageReceiver {
function onMessageReceived(
address originAddress,
uint32 originNetwork,
bytes memory data
) external payable;
}
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
interface ICDKDataCommittee {
function verifySignatures(bytes32 hash, bytes memory signaturesAndAddrs) external view;
}
\ No newline at end of file
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
interface ICDKDataCommitteeErrors {
/**
* @dev Thrown when the addres bytes doesn't have the expected length
*/
error UnexpectedAddrsBytesLength();
/**
* @dev Thrown when the setup attempts to register a member with empty URL
*/
error EmptyURLNotAllowed();
/**
* @dev Thrown when the setup register doesn't order the members correctly
*/
error WrongAddrOrder();
/**
* @dev Thrown when the required amount of signatures is greater than the amount of members
*/
error TooManyRequiredSignatures();
/**
* @dev Thrown when the hash of the committee doesn't match with the provided addresses
*/
error UnexpectedCommitteeHash();
/**
* @dev Thrown when the signature of a DA hash doesn't belong to any member of the committee
*/
error CommitteeAddressDoesntExist();
/**
* @dev Thrown when the addresses and signatures byte array length has an unexpected size
*/
error UnexpectedAddrsAndSignaturesSize();
}
\ No newline at end of file
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
interface ICDKValidiumErrors {
/**
* @dev Thrown when the pending state timeout exceeds the _HALT_AGGREGATION_TIMEOUT
*/
error PendingStateTimeoutExceedHaltAggregationTimeout();
/**
* @dev Thrown when the trusted aggregator timeout exceeds the _HALT_AGGREGATION_TIMEOUT
*/
error TrustedAggregatorTimeoutExceedHaltAggregationTimeout();
/**
* @dev Thrown when the caller is not the admin
*/
error OnlyAdmin();
/**
* @dev Thrown when the caller is not the trusted sequencer
*/
error OnlyTrustedSequencer();
/**
* @dev Thrown when the caller is not the trusted aggregator
*/
error OnlyTrustedAggregator();
/**
* @dev Thrown when attempting to sequence 0 batches
*/
error SequenceZeroBatches();
/**
* @dev Thrown when attempting to sequence or verify more batches than _MAX_VERIFY_BATCHES
*/
error ExceedMaxVerifyBatches();
/**
* @dev Thrown when the forced data does not match
*/
error ForcedDataDoesNotMatch();
/**
* @dev Thrown when the sequenced timestamp is below the forced minimum timestamp
*/
error SequencedTimestampBelowForcedTimestamp();
/**
* @dev Thrown when a global exit root is not zero and does not exist
*/
error GlobalExitRootNotExist();
/**
* @dev Thrown when transactions array length is above _MAX_TRANSACTIONS_BYTE_LENGTH.
*/
error TransactionsLengthAboveMax();
/**
* @dev Thrown when a sequenced timestamp is not inside a correct range.
*/
error SequencedTimestampInvalid();
/**
* @dev Thrown when there are more sequenced force batches than were actually submitted, should be unreachable
*/
error ForceBatchesOverflow();
/**
* @dev Thrown when there are more sequenced force batches than were actually submitted
*/
error TrustedAggregatorTimeoutNotExpired();
/**
* @dev Thrown when attempting to access a pending state that does not exist
*/
error PendingStateDoesNotExist();
/**
* @dev Thrown when the init num batch does not match with the one in the pending state
*/
error InitNumBatchDoesNotMatchPendingState();
/**
* @dev Thrown when the old state root of a certain batch does not exist
*/
error OldStateRootDoesNotExist();
/**
* @dev Thrown when the init verification batch is above the last verification batch
*/
error InitNumBatchAboveLastVerifiedBatch();
/**
* @dev Thrown when the final verification batch is below or equal the last verification batch
*/
error FinalNumBatchBelowLastVerifiedBatch();
/**
* @dev Thrown when the zkproof is not valid
*/
error InvalidProof();
/**
* @dev Thrown when attempting to consolidate a pending state not yet consolidable
*/
error PendingStateNotConsolidable();
/**
* @dev Thrown when attempting to consolidate a pending state that is already consolidated or does not exist
*/
error PendingStateInvalid();
/**
* @dev Thrown when the matic amount is below the necessary matic fee
*/
error NotEnoughMaticAmount();
/**
* @dev Thrown when attempting to sequence a force batch using sequenceForceBatches and the
* force timeout did not expire
*/
error ForceBatchTimeoutNotExpired();
/**
* @dev Thrown when attempting to set a new trusted aggregator timeout equal or bigger than current one
*/
error NewTrustedAggregatorTimeoutMustBeLower();
/**
* @dev Thrown when attempting to set a new pending state timeout equal or bigger than current one
*/
error NewPendingStateTimeoutMustBeLower();
/**
* @dev Thrown when attempting to set a new multiplier batch fee in a invalid range of values
*/
error InvalidRangeMultiplierBatchFee();
/**
* @dev Thrown when attempting to set a batch time target in an invalid range of values
*/
error InvalidRangeBatchTimeTarget();
/**
* @dev Thrown when attempting to set a force batch timeout in an invalid range of values
*/
error InvalidRangeForceBatchTimeout();
/**
* @dev Thrown when the caller is not the pending admin
*/
error OnlyPendingAdmin();
/**
* @dev Thrown when the final pending state num is not in a valid range
*/
error FinalPendingStateNumInvalid();
/**
* @dev Thrown when the final num batch does not match with the one in the pending state
*/
error FinalNumBatchDoesNotMatchPendingState();
/**
* @dev Thrown when the stored root matches the new root proving a different state
*/
error StoredRootMustBeDifferentThanNewRoot();
/**
* @dev Thrown when the batch is already verified when attempting to activate the emergency state
*/
error BatchAlreadyVerified();
/**
* @dev Thrown when the batch is not sequenced or not at the end of a sequence when attempting to activate the emergency state
*/
error BatchNotSequencedOrNotSequenceEnd();
/**
* @dev Thrown when the halt timeout is not expired when attempting to activate the emergency state
*/
error HaltTimeoutNotExpired();
/**
* @dev Thrown when the old accumulate input hash does not exist
*/
error OldAccInputHashDoesNotExist();
/**
* @dev Thrown when the new accumulate input hash does not exist
*/
error NewAccInputHashDoesNotExist();
/**
* @dev Thrown when the new state root is not inside prime
*/
error NewStateRootNotInsidePrime();
/**
* @dev Thrown when force batch is not allowed
*/
error ForceBatchNotAllowed();
/**
* @dev Thrown when try to activate force batches when they are already active
*/
error ForceBatchesAlreadyActive();
}
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
interface IPolygonZkEVMBridge {
/**
* @dev Thrown when sender is not the PolygonZkEVM address
*/
error OnlyPolygonZkEVM();
/**
* @dev Thrown when the destination network is invalid
*/
error DestinationNetworkInvalid();
/**
* @dev Thrown when the amount does not match msg.value
*/
error AmountDoesNotMatchMsgValue();
/**
* @dev Thrown when user is bridging tokens and is also sending a value
*/
error MsgValueNotZero();
/**
* @dev Thrown when the Ether transfer on claimAsset fails
*/
error EtherTransferFailed();
/**
* @dev Thrown when the message transaction on claimMessage fails
*/
error MessageFailed();
/**
* @dev Thrown when the global exit root does not exist
*/
error GlobalExitRootInvalid();
/**
* @dev Thrown when the smt proof does not match
*/
error InvalidSmtProof();
/**
* @dev Thrown when an index is already claimed
*/
error AlreadyClaimed();
/**
* @dev Thrown when the owner of permit does not match the sender
*/
error NotValidOwner();
/**
* @dev Thrown when the spender of the permit does not match this contract address
*/
error NotValidSpender();
/**
* @dev Thrown when the amount of the permit does not match
*/
error NotValidAmount();
/**
* @dev Thrown when the permit data contains an invalid signature
*/
error NotValidSignature();
function bridgeAsset(
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
address token,
bool forceUpdateGlobalExitRoot,
bytes calldata permitData
) external payable;
function bridgeMessage(
uint32 destinationNetwork,
address destinationAddress,
bool forceUpdateGlobalExitRoot,
bytes calldata metadata
) external payable;
function claimAsset(
bytes32[32] calldata smtProof,
uint32 index,
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot,
uint32 originNetwork,
address originTokenAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes calldata metadata
) external;
function claimMessage(
bytes32[32] calldata smtProof,
uint32 index,
bytes32 mainnetExitRoot,
bytes32 rollupExitRoot,
uint32 originNetwork,
address originAddress,
uint32 destinationNetwork,
address destinationAddress,
uint256 amount,
bytes calldata metadata
) external;
function updateGlobalExitRoot() external;
function activateEmergencyState() external;
function deactivateEmergencyState() external;
}
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
import "./IBasePolygonZkEVMGlobalExitRoot.sol";
interface IPolygonZkEVMGlobalExitRoot is IBasePolygonZkEVMGlobalExitRoot {
function getLastGlobalExitRoot() external view returns (bytes32);
}
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
/**
* @dev Define interface verifier
*/
interface IVerifierRollup {
function verifyProof(
bytes32[24] calldata proof,
uint256[1] memory pubSignals
) external view returns (bool);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment