Skip to content

Commit f46f771

Browse files
authored
Merge pull request #110 from berachain/latest-master-update2
2 parents 156ced5 + 801ea3c commit f46f771

File tree

140 files changed

+22224
-12045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+22224
-12045
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Set up Go
2626
uses: actions/setup-go@v5
2727
with:
28-
go-version: 1.24
28+
go-version: '1.25'
2929
cache: false
3030

3131
- name: Run linters
@@ -34,6 +34,24 @@ jobs:
3434
go run build/ci.go check_generate
3535
go run build/ci.go check_baddeps
3636
37+
keeper:
38+
name: Keeper Builds
39+
needs: test
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
submodules: true
45+
46+
- name: Set up Go
47+
uses: actions/setup-go@v5
48+
with:
49+
go-version: '1.25'
50+
cache: false
51+
52+
- name: Build
53+
run: go run build/ci.go keeper
54+
3755
tests:
3856
name: Tests
3957
runs-on: ubuntu-latest
@@ -45,8 +63,8 @@ jobs:
4563
- name: Set up Go
4664
uses: actions/setup-go@v5
4765
with:
48-
go-version: 1.24.0
66+
go-version: '1.25'
4967
cache: false
5068

5169
- name: Run tests
52-
run: go run build/ci.go test
70+
run: go run build/ci.go test -p 8

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ cmd/evm/evm
5656
cmd/geth/geth
5757
cmd/rlpdump/rlpdump
5858
cmd/workload/workload
59+
cmd/keeper/keeper
5960

6061
# claude
6162
.claude

