diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml deleted file mode 100644 index b0fb9833b3..0000000000 --- a/.github/workflows/build-test.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build Test - -on: - push: - branches: - - master - - develop - - pull_request: - branches: - - master - - develop - -jobs: - unit-test: - strategy: - matrix: - go-version: [1.16.x] - os: [ubuntu-18.04] - runs-on: ${{ matrix.os }} - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - name: Checkout code - uses: actions/checkout@v2 - - - uses: actions/cache@v2 - with: - # In order: - # * Module download cache - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - %LocalAppData%\go-build - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Test Build - run: | - make geth - - diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml new file mode 100644 index 0000000000..90dbb63860 --- /dev/null +++ b/.github/workflows/docker-publish.yaml @@ -0,0 +1,48 @@ +name: GethPublisher + +on: + workflow_dispatch: + push: + branches: [ dev-hanwang-v1.1.11 ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=sha + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml deleted file mode 100644 index a4774d856f..0000000000 --- a/.github/workflows/integration-test.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Integration Test - -on: - push: - branches: - - master - - develop - - pull_request: - branches: - - master - - develop - -jobs: - truffle-test: - strategy: - matrix: - os: [ubuntu-18.04] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Truffle test - run: make truffle-test diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 288749ae41..0000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Lint - -on: - push: - branches: - - master - - develop - - pull_request: - branches: - - master - - develop - -jobs: - unit-test: - strategy: - matrix: - go-version: [1.16.x] - os: [ubuntu-18.04] - runs-on: ${{ matrix.os }} - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - name: Checkout code - uses: actions/checkout@v2 - - - uses: actions/cache@v2 - with: - # In order: - # * Module download cache - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - %LocalAppData%\go-build - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Lint - run: | - make lint diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml deleted file mode 100644 index 87583d8b54..0000000000 --- a/.github/workflows/pre-release.yml +++ /dev/null @@ -1,288 +0,0 @@ -name: Pre Release - -on: - push: - tags: - - 'pre-*' - -jobs: - build: - name: Build Release - strategy: - matrix: - go-version: [1.16.x] - os: [ubuntu-18.04, macos-11, windows-2019] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - uses: actions/cache@v2 - with: - # In order: - # * Module download cache - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - %LocalAppData%\go-build - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - # ============================== - # Linux/Macos/Windows Build - # ============================== - - - name: Build Binary for ${{matrix.os}} - run: make geth - - # ============================== - # Cross Compile for ARM - # ============================== - - - name: Build Binary for ARM - if: matrix.os == 'ubuntu-18.04' - env: - GOPATH: /home/runner/work/woodpecker/go - run: | - mkdir -p $GOPATH/src/github.com/binance-chain/bsc/ - cp -r ./* $GOPATH/src/github.com/binance-chain/bsc/ - cd $GOPATH/src/github.com/binance-chain/bsc/ && make geth-linux-arm - - # ============================== - # Upload artifacts - # ============================== - - - name: Upload Linux Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'ubuntu-18.04' - with: - name: linux - path: ./build/bin/geth - - - name: Upload MacOS Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'macos-11' - with: - name: macos - path: ./build/bin/geth - - - name: Upload Windows Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'windows-2019' - with: - name: windows - path: ./build/bin/geth.exe - - - name: Upload ARM-5 Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'ubuntu-18.04' - with: - name: arm5 - path: /home/runner/work/woodpecker/go/src/github.com/binance-chain/bsc/build/bin/geth-linux-arm-5 - - - name: Upload ARM-6 Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'ubuntu-18.04' - with: - name: arm6 - path: /home/runner/work/woodpecker/go/src/github.com/binance-chain/bsc/build/bin/geth-linux-arm-6 - - - name: Upload ARM-7 Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'ubuntu-18.04' - with: - name: arm7 - path: /home/runner/work/woodpecker/go/src/github.com/binance-chain/bsc/build/bin/geth-linux-arm-7 - - - name: Upload ARM-64 Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'ubuntu-18.04' - with: - name: arm64 - path: /home/runner/work/woodpecker/go/src/github.com/binance-chain/bsc/build/bin/geth-linux-arm64 - - release: - name: Release - needs: build - runs-on: ubuntu-18.04 - steps: - - name: Set Env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Checkout Code - uses: actions/checkout@v2 - - # ============================== - # Download artifacts - # ============================== - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: linux - path: ./linux - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: macos - path: ./macos - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: windows - path: ./windows - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: arm5 - path: ./arm5 - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: arm6 - path: ./arm6 - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: arm7 - path: ./arm7 - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: arm64 - path: ./arm64 - - - name: Download Config File - run: | - . ./.github/release.env - echo "mainnet.zip url: $MAINNET_FILE_URL" - echo "testnet.zip url: $TESTNET_FILE_URL" - curl -L $MAINNET_FILE_URL -o ./mainnet.zip - curl -L $TESTNET_FILE_URL -o ./testnet.zip - - # ============================== - # Create release - # ============================== - - - name: Create Release - id: create_release - uses: actions/create-release@latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - body: | - versing: ${{ env.RELEASE_VERSION}} - git commit: ${{ github.sha }} - draft: true - prerelease: true - - # Check downloaded files - - run: ls - - - name: Upload Release Asset - Linux - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./linux/geth - asset_name: geth_linux - asset_content_type: application/octet-stream - - - name: Upload Release Asset - MacOS - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./macos/geth - asset_name: geth_mac - asset_content_type: application/octet-stream - - - name: Upload Release Asset - Windows - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./windows/geth.exe - asset_name: geth_windows.exe - asset_content_type: application/octet-stream - - - name: Upload Release Asset - Linux ARM 5 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./arm5/geth-linux-arm-5 - asset_name: geth-linux-arm-5 - asset_content_type: application/octet-stream - - - name: Upload Release Asset - Linux ARM 6 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./arm6/geth-linux-arm-6 - asset_name: geth-linux-arm-6 - asset_content_type: application/octet-stream - - - name: Upload Release Asset - Linux ARM 7 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./arm7/geth-linux-arm-7 - asset_name: geth-linux-arm-7 - asset_content_type: application/octet-stream - - - name: Upload Release Asset - Linux ARM 64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./arm64/geth-linux-arm64 - asset_name: geth-linux-arm64 - asset_content_type: application/octet-stream - - - name: Upload Release Asset - MAINNET.ZIP - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./mainnet.zip - asset_name: mainnet.zip - asset_content_type: application/zip - - - name: Upload Release Asset - TESTNET.ZIP - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./testnet.zip - asset_name: testnet.zip - asset_content_type: application/zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 63b49e9772..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,297 +0,0 @@ -name: Release - -on: - push: - # Publish `v1.2.3` tags as releases. - tags: - - v* - -jobs: - build: - name: Build Release - strategy: - matrix: - go-version: [1.16.x] - os: [ubuntu-18.04, macos-11, windows-2019] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - uses: actions/cache@v2 - with: - # In order: - # * Module download cache - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - %LocalAppData%\go-build - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - # ============================== - # Linux/Macos/Windows Build - # ============================== - - - name: Build Binary for ${{matrix.os}} - run: make geth - - # ============================== - # Cross Compile for ARM - # ============================== - - - name: Build Binary for ARM - if: matrix.os == 'ubuntu-18.04' - env: - GOPATH: /home/runner/work/woodpecker/go - run: | - mkdir -p $GOPATH/src/github.com/binance-chain/bsc/ - cp -r ./* $GOPATH/src/github.com/binance-chain/bsc/ - cd $GOPATH/src/github.com/binance-chain/bsc/ && make geth-linux-arm - - # ============================== - # Upload artifacts - # ============================== - - - name: Upload Linux Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'ubuntu-18.04' - with: - name: linux - path: ./build/bin/geth - - - name: Upload MacOS Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'macos-11' - with: - name: macos - path: ./build/bin/geth - - - name: Upload Windows Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'windows-2019' - with: - name: windows - path: ./build/bin/geth.exe - - - name: Upload ARM-5 Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'ubuntu-18.04' - with: - name: arm5 - path: /home/runner/work/woodpecker/go/src/github.com/binance-chain/bsc/build/bin/geth-linux-arm-5 - - - name: Upload ARM-6 Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'ubuntu-18.04' - with: - name: arm6 - path: /home/runner/work/woodpecker/go/src/github.com/binance-chain/bsc/build/bin/geth-linux-arm-6 - - - name: Upload ARM-7 Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'ubuntu-18.04' - with: - name: arm7 - path: /home/runner/work/woodpecker/go/src/github.com/binance-chain/bsc/build/bin/geth-linux-arm-7 - - - name: Upload ARM-64 Build - uses: actions/upload-artifact@v2 - if: matrix.os == 'ubuntu-18.04' - with: - name: arm64 - path: /home/runner/work/woodpecker/go/src/github.com/binance-chain/bsc/build/bin/geth-linux-arm64 - - release: - name: Release - needs: build - runs-on: ubuntu-18.04 - steps: - - name: Set Env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Checkout Code - uses: actions/checkout@v2 - - # ============================== - # Download artifacts - # ============================== - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: linux - path: ./linux - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: macos - path: ./macos - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: windows - path: ./windows - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: arm5 - path: ./arm5 - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: arm6 - path: ./arm6 - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: arm7 - path: ./arm7 - - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: arm64 - path: ./arm64 - - - name: Download Config File - run: | - . ./.github/release.env - echo "mainnet.zip url: $MAINNET_FILE_URL" - echo "testnet.zip url: $TESTNET_FILE_URL" - curl -L $MAINNET_FILE_URL -o ./mainnet.zip - curl -L $TESTNET_FILE_URL -o ./testnet.zip - - # ============================== - # Create release - # ============================== - - name: Generate Change Log - id: changelog - run: | - chmod 755 ./.github/generate_change_log.sh - CHANGELOG=$(./.github/generate_change_log.sh ${{ env.RELEASE_VERSION}}) - - echo "CHANGELOG<> $GITHUB_ENV - echo "$CHANGELOG" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - - name: Create Release - id: create_release - uses: actions/create-release@latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - body: | - ${{ env.CHANGELOG }} - draft: false - prerelease: false - - # Check downloaded files - - run: ls - - - name: Upload Release Asset - Linux - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./linux/geth - asset_name: geth_linux - asset_content_type: application/octet-stream - - - name: Upload Release Asset - MacOS - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./macos/geth - asset_name: geth_mac - asset_content_type: application/octet-stream - - - name: Upload Release Asset - Windows - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./windows/geth.exe - asset_name: geth_windows.exe - asset_content_type: application/octet-stream - - - name: Upload Release Asset - Linux ARM 5 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./arm5/geth-linux-arm-5 - asset_name: geth-linux-arm-5 - asset_content_type: application/octet-stream - - - name: Upload Release Asset - Linux ARM 6 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./arm6/geth-linux-arm-6 - asset_name: geth-linux-arm-6 - asset_content_type: application/octet-stream - - - name: Upload Release Asset - Linux ARM 7 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./arm7/geth-linux-arm-7 - asset_name: geth-linux-arm-7 - asset_content_type: application/octet-stream - - - name: Upload Release Asset - Linux ARM 64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./arm64/geth-linux-arm64 - asset_name: geth-linux-arm64 - asset_content_type: application/octet-stream - - - name: Upload Release Asset - MAINNET.ZIP - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./mainnet.zip - asset_name: mainnet.zip - asset_content_type: application/zip - - - name: Upload Release Asset - TESTNET.ZIP - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./testnet.zip - asset_name: testnet.zip - asset_content_type: application/zip diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml deleted file mode 100644 index 8847aeba4d..0000000000 --- a/.github/workflows/unit-test.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Unit Test - -on: - push: - branches: - - master - - develop - - pull_request: - branches: - - master - - develop - -jobs: - unit-test: - strategy: - matrix: - go-version: [1.16.x] - os: [ubuntu-18.04] - runs-on: ${{ matrix.os }} - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - - name: Checkout code - uses: actions/checkout@v2 - - - uses: actions/cache@v2 - with: - # In order: - # * Module download cache - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - %LocalAppData%\go-build - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - - name: Uint Test - env: - ANDROID_HOME: "" # Skip android test - run: | - go clean -testcache - make test - diff --git a/core/vm/dump_logger.go b/core/vm/dump_logger.go index 358e9978e6..c182dee9e3 100644 --- a/core/vm/dump_logger.go +++ b/core/vm/dump_logger.go @@ -18,10 +18,7 @@ package vm import ( "encoding/json" - "errors" "fmt" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" "math/big" "os" "path" @@ -29,6 +26,9 @@ import ( "strings" "time" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/common" ) @@ -78,11 +78,6 @@ type ParityTraceItem struct { TransactionPosition int `json:"transactionPosition"` TransactionTraceID int `json:"transactionTraceID"` TransactionLastTrace int `json:"transactionLastTrace"` - - outOff int64 - outLen int64 - gasIn uint64 - gasCost uint64 } type ParityLogContext struct { @@ -100,8 +95,6 @@ type ParityLogger struct { file *os.File stack []*ParityTraceItem items []*ParityTraceItem - err error - descended bool } // NewParityLogger creates a new EVM tracer that prints execution steps as parity trace format @@ -111,6 +104,7 @@ func NewParityLogger(ctx *ParityLogContext, blockNumber uint64, perFolder, perFi if err != nil { return nil, err } + sb := &strings.Builder{} l := &ParityLogger{context: ctx, sb: sb, encoder: json.NewEncoder(sb), file: file} if l.context == nil { @@ -131,145 +125,23 @@ func (l *ParityLogger) CaptureStart(env *EVM, from, to common.Address, create bo l.activePrecompiles = ActivePrecompiles(rules) l.stack = make([]*ParityTraceItem, 0, 20) l.items = make([]*ParityTraceItem, 0, 20) - l.err = nil - l.descended = false if create { - l.captureEnter(CREATE, from, to, input, gas, value) + l.CaptureEnter(CREATE, from, to, input, gas, value) } else { - l.captureEnter(CALL, from, to, input, gas, value) + l.CaptureEnter(CALL, from, to, input, gas, value) } } -func (l *ParityLogger) CaptureFault(evm *EVM, pc uint64, op OpCode, gas uint64, cost uint64, scope *ScopeContext, depth int, err error) { - size := len(l.stack) - l.captureExit([]byte{}, uint64(l.stack[size-1].Action.Gas)-gas, err) +func (l *ParityLogger) CaptureFault(uint64, OpCode, uint64, uint64, *ScopeContext, int, error) { } // CaptureState outputs state information on the logger. -func (l *ParityLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost uint64, scope *ScopeContext, rData []byte, depth int, err error) { - // Capture any errors immediately - if err != nil { - l.CaptureFault(env, pc, op, gas, cost, scope, depth, err) - return - } - // We only care about system opcodes, faster if we pre-check once - var syscall = (op & 0xf0) == 0xf0 - - // If a new contract is being created, add to the call stack - if syscall && (op == CREATE || op == CREATE2) { - var inOff = int64(scope.Stack.Back(1).Uint64()) - var inLen = int64(scope.Stack.Back(2).Uint64()) - var value = &big.Int{} - value.SetString(scope.Stack.Back(0).Hex(), 0) - l.captureEnter(op, scope.Contract.Address(), common.Address{}, scope.Memory.GetCopy(inOff, inLen), gas, value) - l.stack[len(l.stack)-1].gasCost = cost - - l.descended = true - return - } - - // If a contract is being self destructed, gather that as a subcall too - if syscall && op == SELFDESTRUCT { - to := common.HexToAddress(scope.Stack.Back(0).Hex()) - value := env.StateDB.GetBalance(scope.Contract.Address()) - l.captureEnter(op, scope.Contract.Address(), to, []byte{}, gas, value) - l.captureExit([]byte{}, 0, nil) - return - } - - // If a new method invocation is being done, add to the call stack - if syscall && (op == CALL || op == CALLCODE || op == DELEGATECALL || op == STATICCALL) { - // Skip any pre-compile invocations, those are just fancy opcodes - var to = common.HexToAddress(scope.Stack.Back(1).Hex()) - if l.isPrecompiled(to) { - return - } - var off int - value := &big.Int{} - if op == DELEGATECALL || op == STATICCALL { - off = 0 - } else { - off = 1 - value.SetString(scope.Stack.Back(2).Hex(), 0) - } - - var inOff = int64(scope.Stack.Back(2 + off).Uint64()) - var inLen = int64(scope.Stack.Back(3 + off).Uint64()) - - l.captureEnter(op, scope.Contract.Address(), to, scope.Memory.GetCopy(inOff, inLen), gas, value) - size := len(l.stack) - l.stack[size-1].outOff = int64(scope.Stack.Back(4 + off).Uint64()) - l.stack[size-1].outLen = int64(scope.Stack.Back(5 + off).Uint64()) - l.stack[size-1].gasCost = cost - - l.descended = true - return - } - // If we've just descended into an inner call, retrieve it's true allowance. We - // need to extract if from within the call as there may be funky gas dynamics - // with regard to requested and actually given gas (2300 stipend, 63/64 rule). - if l.descended { - if depth >= len(l.stack) { - l.stack[len(l.stack)-1].Action.Gas = hexutil.Uint64(gas) - } else { - // TODO(karalabe): The call was made to a plain account. We currently don't - // have access to the true gas amount inside the call and so any amount will - // mostly be wrong since it depends on a lot of input args. Skip gas for now. - } - l.descended = false - } - - if syscall && op == REVERT { - return - } - - // If an existing call is returning, pop off the call stack - if depth == len(l.stack)-1 { - // Pop off the last call and get the execution results - - size := len(l.stack) - callType := l.stack[size-1].Action.CallType - var ( - err error - output []byte - gasUsed uint64 - ) - if callType == strings.ToLower(opCodeToString[CREATE]) || callType == strings.ToLower(opCodeToString[CREATE2]) { - gasUsed = l.stack[size-1].gasIn - l.stack[size-1].gasCost - gas - ret := scope.Stack.Back(0) - if !ret.IsZero() { - addr := common.HexToAddress(ret.Hex()) - l.stack[size-1].Action.To = addr - output = env.StateDB.GetCode(addr) - } else { - err = errors.New("internal failure") - fmt.Println("internal failure: ret equals zero -- 1") - } - } else { - // If the call was a contract call, retrieve the gas usage and output - gasUsed = l.stack[size-1].gasIn - l.stack[size-1].gasCost + uint64(l.stack[size-1].Action.Gas) - gas - ret := scope.Stack.Back(0) - if !ret.IsZero() { - output = scope.Memory.GetCopy(l.stack[size-1].outOff, l.stack[size-1].outLen) - } else { - err = errors.New("internal failure") - fmt.Println("internal failure: ret equals zero -- 2") - } - } - l.captureExit(output, gasUsed, err) - } +func (l *ParityLogger) CaptureState(pc uint64, op OpCode, gas, cost uint64, scope *ScopeContext, rData []byte, depth int, err error) { } // CaptureEnd is triggered at end of execution. func (l *ParityLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) { - if len(l.stack) > 0 { - l.captureExit(output, gasUsed, err) - } else if len(l.items) > 0 && l.items[0].Error == "" && err != nil { - l.items[0].Error = err.Error() - } - if len(l.stack) > 0 { - fmt.Printf("block: %v, tx: %v, trace end with stack size %v", l.context.BlockNumber, l.context.TxPos, len(l.stack)) - } + l.CaptureExit(output, gasUsed, err) itemsSize := len(l.items) for no, item := range l.items { item.TransactionTraceID = no @@ -294,7 +166,7 @@ func getTraceType(typ OpCode) string { } } -func (l *ParityLogger) captureEnter(typ OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) { +func (l *ParityLogger) CaptureEnter(typ OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) { traceAddress := make([]int, 0, 5) if len(l.stack) > 0 { back := l.stack[len(l.stack)-1] @@ -321,8 +193,6 @@ func (l *ParityLogger) captureEnter(typ OpCode, from common.Address, to common.A BlockNumber: l.context.BlockNumber, TransactionHash: l.context.TxHash, TransactionPosition: l.context.TxPos, - - gasIn: gas, } if value != nil { newItem.Action.Value = value.Bytes() @@ -341,12 +211,12 @@ func (l *ParityLogger) isPrecompiled(addr common.Address) bool { return false } -func (l *ParityLogger) captureExit(output []byte, gasUsed uint64, err error) { +func (l *ParityLogger) CaptureExit(output []byte, gasUsed uint64, err error) { current := l.stack[len(l.stack)-1] current.Result.GasUsed = hexutil.Uint64(gasUsed) current.Result.Output = append([]byte{}, output...) if err != nil { - current.Error += err.Error() + current.Error = err.Error() } l.stack = l.stack[0 : len(l.stack)-1]