diff --git a/.github/workflows/on_main.yml b/.github/workflows/on_main.yml index 78acf71..546a676 100644 --- a/.github/workflows/on_main.yml +++ b/.github/workflows/on_main.yml @@ -29,4 +29,14 @@ jobs: tags: | ghcr.io/near/rollup-data-availability/da-rpc:${{ github.sha }} ghcr.io/near/rollup-data-availability/da-rpc:latest + + - name: Build "sidecar" Docker image and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + file: ./bin/http-api/Dockerfile + tags: | + ghcr.io/near/rollup-data-availability/http-api:${{ github.sha }} + ghcr.io/near/rollup-data-availability/http-api:latest diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml index bf95127..a41db5c 100644 --- a/.github/workflows/on_pull_request.yml +++ b/.github/workflows/on_pull_request.yml @@ -6,24 +6,43 @@ on: - main jobs: - lint: - name: "Lint" - runs-on: - group: ubuntu-22.04-8core + changes: + runs-on: ubuntu-latest + permissions: + pull-requests: read steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: "recursive" - - uses: actions-rust-lang/setup-rust-toolchain@v1 - - uses: Swatinem/rust-cache@v2 - - name: 📜 Lint code format - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - test-rust: - name: "Test Rust" + # For pull requests it's not necessary to checkout the code + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + rust: + - '.github/**' + - '/**/*.rs' + - '/**/Cargo.toml' + - '/**/Cargo.lock' + - '/**/rust-toolchain**' + - 'flake.nix' + - 'flake.lock' + go: + - '.github/**' + - '/**/*.go' + - '/**/go.mod' + - '/**/go.sum' + - '/**/gopkg.lock' + eth: + - '.github/**' + - '/**/*.sol' + - 'eth/foundry.toml' + - 'eth/justfile' + - 'eth/package.json' + outputs: + rust: ${{ steps.filter.outputs.rust }} + go: ${{ steps.filter.outputs.go }} + eth: ${{ steps.filter.outputs.eth }} + rust: + needs: changes + if: ${{ needs.changes.outputs.rust == 'true' }} runs-on: group: ubuntu-22.04-16core steps: @@ -37,6 +56,11 @@ jobs: uses: taiki-e/install-action@v2 with: tool: nextest + - name: 📜 Lint code format + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check - name: "Build contracts" run: make build-contracts - name: "Ensure target dir exists" @@ -48,8 +72,9 @@ jobs: # uses: orf/cargo-bloat-action@v1 # with: # token: ${{ secrets.CEJAS_PERSONAL_ACCESS_TOKEN }} - test-go: - name: "Test gopkg" + go: + needs: changes + if: ${{ needs.changes.outputs.go == 'true' }} runs-on: group: ubuntu-22.04-8core steps: @@ -66,4 +91,49 @@ jobs: - name: "Test gopkg" working-directory: ./gopkg/da-rpc run: go test -v - + + eth-contracts: + needs: changes + if: ${{ needs.changes.outputs.eth == 'true' }} + runs-on: + group: ubuntu-22.04-8core + defaults: + run: + working-directory: ./eth + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + token: ${{ secrets.GITHUB_TOKEN }} + - name: "Install Foundry" + uses: "foundry-rs/foundry-toolchain@v1" + - name: "Install Bun" + uses: "oven-sh/setup-bun@v1" + - name: "Install the Node.js dependencies" + run: "bun install" + - name: "Lint the code" + run: "bun run lint" + - name: "Add lint summary" + run: | + echo "## Lint result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY + - name: "Build the contracts and print their size" + run: "forge build --sizes" + - name: "Add build summary" + run: | + echo "## Build result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY + - name: "Show the Foundry config" + run: "forge config" + - name: "Generate a fuzz seed that changes weekly to avoid burning through RPC allowance" + run: > + echo "FOUNDRY_FUZZ_SEED=$( + echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800)) + )" >> $GITHUB_ENV + - name: "Run the tests" + run: "forge test --gas-report" + - name: "Add test summary" + run: | + echo "## Tests result" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY diff --git a/eth/.githubtodo/scripts/rename.sh b/eth/.githubtodo/scripts/rename.sh deleted file mode 100755 index 62e37dd..0000000 --- a/eth/.githubtodo/scripts/rename.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -# https://gist.github.com/vncsna/64825d5609c146e80de8b1fd623011ca -set -euo pipefail - -# Define the input vars -GITHUB_REPOSITORY=${1?Error: Please pass username/repo, e.g. prb/foundry-template} -GITHUB_REPOSITORY_OWNER=${2?Error: Please pass username, e.g. prb} -GITHUB_REPOSITORY_DESCRIPTION=${3:-""} # If null then replace with empty string - -echo "GITHUB_REPOSITORY: $GITHUB_REPOSITORY" -echo "GITHUB_REPOSITORY_OWNER: $GITHUB_REPOSITORY_OWNER" -echo "GITHUB_REPOSITORY_DESCRIPTION: $GITHUB_REPOSITORY_DESCRIPTION" - -# jq is like sed for JSON data -JQ_OUTPUT=`jq \ - --arg NAME "@$GITHUB_REPOSITORY" \ - --arg AUTHOR_NAME "$GITHUB_REPOSITORY_OWNER" \ - --arg URL "https://github.com/$GITHUB_REPOSITORY_OWNER" \ - --arg DESCRIPTION "$GITHUB_REPOSITORY_DESCRIPTION" \ - '.name = $NAME | .description = $DESCRIPTION | .author |= ( .name = $AUTHOR_NAME | .url = $URL )' \ - package.json -` - -# Overwrite package.json -echo "$JQ_OUTPUT" > package.json - -# Make sed command compatible in both Mac and Linux environments -# Reference: https://stackoverflow.com/a/38595160/8696958 -sedi () { - sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@" -} - -# Rename instances of "PaulRBerg/foundry-template" to the new repo name in README.md for badges only -sedi "/gitpod/ s|PaulRBerg/foundry-template|"${GITHUB_REPOSITORY}"|;" "README.md" -sedi "/gitpod-badge/ s|PaulRBerg/foundry-template|"${GITHUB_REPOSITORY}"|;" "README.md" -sedi "/gha/ s|PaulRBerg/foundry-template|"${GITHUB_REPOSITORY}"|;" "README.md" -sedi "/gha-badge/ s|PaulRBerg/foundry-template|"${GITHUB_REPOSITORY}"|;" "README.md" diff --git a/eth/.githubtodo/workflows/ci.yml b/eth/.githubtodo/workflows/ci.yml deleted file mode 100644 index 7550749..0000000 --- a/eth/.githubtodo/workflows/ci.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: "CI" - -env: - API_KEY_ALCHEMY: ${{ secrets.API_KEY_ALCHEMY }} - FOUNDRY_PROFILE: "ci" - -on: - workflow_dispatch: - pull_request: - push: - branches: - - "main" - -jobs: - lint: - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v4" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Install Bun" - uses: "oven-sh/setup-bun@v1" - - - name: "Install the Node.js dependencies" - run: "bun install" - - - name: "Lint the code" - run: "bun run lint" - - - name: "Add lint summary" - run: | - echo "## Lint result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - build: - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v4" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Install Bun" - uses: "oven-sh/setup-bun@v1" - - - name: "Install the Node.js dependencies" - run: "bun install" - - - name: "Build the contracts and print their size" - run: "forge build --sizes" - - - name: "Add build summary" - run: | - echo "## Build result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - test: - needs: ["lint", "build"] - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v4" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Install Bun" - uses: "oven-sh/setup-bun@v1" - - - name: "Install the Node.js dependencies" - run: "bun install" - - - name: "Show the Foundry config" - run: "forge config" - - - name: "Generate a fuzz seed that changes weekly to avoid burning through RPC allowance" - run: > - echo "FOUNDRY_FUZZ_SEED=$( - echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800)) - )" >> $GITHUB_ENV - - - name: "Run the tests" - run: "forge test" - - - name: "Add test summary" - run: | - echo "## Tests result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY diff --git a/eth/.githubtodo/workflows/create.yml b/eth/.githubtodo/workflows/create.yml deleted file mode 100644 index e0e9369..0000000 --- a/eth/.githubtodo/workflows/create.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: "Create" - -# The workflow will run only when the "Use this template" button is used -on: - create: - -jobs: - create: - # We only run this action when the repository isn't the template repository. References: - # - https://docs.github.com/en/actions/learn-github-actions/contexts - # - https://docs.github.com/en/actions/learn-github-actions/expressions - if: ${{ !github.event.repository.is_template }} - permissions: "write-all" - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v4" - - - name: "Update package.json" - env: - GITHUB_REPOSITORY_DESCRIPTION: ${{ github.event.repository.description }} - run: - ./.github/scripts/rename.sh "$GITHUB_REPOSITORY" "$GITHUB_REPOSITORY_OWNER" "$GITHUB_REPOSITORY_DESCRIPTION" - - - name: "Add rename summary" - run: | - echo "## Commit result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - - name: "Remove files not needed in the user's copy of the template" - run: | - rm -f "./.github/FUNDING.yml" - rm -f "./.github/scripts/rename.sh" - rm -f "./.github/workflows/create.yml" - - - name: "Add remove summary" - run: | - echo "## Remove result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - - name: "Update commit" - uses: "stefanzweifel/git-auto-commit-action@v4" - with: - commit_message: "feat: initial commit" - commit_options: "--amend" - push_options: "--force" - skip_fetch: true - - - name: "Add commit summary" - run: | - echo "## Commit result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY diff --git a/eth/.gitpod.yml b/eth/.gitpod.yml deleted file mode 100644 index b9646d8..0000000 --- a/eth/.gitpod.yml +++ /dev/null @@ -1,14 +0,0 @@ -image: "gitpod/workspace-bun" - -tasks: - - name: "Install dependencies" - before: | - curl -L https://foundry.paradigm.xyz | bash - source ~/.bashrc - foundryup - init: "bun install" - -vscode: - extensions: - - "esbenp.prettier-vscode" - - "NomicFoundation.hardhat-solidity" diff --git a/eth/.vscode/settings.json b/eth/.vscode/settings.json deleted file mode 100644 index 241108b..0000000 --- a/eth/.vscode/settings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "[solidity]": { - "editor.defaultFormatter": "NomicFoundation.hardhat-solidity" - }, - "[toml]": { - "editor.defaultFormatter": "tamasfe.even-better-toml" - }, - "solidity.formatter": "forge" -} diff --git a/eth/README.md b/eth/README.md index 1c04aaf..607ee4f 100644 --- a/eth/README.md +++ b/eth/README.md @@ -1,39 +1,3 @@ -# Foundry Template [![Open in Gitpod][gitpod-badge]][gitpod] [![Github Actions][gha-badge]][gha] [![Foundry][foundry-badge]][foundry] [![License: MIT][license-badge]][license] - -[gitpod]: https://gitpod.io/#https://github.com/PaulRBerg/foundry-template -[gitpod-badge]: https://img.shields.io/badge/Gitpod-Open%20in%20Gitpod-FFB45B?logo=gitpod -[gha]: https://github.com/PaulRBerg/foundry-template/actions -[gha-badge]: https://github.com/PaulRBerg/foundry-template/actions/workflows/ci.yml/badge.svg -[foundry]: https://getfoundry.sh/ -[foundry-badge]: https://img.shields.io/badge/Built%20with-Foundry-FFDB1C.svg -[license]: https://opensource.org/licenses/MIT -[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg - -A Foundry-based template for developing Solidity smart contracts, with sensible defaults. - -## What's Inside - -- [Forge](https://github.com/foundry-rs/foundry/blob/master/forge): compile, test, fuzz, format, and deploy smart - contracts -- [Forge Std](https://github.com/foundry-rs/forge-std): collection of helpful contracts and cheatcodes for testing -- [PRBTest](https://github.com/PaulRBerg/prb-test): modern collection of testing assertions and logging utilities -- [Prettier](https://github.com/prettier/prettier): code formatter for non-Solidity files -- [Solhint](https://github.com/protofire/solhint): linter for Solidity code - -## Getting Started - -Click the [`Use this template`](https://github.com/PaulRBerg/foundry-template/generate) button at the top of the page to -create a new repository with this repo as the initial state. - -Or, if you prefer to install the template manually: - -```sh -$ mkdir my-project -$ cd my-project -$ forge init --template PaulRBerg/foundry-template -$ bun install # install Solhint, Prettier, and other Node.js deps -``` - If this is your first time with Foundry, check out the [installation](https://github.com/foundry-rs/foundry#installation) instructions. diff --git a/eth/justfile b/eth/justfile index 79a03e6..1c9cee6 100644 --- a/eth/justfile +++ b/eth/justfile @@ -1,6 +1,9 @@ # Change this if you want to use it CDK_PATH := ~/projects/data-availability/cdk/cdk-validium-node +cdk-local: + NEWCONTRACT=forge script Deploy --fork-url local --broadcast --legacy --json | jq -R 'fromjson?' | jq -r '.returns.da.value' + docker exec zkevm-sequence-sender /app/zkevm-node set-dap --da-addr $NEWCONTRACT --network custom --custom-network-file /app/genesis.json --key-store-path /pk/sequencer.keystore --pw testonly --cfg /app/config.toml gen-cdk: forge inspect NearDataAvailability abi > {{CDK_PATH}}/etherman/smartcontracts/abi/neardataavailability.abi forge inspect NearDataAvailability bytecode > {{CDK_PATH}}/etherman/smartcontracts/bin/neardataavailabil diff --git a/eth/package.json b/eth/package.json index a02fa92..7d56273 100644 --- a/eth/package.json +++ b/eth/package.json @@ -1,10 +1,10 @@ { - "name": "@prb/foundry-template", - "description": "Foundry-based template for developing Solidity smart contracts", + "name": "@near/rollup-data-availability", + "description": "", "version": "1.0.0", "author": { - "name": "Paul Razvan Berg", - "url": "https://github.com/PaulRBerg" + "name": "dndll", + "url": "https://github.com/dndll" }, "dependencies": { "@0xpolygonhermez/zkevm-contracts": "github.com:0xPolygonHermez/zkevm-contracts", diff --git a/eth/todoscript.sh b/eth/todoscript.sh deleted file mode 100644 index 1adfa8e..0000000 --- a/eth/todoscript.sh +++ /dev/null @@ -1,2 +0,0 @@ -NEWCONTRACT=forge script Deploy --fork-url local --broadcast --legacy --json | jq -R 'fromjson?' | jq -r '.returns.da.value' -docker exec zkevm-sequence-sender /app/zkevm-node set-dap --da-addr $NEWCONTRACT --network custom --custom-network-file /app/genesis.json --key-store-path /pk/sequencer.keystore --pw testonly --cfg /app/config.toml