accounts/abi/abigen/bind_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,13 +485,13 @@ var bindTests = []struct {
485485
contract Defaulter {
486486
address public caller;
487487
488-
function() {
488+
fallback() external payable {
489489
caller = msg.sender;
490490
}
491491
}
492492
`,
493-
[]string{`6060604052606a8060106000396000f360606040523615601d5760e060020a6000350463fc9c8d3981146040575b605e6000805473ffffffffffffffffffffffffffffffffffffffff191633179055565b606060005473ffffffffffffffffffffffffffffffffffffffff1681565b005b6060908152602090f3`},
494-
[]string{`[{"constant":true,"inputs":[],"name":"caller","outputs":[{"name":"","type":"address"}],"type":"function"}]`},
493+
[]string{`608060405234801561000f575f80fd5b5061013d8061001d5f395ff3fe608060405260043610610021575f3560e01c8063fc9c8d391461006257610022565b5b335f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055005b34801561006d575f80fd5b5061007661008c565b60405161008391906100ee565b60405180910390f35b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100d8826100af565b9050919050565b6100e8816100ce565b82525050565b5f6020820190506101015f8301846100df565b9291505056fea26469706673582212201e9273ecfb1f534644c77f09a25c21baaba81cf1c444ebc071e12a225a23c72964736f6c63430008140033`},
494+
[]string{`[{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"caller","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]`},
495495
`
496496
"math/big"
497497

accounts/abi/bind/v2/base.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,10 @@ func (c *BoundContract) RawCreationTransact(opts *TransactOpts, calldata []byte)
277277
// Transfer initiates a plain transaction to move funds to the contract, calling
278278
// its default method if one is available.
279279
func (c *BoundContract) Transfer(opts *TransactOpts) (*types.Transaction, error) {
280-
// todo(rjl493456442) check the payable fallback or receive is defined
281-
// or not, reject invalid transaction at the first place
280+
// Check if payable fallback or receive is defined
281+
if !c.abi.HasReceive() && !(c.abi.HasFallback() && c.abi.Fallback.IsPayable()) {
282+
return nil, fmt.Errorf("contract does not have a payable fallback or receive function")
283+
}
282284
return c.transact(opts, &c.address, nil)
283285
}
284286

accounts/abi/bind/v2/util_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,9 @@ func TestWaitDeployedCornerCases(t *testing.T) {
144144
done := make(chan struct{})
145145
go func() {
146146
defer close(done)
147-
want := errors.New("context canceled")
148147
_, err := bind.WaitDeployed(ctx, backend.Client(), tx.Hash())
149-
if err == nil || errors.Is(want, err) {
150-
t.Errorf("error mismatch: want %v, got %v", want, err)
148+
if !errors.Is(err, context.Canceled) {
149+
t.Errorf("error mismatch: want %v, got %v", context.Canceled, err)
151150
}
152151
}()
153152

beacon/params/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ func (c *ChainConfig) LoadForks(file []byte) error {
108108
switch version := value.(type) {
109109
case int:
110110
versions[name] = new(big.Int).SetUint64(uint64(version)).FillBytes(make([]byte, 4))
111+
case int64:
112+
versions[name] = new(big.Int).SetUint64(uint64(version)).FillBytes(make([]byte, 4))
111113
case uint64:
112114
versions[name] = new(big.Int).SetUint64(version).FillBytes(make([]byte, 4))
113115
case string:
@@ -125,6 +127,8 @@ func (c *ChainConfig) LoadForks(file []byte) error {
125127
switch epoch := value.(type) {
126128
case int:
127129
epochs[name] = uint64(epoch)
130+
case int64:
131+
epochs[name] = uint64(epoch)
128132
case uint64:
129133
epochs[name] = epoch
130134
case string:

build/ci.go

Lines changed: 104 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Available commands are:
3131
install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables
3232
test [ -coverage ] [ packages... ] -- runs the tests
3333
34+
keeper [ -dlgo ]
35+
keeper-archive [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ]
36+
3437
archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ] -- archives build artifacts
3538
importkeys -- imports signing keys from env
3639
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
@@ -86,6 +89,30 @@ var (
8689
executablePath("clef"),
8790
}
8891

92+
// Keeper build targets with their configurations
93+
keeperTargets = []struct {
94+
Name string
95+
GOOS string
96+
GOARCH string
97+
CC string
98+
Tags string
99+
Env map[string]string
100+
}{
101+
{
102+
Name: "ziren",
103+
GOOS: "linux",
104+
GOARCH: "mipsle",
105+
// enable when cgo works
106+
// CC: "mipsel-linux-gnu-gcc",
107+
Tags: "ziren",
108+
Env: map[string]string{"GOMIPS": "softfloat", "CGO_ENABLED": "0"},
109+
},
110+
{
111+
Name: "example",
112+
Tags: "example",
113+
},
114+
}
115+
89116
// A debian package is created for all executables listed here.
90117
debExecutables = []debExecutable{
91118
{
@@ -178,6 +205,10 @@ func main() {
178205
doPurge(os.Args[2:])
179206
case "sanitycheck":
180207
doSanityCheck()
208+
case "keeper":
209+
doInstallKeeper(os.Args[2:])
210+
case "keeper-archive":
211+
doKeeperArchive(os.Args[2:])
181212
default:
182213
log.Fatal("unknown command ", os.Args[1])
183214
}
@@ -212,9 +243,6 @@ func doInstall(cmdline []string) {
212243
// Configure the build.
213244
gobuild := tc.Go("build", buildFlags(env, *staticlink, buildTags)...)
214245

215-
// We use -trimpath to avoid leaking local paths into the built executables.
216-
gobuild.Args = append(gobuild.Args, "-trimpath")
217-
218246
// Show packages during build.
219247
gobuild.Args = append(gobuild.Args, "-v")
220248

@@ -234,6 +262,43 @@ func doInstall(cmdline []string) {
234262
}
235263
}
236264

265+
// doInstallKeeper builds keeper binaries for all supported targets.
266+
func doInstallKeeper(cmdline []string) {
267+
var dlgo = flag.Bool("dlgo", false, "Download Go and build with it")
268+
269+
flag.CommandLine.Parse(cmdline)
270+
env := build.Env()
271+
272+
// Configure the toolchain.
273+
tc := build.GoToolchain{}
274+
if *dlgo {
275+
csdb := download.MustLoadChecksums("build/checksums.txt")
276+
tc.Root = build.DownloadGo(csdb)
277+
}
278+
279+
for _, target := range keeperTargets {
280+
log.Printf("Building keeper-%s", target.Name)
281+
282+
// Configure the build.
283+
tc.GOARCH = target.GOARCH
284+
tc.GOOS = target.GOOS
285+
tc.CC = target.CC
286+
gobuild := tc.Go("build", buildFlags(env, true, []string{target.Tags})...)
287+
gobuild.Dir = "./cmd/keeper"
288+
gobuild.Args = append(gobuild.Args, "-v")
289+
290+
for key, value := range target.Env {
291+
gobuild.Env = append(gobuild.Env, key+"="+value)
292+
}
293+
outputName := fmt.Sprintf("keeper-%s", target.Name)
294+
295+
args := slices.Clone(gobuild.Args)
296+
args = append(args, "-o", executablePath(outputName))
297+
args = append(args, ".")
298+
build.MustRun(&exec.Cmd{Path: gobuild.Path, Args: args, Env: gobuild.Env})
299+
}
300+
}
301+
237302
// buildFlags returns the go tool flags for building.
238303
func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (flags []string) {
239304
var ld []string
@@ -273,6 +338,8 @@ func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (
273338
if len(buildTags) > 0 {
274339
flags = append(flags, "-tags", strings.Join(buildTags, ","))
275340
}
341+
// We use -trimpath to avoid leaking local paths into the built executables.
342+
flags = append(flags, "-trimpath")
276343
return flags
277344
}
278345

@@ -290,12 +357,17 @@ func doTest(cmdline []string) {
290357
race = flag.Bool("race", false, "Execute the race detector")
291358
short = flag.Bool("short", false, "Pass the 'short'-flag to go test")
292359
cachedir = flag.String("cachedir", "./build/cache", "directory for caching downloads")
360+
threads = flag.Int("p", 1, "Number of CPU threads to use for testing")
293361
)
294362
flag.CommandLine.Parse(cmdline)
295363

296-
// Get test fixtures.
364+
// Load checksums file (needed for both spec tests and dlgo)
297365
csdb := download.MustLoadChecksums("build/checksums.txt")
298-
downloadSpecTestFixtures(csdb, *cachedir)
366+
367+
// Get test fixtures.
368+
if !*short {
369+
downloadSpecTestFixtures(csdb, *cachedir)
370+
}
299371

300372
// Configure the toolchain.
301373
tc := build.GoToolchain{GOARCH: *arch, CC: *cc}
@@ -316,7 +388,7 @@ func doTest(cmdline []string) {
316388

317389
// Test a single package at a time. CI builders are slow
318390
// and some tests run into timeouts under load.
319-
gotest.Args = append(gotest.Args, "-p", "1")
391+
gotest.Args = append(gotest.Args, "-p", fmt.Sprintf("%d", *threads))
320392
if *coverage {
321393
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover")
322394
}
@@ -625,6 +697,32 @@ func doArchive(cmdline []string) {
625697
}
626698
}
627699

700+
func doKeeperArchive(cmdline []string) {
701+
var (
702+
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. LINUX_SIGNING_KEY)`)
703+
signify = flag.String("signify", "", `Environment variable holding the signify key (e.g. LINUX_SIGNIFY_KEY)`)
704+
upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
705+
)
706+
flag.CommandLine.Parse(cmdline)
707+
708+
var (
709+
env = build.Env()
710+
vsn = version.Archive(env.Commit)
711+
keeper = "keeper-" + vsn + ".tar.gz"
712+
)
713+
maybeSkipArchive(env)
714+
files := []string{"COPYING"}
715+
for _, target := range keeperTargets {
716+
files = append(files, executablePath(fmt.Sprintf("keeper-%s", target.Name)))
717+
}
718+
if err := build.WriteArchive(keeper, files); err != nil {
719+
log.Fatal(err)
720+
}
721+
if err := archiveUpload(keeper, *upload, *signer, *signify); err != nil {
722+
log.Fatal(err)
723+
}
724+
}
725+
628726
func archiveBasename(arch string, archiveVersion string) string {
629727
platform := runtime.GOOS + "-" + arch
630728
if arch == "arm" {

cmd/bera-geth/config.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"github.com/ethereum/go-ethereum/beacon/blsync"
3636
"github.com/ethereum/go-ethereum/cmd/utils"
3737
"github.com/ethereum/go-ethereum/common"
38-
"github.com/ethereum/go-ethereum/common/hexutil"
3938
"github.com/ethereum/go-ethereum/crypto"
4039
"github.com/ethereum/go-ethereum/eth/catalyst"
4140
"github.com/ethereum/go-ethereum/eth/ethconfig"
@@ -279,11 +278,11 @@ func makeFullNode(ctx *cli.Context) *node.Node {
279278
// Configure synchronization override service
280279
var synctarget common.Hash
281280
if ctx.IsSet(utils.SyncTargetFlag.Name) {
282-
hex := hexutil.MustDecode(ctx.String(utils.SyncTargetFlag.Name))
283-
if len(hex) != common.HashLength {
284-
utils.Fatalf("invalid sync target length: have %d, want %d", len(hex), common.HashLength)
281+
target := ctx.String(utils.SyncTargetFlag.Name)
282+
if !common.IsHexHash(target) {
283+
utils.Fatalf("sync target hash is not a valid hex hash: %s", target)
285284
}
286-
synctarget = common.BytesToHash(hex)
285+
synctarget = common.HexToHash(target)
287286
}
288287
utils.RegisterSyncOverrideService(stack, eth, synctarget, ctx.Bool(utils.ExitWhenSyncedFlag.Name))
289288

cmd/bera-geth/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ var (
6666
utils.OverrideBPO1,
6767
utils.OverrideBPO2,
6868
utils.OverrideVerkle,
69+
utils.OverrideGenesisFlag,
6970
utils.EnablePersonal, // deprecated
7071
utils.TxPoolLocalsFlag,
7172
utils.TxPoolNoLocalsFlag,
@@ -188,6 +189,8 @@ var (
188189
utils.AllowUnprotectedTxs,
189190
utils.BatchRequestLimit,
190191
utils.BatchResponseMaxSize,
192+
utils.RPCTxSyncDefaultTimeoutFlag,
193+
utils.RPCTxSyncMaxTimeoutFlag,
191194
}
192195

193196
metricsFlags = []cli.Flag{

cmd/bera-geth/snapshot.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,11 +639,11 @@ func snapshotExportPreimages(ctx *cli.Context) error {
639639

640640
var root common.Hash
641641
if ctx.NArg() > 1 {
642-
rootBytes := common.FromHex(ctx.Args().Get(1))
643-
if len(rootBytes) != common.HashLength {
642+
hash := ctx.Args().Get(1)
643+
if !common.IsHexHash(hash) {
644644
return fmt.Errorf("invalid hash: %s", ctx.Args().Get(1))
645645
}
646-
root = common.BytesToHash(rootBytes)
646+
root = common.HexToHash(hash)
647647
} else {
648648
headBlock := rawdb.ReadHeadBlock(chaindb)
649649
if headBlock == nil {

0 commit comments

Comments
 (0)