Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] go-testing workflow #27

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
name: i386 linux tests
name: Go tests

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]
workflow_dispatch:

jobs:
build:
runs-on: self-hosted
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v5
with:
go-version: 1.21.4
cache: false

- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-mod-cache-${{ hashFiles('**/go.mod', '**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-mod-cache-latest

- name: Install dependencies
run: |
go mod download

- name: Run tests
run: go test -short ./...
env:
GOOS: linux
GOARCH: 386
GOARCH: amd64
4 changes: 2 additions & 2 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var (
HoleskyGenesisHash = common.HexToHash("0xb5f7f912443c940f21fd611f12828d75b534364ed9e95ca4e307729a4661bde4")
SepoliaGenesisHash = common.HexToHash("0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9")
GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
IliadGenesisHash = common.HexToHash("0xf688549151cee34b707abd49c32c019aefb766d701488dd0c668601a91a67978")
LocalGenesisHash = common.HexToHash("0xc070ebc5e40309e00af74260326aaafe320bee14bf131a4852f73b089b592123")
IliadGenesisHash = common.HexToHash("0xf5ebc6f0982e8bf7fd532b3f959f84d12b3dedd2827af8d31f5389447bedafc6")
LocalGenesisHash = common.HexToHash("0x8f3fc56b0dc3a009e6771da99ff737900da84b9aeae15d1bae225cc8b4dbbdc3")
)

func newUint64(val uint64) *uint64 { return &val }
Expand Down
12 changes: 11 additions & 1 deletion tests/fuzzers/bls12381/precompile_fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ package bls
import (
"bytes"
"fmt"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/holiman/uint256"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
Expand Down Expand Up @@ -70,6 +75,11 @@ func checkInput(id byte, inputLen int) bool {
//
// other values are reserved for future use.
func fuzz(id byte, data []byte) int {
vmctx := vm.BlockContext{
Transfer: func(vm.StateDB, common.Address, common.Address, *uint256.Int) {},
}
statedb, _ := state.New(types.EmptyRootHash, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
evm := vm.NewEVM(vmctx, vm.TxContext{}, statedb, params.AllEthashProtocolChanges, vm.Config{})
// Even on bad input, it should not crash, so we still test the gas calc
precompile := vm.PrecompiledContractsBLS[common.BytesToAddress([]byte{id})]
gas := precompile.RequiredGas(data)
Expand All @@ -82,7 +92,7 @@ func fuzz(id byte, data []byte) int {
}
cpy := make([]byte, len(data))
copy(cpy, data)
_, err := precompile.Run(cpy)
_, err := precompile.Run(evm, cpy)
if !bytes.Equal(cpy, data) {
panic(fmt.Sprintf("input data modified, precompile %d: %x %x", id, data, cpy))
}
Expand Down
Loading