Skip to content

Commit 73b1d11

Browse files
Merge branch 'develop' of https://github.com/prysmaticlabs/prysm into broadcast-equivocating-blocks
2 parents 5c184fc + 92cf0bc commit 73b1d11

File tree

130 files changed

+1520
-848
lines changed

Some content is hidden

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

130 files changed

+1520
-848
lines changed

README.md

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,68 @@
1-
# Prysm: An Ethereum Consensus Implementation Written in Go
1+
<h1 align="left">Prysm: An Ethereum Consensus Implementation Written in Go</h1>
22

3+
<div align="left">
4+
35
[![Build status](https://badge.buildkite.com/b555891daf3614bae4284dcf365b2340cefc0089839526f096.svg?branch=master)](https://buildkite.com/prysmatic-labs/prysm)
46
[![Go Report Card](https://goreportcard.com/badge/github.com/prysmaticlabs/prysm)](https://goreportcard.com/report/github.com/prysmaticlabs/prysm)
57
[![Consensus_Spec_Version 1.4.0](https://img.shields.io/badge/Consensus%20Spec%20Version-v1.4.0-blue.svg)](https://github.com/ethereum/consensus-specs/tree/v1.4.0)
68
[![Execution_API_Version 1.0.0-beta.2](https://img.shields.io/badge/Execution%20API%20Version-v1.0.0.beta.2-blue.svg)](https://github.com/ethereum/execution-apis/tree/v1.0.0-beta.2/src/engine)
79
[![Discord](https://user-images.githubusercontent.com/7288322/34471967-1df7808a-efbb-11e7-9088-ed0b04151291.png)](https://discord.gg/prysmaticlabs)
810
[![GitPOAP Badge](https://public-api.gitpoap.io/v1/repo/prysmaticlabs/prysm/badge)](https://www.gitpoap.io/gh/prysmaticlabs/prysm)
911

10-
This is the core repository for Prysm, a [Golang](https://golang.org/) implementation of the [Ethereum Consensus](https://ethereum.org/en/developers/docs/consensus-mechanisms/#proof-of-stake) [specification](https://github.com/ethereum/consensus-specs), developed by [Offchain Labs](https://www.offchainlabs.com). See the [Changelog](https://github.com/prysmaticlabs/prysm/releases) for details of the latest releases and upcoming breaking changes.
12+
</div>
1113

12-
### Getting Started
14+
---
1315

14-
A detailed set of installation and usage instructions as well as breakdowns of each individual component are available in the [official documentation portal](https://docs.prylabs.network). If you still have questions, feel free to stop by our [Discord](https://discord.gg/prysmaticlabs).
16+
## 📖 Overview
1517

16-
### Staking on Mainnet
18+
This is the core repository for Prysm, a [Golang](https://golang.org/) implementation of the [Ethereum Consensus](https://ethereum.org/en/developers/docs/consensus-mechanisms/#proof-of-stake) [specification](https://github.com/ethereum/consensus-specs), developed by [Offchain Labs](https://www.offchainlabs.com).
1719

18-
To participate in staking, you can join the [official eth2 launchpad](https://launchpad.ethereum.org). The launchpad is the only recommended way to become a validator on mainnet. You can explore validator rewards/penalties via Bitfly's block explorer: [beaconcha.in](https://beaconcha.in), and follow the latest blocks added to the chain on [beaconscan](https://beaconscan.com).
20+
See the [Changelog](https://github.com/prysmaticlabs/prysm/releases) for details of the latest releases and upcoming breaking changes.
1921

22+
---
23+
24+
## 🚀 Getting Started
25+
26+
A detailed set of installation and usage instructions as well as breakdowns of each individual component are available in the **[official documentation portal](https://docs.prylabs.network)**.
27+
28+
💬 **Need help?** Join our **[Discord Community](https://discord.gg/prysmaticlabs)** for support.
29+
30+
---
31+
32+
## 🏆 Staking on Mainnet
33+
34+
To participate in staking, you can join the **[official Ethereum launchpad](https://launchpad.ethereum.org)**. The launchpad is the **only recommended** way to become a validator on mainnet.
35+
36+
🔍 Explore validator rewards/penalties:
37+
38+
- **[beaconcha.in](https://beaconcha.in)**
39+
- **[beaconscan](https://beaconscan.com)**
40+
41+
---
42+
43+
## 🤝 Contributing
44+
45+
### 🔥 Branches
2046

21-
## Contributing
22-
### Branches
2347
Prysm maintains two permanent branches:
2448

25-
* [master](https://github.com/prysmaticlabs/prysm/tree/master): This points to the latest stable release. It is ideal for most users.
26-
* [develop](https://github.com/prysmaticlabs/prysm/tree/develop): This is used for development, it contains the latest PRs. Developers should base their PRs on this branch.
49+
- **[`master`](https://github.com/prysmaticlabs/prysm/tree/master)** - This points to the latest stable release. It is ideal for most users.
50+
- **[`develop`](https://github.com/prysmaticlabs/prysm/tree/develop)** - This is used for development and contains the latest PRs. Developers should base their PRs on this branch.
51+
52+
### 🛠 Contribution Guide
53+
54+
Want to get involved? Check out our **[Contribution Guide](https://docs.prylabs.network/docs/contribute/contribution-guidelines/)** to learn more!
55+
56+
---
57+
58+
## 📜 License
2759

28-
### Guide
29-
Want to get involved? Check out our [Contribution Guide](https://docs.prylabs.network/docs/contribute/contribution-guidelines/) to learn more!
60+
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
3061

31-
## License
62+
This project is licensed under the **GNU General Public License v3.0**.
3263

33-
[GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html)
64+
---
3465

35-
## Legal Disclaimer
66+
## ⚖️ Legal Disclaimer
3667

37-
[Terms of Use](/TERMS_OF_SERVICE.md)
68+
📜 [Terms of Use](/TERMS_OF_SERVICE.md)

WORKSPACE

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ filegroup(
255255
url = "https://github.com/ethereum/EIPs/archive/5480440fe51742ed23342b68cf106cefd427e39d.tar.gz",
256256
)
257257

258-
consensus_spec_version = "v1.5.0-beta.3"
258+
consensus_spec_version = "v1.5.0-beta.4"
259259

260260
bls_test_version = "v0.1.1"
261261

@@ -271,7 +271,7 @@ filegroup(
271271
visibility = ["//visibility:public"],
272272
)
273273
""",
274-
integrity = "sha256-z+j0BEJuXMBKbGL+7jq35zddzZMW1je8/uvTz5+wboQ=",
274+
integrity = "sha256-QG0NUqaCvP5lKaKKwF/fmeICZVjONMlb7EE+MtYl0C0=",
275275
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/general.tar.gz" % consensus_spec_version,
276276
)
277277

@@ -287,7 +287,7 @@ filegroup(
287287
visibility = ["//visibility:public"],
288288
)
289289
""",
290-
integrity = "sha256-5/YUOXH65CmM1plZ8twJ3BQxwM51jgSpOB8/VSBI19k=",
290+
integrity = "sha256-8NQngTSSqzW/j3tOUi3r5h+94ChRbLNWTt7BOGqr4+E=",
291291
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/minimal.tar.gz" % consensus_spec_version,
292292
)
293293

@@ -303,7 +303,7 @@ filegroup(
303303
visibility = ["//visibility:public"],
304304
)
305305
""",
306-
integrity = "sha256-iZ2eNhwRnbxrjR+5gMBUYakaCXicvPChwFUkZtQUbbI=",
306+
integrity = "sha256-gFqxbaBnJ7dtdoj0zFbVrtlHv/bLNuWjrTHkyCAjFjI=",
307307
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/mainnet.tar.gz" % consensus_spec_version,
308308
)
309309

@@ -318,7 +318,7 @@ filegroup(
318318
visibility = ["//visibility:public"],
319319
)
320320
""",
321-
integrity = "sha256-inAXV7xNM5J1aUdP7JNXFO2iFFZ7dth38Ji+mJW50Ts=",
321+
integrity = "sha256-9paalF0POULpP2ga+4ouHSETKYrWNCUCZoJHPuFw06E=",
322322
strip_prefix = "consensus-specs-" + consensus_spec_version[1:],
323323
url = "https://github.com/ethereum/consensus-specs/archive/refs/tags/%s.tar.gz" % consensus_spec_version,
324324
)

api/apiutil/BUILD.bazel

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "go_default_library",
5+
srcs = ["common.go"],
6+
importpath = "github.com/prysmaticlabs/prysm/v5/api/apiutil",
7+
visibility = ["//visibility:public"],
8+
deps = ["//consensus-types/primitives:go_default_library"],
9+
)
10+
11+
go_test(
12+
name = "go_default_test",
13+
srcs = ["common_test.go"],
14+
embed = [":go_default_library"],
15+
deps = [
16+
"//consensus-types/primitives:go_default_library",
17+
"//testing/assert:go_default_library",
18+
],
19+
)

api/apiutil/common.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package apiutil
2+
3+
import (
4+
"fmt"
5+
neturl "net/url"
6+
"strconv"
7+
8+
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
9+
)
10+
11+
// Uint64ToString is a util function that will convert uints to string
12+
func Uint64ToString[T uint64 | primitives.Slot | primitives.ValidatorIndex | primitives.CommitteeIndex | primitives.Epoch](val T) string {
13+
return strconv.FormatUint(uint64(val), 10)
14+
}
15+
16+
// BuildURL is a util function that assists with adding query parameters to the url
17+
func BuildURL(path string, queryParams ...neturl.Values) string {
18+
if len(queryParams) == 0 {
19+
return path
20+
}
21+
22+
return fmt.Sprintf("%s?%s", path, queryParams[0].Encode())
23+
}

api/apiutil/common_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package apiutil
2+
3+
import (
4+
"net/url"
5+
"testing"
6+
7+
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
8+
"github.com/prysmaticlabs/prysm/v5/testing/assert"
9+
)
10+
11+
func TestBeaconApiHelpers_TestUint64ToString(t *testing.T) {
12+
const expectedResult = "1234"
13+
const val = uint64(1234)
14+
15+
assert.Equal(t, expectedResult, Uint64ToString(val))
16+
assert.Equal(t, expectedResult, Uint64ToString(primitives.Slot(val)))
17+
assert.Equal(t, expectedResult, Uint64ToString(primitives.ValidatorIndex(val)))
18+
assert.Equal(t, expectedResult, Uint64ToString(primitives.CommitteeIndex(val)))
19+
assert.Equal(t, expectedResult, Uint64ToString(primitives.Epoch(val)))
20+
}
21+
22+
func TestBuildURL_NoParams(t *testing.T) {
23+
wanted := "/aaa/bbb/ccc"
24+
actual := BuildURL("/aaa/bbb/ccc")
25+
assert.Equal(t, wanted, actual)
26+
}
27+
28+
func TestBuildURL_WithParams(t *testing.T) {
29+
params := url.Values{}
30+
params.Add("xxxx", "1")
31+
params.Add("yyyy", "2")
32+
params.Add("zzzz", "3")
33+
34+
wanted := "/aaa/bbb/ccc?xxxx=1&yyyy=2&zzzz=3"
35+
actual := BuildURL("/aaa/bbb/ccc", params)
36+
assert.Equal(t, wanted, actual)
37+
}

api/client/beacon/BUILD.bazel

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ go_library(
55
srcs = [
66
"client.go",
77
"doc.go",
8-
"health.go",
98
"log.go",
109
"template.go",
1110
],
1211
importpath = "github.com/prysmaticlabs/prysm/v5/api/client/beacon",
1312
visibility = ["//visibility:public"],
1413
deps = [
1514
"//api/client:go_default_library",
16-
"//api/client/beacon/iface:go_default_library",
1715
"//api/server:go_default_library",
1816
"//api/server/structs:go_default_library",
1917
"//consensus-types/primitives:go_default_library",
@@ -28,15 +26,10 @@ go_library(
2826

2927
go_test(
3028
name = "go_default_test",
31-
srcs = [
32-
"client_test.go",
33-
"health_test.go",
34-
],
29+
srcs = ["client_test.go"],
3530
embed = [":go_default_library"],
3631
deps = [
3732
"//api/client:go_default_library",
38-
"//api/client/beacon/testing:go_default_library",
3933
"//testing/require:go_default_library",
40-
"@org_uber_go_mock//gomock:go_default_library",
4134
],
4235
)

api/client/beacon/health/BUILD.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
2+
3+
go_library(
4+
name = "go_default_library",
5+
srcs = [
6+
"health.go",
7+
"interfaces.go",
8+
"mock.go",
9+
],
10+
importpath = "github.com/prysmaticlabs/prysm/v5/api/client/beacon/health",
11+
visibility = ["//visibility:public"],
12+
deps = ["@org_uber_go_mock//gomock:go_default_library"],
13+
)
14+
15+
go_test(
16+
name = "go_default_test",
17+
srcs = ["health_test.go"],
18+
embed = [":go_default_library"],
19+
deps = ["@org_uber_go_mock//gomock:go_default_library"],
20+
)

api/client/beacon/health.go renamed to api/client/beacon/health/health.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
package beacon
1+
package health
22

33
import (
44
"context"
55
"sync"
6-
7-
"github.com/prysmaticlabs/prysm/v5/api/client/beacon/iface"
86
)
97

108
type NodeHealthTracker struct {
119
isHealthy *bool
1210
healthChan chan bool
13-
node iface.HealthNode
11+
node Node
1412
sync.RWMutex
1513
}
1614

17-
func NewNodeHealthTracker(node iface.HealthNode) *NodeHealthTracker {
15+
func NewTracker(node Node) Tracker {
1816
return &NodeHealthTracker{
1917
node: node,
2018
healthChan: make(chan bool, 1),
@@ -26,7 +24,7 @@ func (n *NodeHealthTracker) HealthUpdates() <-chan bool {
2624
return n.healthChan
2725
}
2826

29-
func (n *NodeHealthTracker) IsHealthy() bool {
27+
func (n *NodeHealthTracker) IsHealthy(_ context.Context) bool {
3028
n.RLock()
3129
defer n.RUnlock()
3230
if n.isHealthy == nil {

api/client/beacon/health_test.go renamed to api/client/beacon/health/health_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
package beacon
1+
package health
22

33
import (
44
"context"
55
"sync"
66
"testing"
77

8-
healthTesting "github.com/prysmaticlabs/prysm/v5/api/client/beacon/testing"
98
"go.uber.org/mock/gomock"
109
)
1110

@@ -24,7 +23,7 @@ func TestNodeHealth_IsHealthy(t *testing.T) {
2423
isHealthy: &tt.isHealthy,
2524
healthChan: make(chan bool, 1),
2625
}
27-
if got := n.IsHealthy(); got != tt.want {
26+
if got := n.IsHealthy(context.Background()); got != tt.want {
2827
t.Errorf("IsHealthy() = %v, want %v", got, tt.want)
2928
}
3029
})
@@ -47,7 +46,7 @@ func TestNodeHealth_UpdateNodeHealth(t *testing.T) {
4746
t.Run(tt.name, func(t *testing.T) {
4847
ctrl := gomock.NewController(t)
4948
defer ctrl.Finish()
50-
client := healthTesting.NewMockHealthClient(ctrl)
49+
client := NewMockHealthClient(ctrl)
5150
client.EXPECT().IsHealthy(gomock.Any()).Return(tt.newStatus)
5251
n := &NodeHealthTracker{
5352
isHealthy: &tt.initial,
@@ -80,8 +79,8 @@ func TestNodeHealth_UpdateNodeHealth(t *testing.T) {
8079
func TestNodeHealth_Concurrency(t *testing.T) {
8180
ctrl := gomock.NewController(t)
8281
defer ctrl.Finish()
83-
client := healthTesting.NewMockHealthClient(ctrl)
84-
n := NewNodeHealthTracker(client)
82+
client := NewMockHealthClient(ctrl)
83+
n := NewTracker(client)
8584
var wg sync.WaitGroup
8685

8786
// Number of goroutines to spawn for both reading and writing
@@ -104,7 +103,7 @@ func TestNodeHealth_Concurrency(t *testing.T) {
104103
for i := 0; i < numGoroutines; i++ {
105104
go func() {
106105
defer wg.Done()
107-
_ = n.IsHealthy() // Just read the value
106+
_ = n.IsHealthy(context.Background()) // Just read the value
108107
}()
109108
}
110109

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package iface
1+
package health
22

33
import "context"
44

5-
type HealthTracker interface {
5+
type Tracker interface {
66
HealthUpdates() <-chan bool
7-
IsHealthy() bool
87
CheckHealth(ctx context.Context) bool
8+
Node
99
}
1010

11-
type HealthNode interface {
11+
type Node interface {
1212
IsHealthy(ctx context.Context) bool
1313
}

api/client/beacon/testing/mock.go renamed to api/client/beacon/health/mock.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
package testing
1+
package health
22

33
import (
44
"context"
55
"reflect"
66
"sync"
77

8-
"github.com/prysmaticlabs/prysm/v5/api/client/beacon/iface"
98
"go.uber.org/mock/gomock"
109
)
1110

1211
var (
13-
_ = iface.HealthNode(&MockHealthClient{})
12+
_ = Node(&MockHealthClient{})
1413
)
1514

1615
// MockHealthClient is a mock of HealthClient interface.

api/client/beacon/iface/BUILD.bazel

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)