From 3dc61aece5a5fb0446f371b83339a5471c86a116 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 28 Jul 2025 11:38:25 -0700 Subject: [PATCH] chore(audit): address some minor nits (#37) * chore(audit): address some minor nits * lint --- .gitea/workflows/release.yml | 179 ----------------------------------- core/types/tx_pol.go | 4 +- core/types/tx_pol_test.go | 4 +- eth/catalyst/api.go | 4 +- miner/worker.go | 17 ++-- 5 files changed, 13 insertions(+), 195 deletions(-) delete mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml deleted file mode 100644 index f2dcc3ae96..0000000000 --- a/.gitea/workflows/release.yml +++ /dev/null @@ -1,179 +0,0 @@ -on: - push: - branches: - - "master" - tags: - - "v*" - workflow_dispatch: - -jobs: - linux-intel: - name: Linux Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.24 - cache: false - - - name: Install cross toolchain - run: | - apt-get update - apt-get -yq --no-install-suggests --no-install-recommends install gcc-multilib - - - name: Build (amd64) - run: | - go run build/ci.go install -static -arch amd64 -dlgo - - - name: Create/upload archive (amd64) - run: | - go run build/ci.go archive -arch amd64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds - rm -f build/bin/* - env: - LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }} - AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }} - - - name: Build (386) - run: | - go run build/ci.go install -static -arch 386 -dlgo - - - name: Create/upload archive (386) - run: | - go run build/ci.go archive -arch 386 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds - rm -f build/bin/* - env: - LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }} - AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }} - - linux-arm: - name: Linux Build (arm) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.24 - cache: false - - - name: Install cross toolchain - run: | - apt-get update - apt-get -yq --no-install-suggests --no-install-recommends install gcc-arm-linux-gnueabi libc6-dev-armel-cross gcc-arm-linux-gnueabihf libc6-dev-armhf-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross - ln -s /usr/include/asm-generic /usr/include/asm - - - name: Build (arm64) - run: | - go run build/ci.go install -static -dlgo -arch arm64 -cc aarch64-linux-gnu-gcc - - - name: Create/upload archive (arm64) - run: | - go run build/ci.go archive -arch arm64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds - rm -fr build/bin/* - env: - LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }} - AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }} - - - name: Run build (arm5) - run: | - go run build/ci.go install -static -dlgo -arch arm -cc arm-linux-gnueabi-gcc - env: - GOARM: "5" - - - name: Create/upload archive (arm5) - run: | - go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds - env: - GOARM: "5" - LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }} - AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }} - - - name: Run build (arm6) - run: | - go run build/ci.go install -static -dlgo -arch arm -cc arm-linux-gnueabi-gcc - env: - GOARM: "6" - - - name: Create/upload archive (arm6) - run: | - go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds - rm -fr build/bin/* - env: - GOARM: "6" - LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }} - AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }} - - - name: Run build (arm7) - run: | - go run build/ci.go install -static -dlgo -arch arm -cc arm-linux-gnueabi-gcc - env: - GOARM: "7" - - - name: Create/upload archive (arm7) - run: | - go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds - rm -fr build/bin/* - env: - GOARM: "7" - LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }} - AZURE_BLOBSTORE_TOKEN: ${{ secrets.AZURE_BLOBSTORE_TOKEN }} - - windows: - name: Windows Build - runs-on: "win-11" - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.24 - cache: false - - # Note: gcc.exe only works properly if the corresponding bin/ directory is - # contained in PATH. - - - name: "Build (amd64)" - shell: cmd - run: | - set PATH=%GETH_MINGW%\bin;%PATH% - go run build/ci.go install -dlgo -arch amd64 -cc %GETH_MINGW%\bin\gcc.exe - env: - GETH_MINGW: 'C:\msys64\mingw64' - - - name: "Build (386)" - shell: cmd - run: | - set PATH=%GETH_MINGW%\bin;%PATH% - go run build/ci.go install -dlgo -arch 386 -cc %GETH_MINGW%\bin\gcc.exe - env: - GETH_MINGW: 'C:\msys64\mingw32' - - docker: - name: Docker Image - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.24 - cache: false - - - name: Run docker build - env: - DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} - DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} - run: | - go run build/ci.go dockerx -platform linux/amd64,linux/arm64,linux/riscv64 -upload diff --git a/core/types/tx_pol.go b/core/types/tx_pol.go index 54cda4a05e..f5d085e547 100644 --- a/core/types/tx_pol.go +++ b/core/types/tx_pol.go @@ -93,13 +93,13 @@ func (tx *PoLTx) gas() uint64 { return tx.GasLimit } func (tx *PoLTx) gasPrice() *big.Int { return tx.GasPrice } func (tx *PoLTx) gasTipCap() *big.Int { return tx.GasPrice } func (tx *PoLTx) gasFeeCap() *big.Int { return tx.GasPrice } -func (*PoLTx) value() *big.Int { return new(big.Int) } +func (*PoLTx) value() *big.Int { return common.Big0 } func (tx *PoLTx) nonce() uint64 { return tx.Nonce } func (tx *PoLTx) to() *common.Address { return &tx.To } // No-op: PoLTx is originated from the system address and carries no signature. func (*PoLTx) rawSignatureValues() (v, r, s *big.Int) { - return nil, nil, nil + return common.Big0, common.Big0, common.Big0 } func (*PoLTx) setSignatureValues(chainID, v, r, s *big.Int) { diff --git a/core/types/tx_pol_test.go b/core/types/tx_pol_test.go index 68233ee288..97e332539a 100644 --- a/core/types/tx_pol_test.go +++ b/core/types/tx_pol_test.go @@ -122,7 +122,7 @@ func TestPoLTx_RawSignatureValues(t *testing.T) { t.Fatalf("failed to create PoL tx: %v", err) } v, r, s := tx.RawSignatureValues() - if v != nil || r != nil || s != nil { - t.Fatalf("expected nil signature values, have v=%v r=%v s=%v", v, r, s) + if v.Sign() != 0 || r.Sign() != 0 || s.Sign() != 0 { + t.Fatalf("expected 0 signature values, have v=%v r=%v s=%v", v, r, s) } } diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index f514696d1b..4b4cc0282b 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -279,7 +279,7 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV3P11(update engine.ForkchoiceStateV1, return engine.STATUS_INVALID, attributesErr("missing beacon root") case params.ProposerPubkey == nil: return engine.STATUS_INVALID, attributesErr("missing proposer pubkey") - case !api.checkFork(params.Timestamp, forks.Prague1): + case !api.checkFork(params.Timestamp, forks.Prague1, forks.Osaka): return engine.STATUS_INVALID, unsupportedForkErr("fcuV3P11 must only be called for prague1 payloads") } } @@ -720,7 +720,7 @@ func (api *ConsensusAPI) NewPayloadV4P11(params engine.ExecutableData, versioned return invalidStatus, paramsErr("nil executionRequests post-prague") case proposerPubkey == nil: return invalidStatus, paramsErr("nil proposerPubkey post-prague1") - case !api.checkFork(params.Timestamp, forks.Prague1): + case !api.checkFork(params.Timestamp, forks.Prague1, forks.Osaka): return invalidStatus, unsupportedForkErr("newPayloadV4P11 must only be called for prague1 payloads") } requests := convertRequests(executionRequests) diff --git a/miner/worker.go b/miner/worker.go index fa33fa3ea1..a464cd30aa 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -336,23 +336,20 @@ func (miner *Miner) commitBlobTransaction(env *environment, tx *types.Transactio // applyTransaction runs the transaction. If execution fails, state and gas pool are reverted. func (miner *Miner) applyTransaction(env *environment, tx *types.Transaction) (*types.Receipt, error) { var ( - gasPool = env.gasPool - blockGasUsed = &env.header.GasUsed - snap = env.state.Snapshot() - gasBefore uint64 + snap = env.state.Snapshot() + gp = env.gasPool.Gas() ) - // Berachain: PoL tx does not consume gas. + + // Berachain: PoL tx does not consume any block gas. + blockGasUsed := &env.header.GasUsed if tx.Type() == types.PoLTxType { - gasPool = nil blockGasUsed = new(uint64) } - if gasPool != nil { - gasBefore = gasPool.Gas() - } + receipt, err := core.ApplyTransaction(env.evm, env.gasPool, env.state, env.header, tx, blockGasUsed) if err != nil { env.state.RevertToSnapshot(snap) - env.gasPool.SetGas(gasBefore) + env.gasPool.SetGas(gp) } return receipt, err }