Skip to content

Commit

Permalink
Merge pull request #306 from 0xPolygonHermez/feature/add-network-ID
Browse files Browse the repository at this point in the history
add rollupID as a public input
  • Loading branch information
invocamanman authored Aug 1, 2024
2 parents 3f3b029 + 155199c commit 0be472b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 42 deletions.
41 changes: 3 additions & 38 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ name: Build-Docker image

on:
push:
branches: [main]
branches: [main, develop, feature/ongoingPP]
pull_request:
branches: [main, develop, feature/ongoingPP]
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -19,42 +21,5 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Set int-bot SSH key
run: |
touch /tmp/ssh-key
echo "${{ secrets.INT_BOT_SSH_KEY }}" > /tmp/ssh-key
chmod 400 /tmp/ssh-key
eval "$(ssh-agent -s)"
ssh-add /tmp/ssh-key
- name: Checkout code
uses: actions/checkout@v3
- name: setup
run: |
eval "$(ssh-agent -s)"
ssh-add /tmp/ssh-key
npm i
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build docker
run: npm run docker:contracts
- name: Push docker image
run: npm run push:docker:contracts
# Steps to push multi-platform image, it relies on the previous step:
# npm run docker:contracts
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
push: true
tags: hermeznetwork/geth-zkevm-contracts:1.5-integration
file: docker/Dockerfile
context: .
60 changes: 60 additions & 0 deletions .github/workflows/build-push-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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: Build-Docker image and push it

on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Set int-bot SSH key
run: |
touch /tmp/ssh-key
echo "${{ secrets.INT_BOT_SSH_KEY }}" > /tmp/ssh-key
chmod 400 /tmp/ssh-key
eval "$(ssh-agent -s)"
ssh-add /tmp/ssh-key
- name: Checkout code
uses: actions/checkout@v3
- name: setup
run: |
eval "$(ssh-agent -s)"
ssh-add /tmp/ssh-key
npm i
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build docker
run: npm run docker:contracts
- name: Push docker image
run: npm run push:docker:contracts
# Steps to push multi-platform image, it relies on the previous step:
# npm run docker:contracts
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
push: true
tags: hermeznetwork/geth-zkevm-contracts:1.5-integration
file: docker/Dockerfile
context: .
5 changes: 5 additions & 0 deletions contracts/v2/PolygonRollupManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ contract PolygonRollupManager is
}

bytes memory inputPessimisticBytes = _getInputPessimisticBytes(
rollupID,
rollup,
selectedGlobalExitRoot,
newLocalExitRoot,
Expand Down Expand Up @@ -1280,6 +1281,7 @@ contract PolygonRollupManager is
) public view returns (bytes memory) {
return
_getInputPessimisticBytes(
rollupID,
_rollupIDToRollupData[rollupID],
selectedGlobalExitRoot,
newLocalExitRoot,
Expand All @@ -1289,12 +1291,14 @@ contract PolygonRollupManager is

/**
* @notice Function to calculate the input snark bytes
* @param rollupID Rollup identifier
* @param rollup Rollup data storage pointer
* @param selectedGlobalExitRoot Selected global exit root to proof imported bridges
* @param newLocalExitRoot New local exit root
* @param newPessimisticRoot New pessimistic information, Hash(localBalanceTreeRoot, nullifierTreeRoot)
*/
function _getInputPessimisticBytes(
uint32 rollupID,
RollupData storage rollup,
bytes32 selectedGlobalExitRoot,
bytes32 newLocalExitRoot,
Expand All @@ -1310,6 +1314,7 @@ contract PolygonRollupManager is
rollup.lastLocalExitRoot,
rollup.lastPessimisticRoot,
selectedGlobalExitRoot,
rollupID,
consensusHash,
newLocalExitRoot,
newPessimisticRoot
Expand Down
11 changes: 7 additions & 4 deletions src/pessimistic-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,27 @@ const ConsensusTypes = {
* @param {String} lastLocalExitRoot - old LER
* @param {String} lastPessimisticRoot - old pessimistic root. pessRoor = Poseidon(LBR # nullifierRoot)
* @param {String} selectedGlobalExitRoot - selected GER
* @param {Number} consensusHash - consensus hash. consensusHash = Sha(consensusType # consensusPayload)
* @param {Number} newLocalExitRoot - new LER
* @param {Number} newPessimisticRoot - new pessimistic root
* @param {Number} rollupID - rollup identifier (networkID = rollupID - 1)
* @param {String} consensusHash - consensus hash. consensusHash = Sha(consensusType # consensusPayload)
* @param {String} newLocalExitRoot - new LER
* @param {String} newPessimisticRoot - new pessimistic root
*/
function computeInputPessimisticBytes(
lastLocalExitRoot,
lastPessimisticRoot,
selectedGlobalExitRoot,
rollupID,
consensusHash,
newLocalExitRoot,
newPessimisticRoot,
) {
return ethers.solidityPacked(
['bytes32', 'bytes32', 'bytes32', 'bytes32', 'bytes32', 'bytes32'],
['bytes32', 'bytes32', 'bytes32', 'uint32', 'bytes32', 'bytes32', 'bytes32'],
[
lastLocalExitRoot,
lastPessimisticRoot,
selectedGlobalExitRoot,
rollupID,
consensusHash,
newLocalExitRoot,
newPessimisticRoot,
Expand Down
1 change: 1 addition & 0 deletions test/contractsv2/PolygonRollupManager-Pessimistic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ describe("Polygon Rollup Manager with Polygon Pessimistic Consensus", () => {
infoRollup[4],
infoRollup[7],
existingGER,
pessimisticRollupID,
consensusHash,
newLER,
newPPRoot
Expand Down

0 comments on commit 0be472b

Please sign in to comment.