mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Compare commits
21 Commits
fix-intero
...
increase_h
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32e1273546 | ||
|
|
7d750dbc40 | ||
|
|
ec8b67cb12 | ||
|
|
a817aa0a8d | ||
|
|
d76f55e97a | ||
|
|
2de21eb22f | ||
|
|
58b8c31c93 | ||
|
|
f343333880 | ||
|
|
8e0b1b7e1f | ||
|
|
65f71b3a48 | ||
|
|
9fcb9b86af | ||
|
|
aa63c4e7f2 | ||
|
|
d6ae838bbf | ||
|
|
d49afb370c | ||
|
|
4d3a6d84d2 | ||
|
|
9c5d16e161 | ||
|
|
4731304187 | ||
|
|
02cbcf8545 | ||
|
|
4e10734ae4 | ||
|
|
e19c99c3e2 | ||
|
|
697bcd418c |
6
.bazelrc
6
.bazelrc
@@ -6,6 +6,12 @@ import %workspace%/build/bazelrc/debug.bazelrc
|
||||
import %workspace%/build/bazelrc/hermetic-cc.bazelrc
|
||||
import %workspace%/build/bazelrc/performance.bazelrc
|
||||
|
||||
# hermetic_cc_toolchain v3.0.1 required changes.
|
||||
common --enable_platform_specific_config
|
||||
build:linux --sandbox_add_mount_pair=/tmp
|
||||
build:macos --sandbox_add_mount_pair=/var/tmp
|
||||
build:windows --sandbox_add_mount_pair=C:\Temp
|
||||
|
||||
# E2E run with debug gotag
|
||||
test:e2e --define gotags=debug
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
7.0.0
|
||||
7.1.0
|
||||
|
||||
821
MODULE.bazel.lock
generated
821
MODULE.bazel.lock
generated
File diff suppressed because it is too large
Load Diff
30
WORKSPACE
30
WORKSPACE
@@ -16,12 +16,14 @@ load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
|
||||
|
||||
rules_pkg_dependencies()
|
||||
|
||||
HERMETIC_CC_TOOLCHAIN_VERSION = "v3.0.1"
|
||||
|
||||
http_archive(
|
||||
name = "hermetic_cc_toolchain",
|
||||
sha256 = "973ab22945b921ef45b8e1d6ce01ca7ce1b8a462167449a36e297438c4ec2755",
|
||||
strip_prefix = "hermetic_cc_toolchain-5098046bccc15d2962f3cc8e7e53d6a2a26072dc",
|
||||
sha256 = "3bc6ec127622fdceb4129cb06b6f7ab098c4d539124dde96a6318e7c32a53f7a",
|
||||
urls = [
|
||||
"https://github.com/uber/hermetic_cc_toolchain/archive/5098046bccc15d2962f3cc8e7e53d6a2a26072dc.tar.gz", # 2023-06-28
|
||||
"https://mirror.bazel.build/github.com/uber/hermetic_cc_toolchain/releases/download/{0}/hermetic_cc_toolchain-{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION),
|
||||
"https://github.com/uber/hermetic_cc_toolchain/releases/download/{0}/hermetic_cc_toolchain-{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -81,10 +83,10 @@ bazel_skylib_workspace()
|
||||
|
||||
http_archive(
|
||||
name = "bazel_gazelle",
|
||||
sha256 = "d3fa66a39028e97d76f9e2db8f1b0c11c099e8e01bf363a923074784e451f809",
|
||||
integrity = "sha256-MpOL2hbmcABjA1R5Bj2dJMYO2o15/Uc5Vj9Q0zHLMgk=",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz",
|
||||
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz",
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
|
||||
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.35.0/bazel-gazelle-v0.35.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -151,17 +153,13 @@ http_archive(
|
||||
# Expose internals of go_test for custom build transitions.
|
||||
"//third_party:io_bazel_rules_go_test.patch",
|
||||
],
|
||||
sha256 = "d6ab6b57e48c09523e93050f13698f708428cfd5e619252e369d377af6597707",
|
||||
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.43.0/rules_go-v0.43.0.zip",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.43.0/rules_go-v0.43.0.zip",
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
|
||||
],
|
||||
)
|
||||
|
||||
load("//:distroless_deps.bzl", "distroless_deps")
|
||||
|
||||
distroless_deps()
|
||||
|
||||
# Override default import in rules_go with special patch until
|
||||
# https://github.com/gogo/protobuf/pull/582 is merged.
|
||||
git_repository(
|
||||
@@ -200,10 +198,14 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe
|
||||
go_rules_dependencies()
|
||||
|
||||
go_register_toolchains(
|
||||
go_version = "1.21.6",
|
||||
go_version = "1.21.8",
|
||||
nogo = "@//:nogo",
|
||||
)
|
||||
|
||||
load("//:distroless_deps.bzl", "distroless_deps")
|
||||
|
||||
distroless_deps()
|
||||
|
||||
http_archive(
|
||||
name = "io_kubernetes_build",
|
||||
sha256 = "b84fbd1173acee9d02a7d3698ad269fdf4f7aa081e9cecd40e012ad0ad8cfa2a",
|
||||
|
||||
@@ -6,12 +6,14 @@ go_library(
|
||||
"checkpoint.go",
|
||||
"client.go",
|
||||
"doc.go",
|
||||
"health.go",
|
||||
"log.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v5/api/client/beacon",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//api/client:go_default_library",
|
||||
"//api/client/beacon/iface:go_default_library",
|
||||
"//api/server:go_default_library",
|
||||
"//api/server/structs:go_default_library",
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
@@ -37,10 +39,12 @@ go_test(
|
||||
srcs = [
|
||||
"checkpoint_test.go",
|
||||
"client_test.go",
|
||||
"health_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//api/client:go_default_library",
|
||||
"//api/client/beacon/testing:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
@@ -54,5 +58,6 @@ go_test(
|
||||
"//testing/util:go_default_library",
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@org_uber_go_mock//gomock:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
55
api/client/beacon/health.go
Normal file
55
api/client/beacon/health.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package beacon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v5/api/client/beacon/iface"
|
||||
)
|
||||
|
||||
type NodeHealthTracker struct {
|
||||
isHealthy *bool
|
||||
healthChan chan bool
|
||||
node iface.HealthNode
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
func NewNodeHealthTracker(node iface.HealthNode) *NodeHealthTracker {
|
||||
return &NodeHealthTracker{
|
||||
node: node,
|
||||
healthChan: make(chan bool, 1),
|
||||
}
|
||||
}
|
||||
|
||||
// HealthUpdates provides a read-only channel for health updates.
|
||||
func (n *NodeHealthTracker) HealthUpdates() <-chan bool {
|
||||
return n.healthChan
|
||||
}
|
||||
|
||||
func (n *NodeHealthTracker) IsHealthy() bool {
|
||||
n.RLock()
|
||||
defer n.RUnlock()
|
||||
if n.isHealthy == nil {
|
||||
return false
|
||||
}
|
||||
return *n.isHealthy
|
||||
}
|
||||
|
||||
func (n *NodeHealthTracker) CheckHealth(ctx context.Context) bool {
|
||||
n.RLock()
|
||||
newStatus := n.node.IsHealthy(ctx)
|
||||
if n.isHealthy == nil {
|
||||
n.isHealthy = &newStatus
|
||||
}
|
||||
isStatusChanged := newStatus != *n.isHealthy
|
||||
n.RUnlock()
|
||||
|
||||
if isStatusChanged {
|
||||
n.Lock()
|
||||
// Double-check the condition to ensure it hasn't changed since the first check.
|
||||
n.isHealthy = &newStatus
|
||||
n.Unlock() // It's better to unlock as soon as the protected section is over.
|
||||
n.healthChan <- newStatus
|
||||
}
|
||||
return newStatus
|
||||
}
|
||||
118
api/client/beacon/health_test.go
Normal file
118
api/client/beacon/health_test.go
Normal file
@@ -0,0 +1,118 @@
|
||||
package beacon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
healthTesting "github.com/prysmaticlabs/prysm/v5/api/client/beacon/testing"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
func TestNodeHealth_IsHealthy(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
isHealthy bool
|
||||
want bool
|
||||
}{
|
||||
{"initially healthy", true, true},
|
||||
{"initially unhealthy", false, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
n := &NodeHealthTracker{
|
||||
isHealthy: &tt.isHealthy,
|
||||
healthChan: make(chan bool, 1),
|
||||
}
|
||||
if got := n.IsHealthy(); got != tt.want {
|
||||
t.Errorf("IsHealthy() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeHealth_UpdateNodeHealth(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
initial bool // Initial health status
|
||||
newStatus bool // Status to update to
|
||||
shouldSend bool // Should a message be sent through the channel
|
||||
}{
|
||||
{"healthy to unhealthy", true, false, true},
|
||||
{"unhealthy to healthy", false, true, true},
|
||||
{"remain healthy", true, true, false},
|
||||
{"remain unhealthy", false, false, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
client := healthTesting.NewMockHealthClient(ctrl)
|
||||
client.EXPECT().IsHealthy(gomock.Any()).Return(tt.newStatus)
|
||||
n := &NodeHealthTracker{
|
||||
isHealthy: &tt.initial,
|
||||
node: client,
|
||||
healthChan: make(chan bool, 1),
|
||||
}
|
||||
|
||||
s := n.CheckHealth(context.Background())
|
||||
// Check if health status was updated
|
||||
if s != tt.newStatus {
|
||||
t.Errorf("UpdateNodeHealth() failed to update isHealthy from %v to %v", tt.initial, tt.newStatus)
|
||||
}
|
||||
|
||||
select {
|
||||
case status := <-n.HealthUpdates():
|
||||
if !tt.shouldSend {
|
||||
t.Errorf("UpdateNodeHealth() unexpectedly sent status %v to HealthCh", status)
|
||||
} else if status != tt.newStatus {
|
||||
t.Errorf("UpdateNodeHealth() sent wrong status %v, want %v", status, tt.newStatus)
|
||||
}
|
||||
default:
|
||||
if tt.shouldSend {
|
||||
t.Error("UpdateNodeHealth() did not send any status to HealthCh when expected")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeHealth_Concurrency(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
client := healthTesting.NewMockHealthClient(ctrl)
|
||||
n := NewNodeHealthTracker(client)
|
||||
var wg sync.WaitGroup
|
||||
|
||||
// Number of goroutines to spawn for both reading and writing
|
||||
numGoroutines := 6
|
||||
|
||||
go func() {
|
||||
for range n.HealthUpdates() {
|
||||
// Consume values to avoid blocking on channel send.
|
||||
}
|
||||
}()
|
||||
|
||||
wg.Add(numGoroutines * 2) // for readers and writers
|
||||
|
||||
// Concurrently update health status
|
||||
for i := 0; i < numGoroutines; i++ {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
client.EXPECT().IsHealthy(gomock.Any()).Return(false)
|
||||
n.CheckHealth(context.Background())
|
||||
client.EXPECT().IsHealthy(gomock.Any()).Return(true)
|
||||
n.CheckHealth(context.Background())
|
||||
}()
|
||||
}
|
||||
|
||||
// Concurrently read health status
|
||||
for i := 0; i < numGoroutines; i++ {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
_ = n.IsHealthy() // Just read the value
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Wait() // Wait for all goroutines to finish
|
||||
}
|
||||
8
api/client/beacon/iface/BUILD.bazel
Normal file
8
api/client/beacon/iface/BUILD.bazel
Normal file
@@ -0,0 +1,8 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["health.go"],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v5/api/client/beacon/iface",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
13
api/client/beacon/iface/health.go
Normal file
13
api/client/beacon/iface/health.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package iface
|
||||
|
||||
import "context"
|
||||
|
||||
type HealthTracker interface {
|
||||
HealthUpdates() <-chan bool
|
||||
IsHealthy() bool
|
||||
CheckHealth(ctx context.Context) bool
|
||||
}
|
||||
|
||||
type HealthNode interface {
|
||||
IsHealthy(ctx context.Context) bool
|
||||
}
|
||||
12
api/client/beacon/testing/BUILD.bazel
Normal file
12
api/client/beacon/testing/BUILD.bazel
Normal file
@@ -0,0 +1,12 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["mock.go"],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v5/api/client/beacon/testing",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//api/client/beacon/iface:go_default_library",
|
||||
"@org_uber_go_mock//gomock:go_default_library",
|
||||
],
|
||||
)
|
||||
53
api/client/beacon/testing/mock.go
Normal file
53
api/client/beacon/testing/mock.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v5/api/client/beacon/iface"
|
||||
"go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
var (
|
||||
_ = iface.HealthNode(&MockHealthClient{})
|
||||
)
|
||||
|
||||
// MockHealthClient is a mock of HealthClient interface.
|
||||
type MockHealthClient struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockHealthClientMockRecorder
|
||||
}
|
||||
|
||||
// MockHealthClientMockRecorder is the mock recorder for MockHealthClient.
|
||||
type MockHealthClientMockRecorder struct {
|
||||
mock *MockHealthClient
|
||||
}
|
||||
|
||||
// IsHealthy mocks base method.
|
||||
func (m *MockHealthClient) IsHealthy(arg0 context.Context) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsHealthy", arg0)
|
||||
ret0, ok := ret[0].(bool)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return ret0
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockHealthClient) EXPECT() *MockHealthClientMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// IsHealthy indicates an expected call of IsHealthy.
|
||||
func (mr *MockHealthClientMockRecorder) IsHealthy(arg0 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsHealthy", reflect.TypeOf((*MockHealthClient)(nil).IsHealthy), arg0)
|
||||
}
|
||||
|
||||
// NewMockHealthClient creates a new mock instance.
|
||||
func NewMockHealthClient(ctrl *gomock.Controller) *MockHealthClient {
|
||||
mock := &MockHealthClient{ctrl: ctrl}
|
||||
mock.recorder = &MockHealthClientMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
@@ -304,6 +304,8 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS
|
||||
}
|
||||
versionOpt := func(r *http.Request) {
|
||||
r.Header.Add("Eth-Consensus-Version", version.String(version.Bellatrix))
|
||||
r.Header.Set("Content-Type", "application/json")
|
||||
r.Header.Set("Accept", "application/json")
|
||||
}
|
||||
rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt)
|
||||
|
||||
@@ -341,6 +343,8 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS
|
||||
}
|
||||
versionOpt := func(r *http.Request) {
|
||||
r.Header.Add("Eth-Consensus-Version", version.String(version.Capella))
|
||||
r.Header.Set("Content-Type", "application/json")
|
||||
r.Header.Set("Accept", "application/json")
|
||||
}
|
||||
rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt)
|
||||
|
||||
@@ -379,6 +383,8 @@ func (c *Client) SubmitBlindedBlock(ctx context.Context, sb interfaces.ReadOnlyS
|
||||
|
||||
versionOpt := func(r *http.Request) {
|
||||
r.Header.Add("Eth-Consensus-Version", version.String(version.Deneb))
|
||||
r.Header.Set("Content-Type", "application/json")
|
||||
r.Header.Set("Accept", "application/json")
|
||||
}
|
||||
rb, err := c.do(ctx, http.MethodPost, postBlindedBeaconBlockPath, bytes.NewBuffer(body), versionOpt)
|
||||
if err != nil {
|
||||
|
||||
@@ -321,6 +321,8 @@ func TestSubmitBlindedBlock(t *testing.T) {
|
||||
Transport: roundtrip(func(r *http.Request) (*http.Response, error) {
|
||||
require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path)
|
||||
require.Equal(t, "bellatrix", r.Header.Get("Eth-Consensus-Version"))
|
||||
require.Equal(t, "application/json", r.Header.Get("Content-Type"))
|
||||
require.Equal(t, "application/json", r.Header.Get("Accept"))
|
||||
return &http.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: io.NopCloser(bytes.NewBufferString(testExampleExecutionPayload)),
|
||||
@@ -347,6 +349,8 @@ func TestSubmitBlindedBlock(t *testing.T) {
|
||||
Transport: roundtrip(func(r *http.Request) (*http.Response, error) {
|
||||
require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path)
|
||||
require.Equal(t, "capella", r.Header.Get("Eth-Consensus-Version"))
|
||||
require.Equal(t, "application/json", r.Header.Get("Content-Type"))
|
||||
require.Equal(t, "application/json", r.Header.Get("Accept"))
|
||||
return &http.Response{
|
||||
StatusCode: http.StatusOK,
|
||||
Body: io.NopCloser(bytes.NewBufferString(testExampleExecutionPayloadCapella)),
|
||||
@@ -376,6 +380,8 @@ func TestSubmitBlindedBlock(t *testing.T) {
|
||||
Transport: roundtrip(func(r *http.Request) (*http.Response, error) {
|
||||
require.Equal(t, postBlindedBeaconBlockPath, r.URL.Path)
|
||||
require.Equal(t, "deneb", r.Header.Get("Eth-Consensus-Version"))
|
||||
require.Equal(t, "application/json", r.Header.Get("Content-Type"))
|
||||
require.Equal(t, "application/json", r.Header.Get("Accept"))
|
||||
var req structs.SignedBlindedBeaconBlockDeneb
|
||||
err := json.NewDecoder(r.Body).Decode(&req)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -21,6 +21,9 @@ var ErrNotFound = errors.Wrap(ErrNotOK, "recv 404 NotFound response from API")
|
||||
// ErrInvalidNodeVersion indicates that the /eth/v1/node/version API response format was not recognized.
|
||||
var ErrInvalidNodeVersion = errors.New("invalid node version response")
|
||||
|
||||
// ErrConnectionIssue represents a connection problem.
|
||||
var ErrConnectionIssue = errors.New("could not connect")
|
||||
|
||||
// Non200Err is a function that parses an HTTP response to handle responses that are not 200 with a formatted error.
|
||||
func Non200Err(response *http.Response) error {
|
||||
bodyBytes, err := io.ReadAll(response.Body)
|
||||
|
||||
24
api/client/event/BUILD.bazel
Normal file
24
api/client/event/BUILD.bazel
Normal file
@@ -0,0 +1,24 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["event_stream.go"],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v5/api/client/event",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//api:go_default_library",
|
||||
"//api/client:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["event_stream_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//testing/require:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
],
|
||||
)
|
||||
148
api/client/event/event_stream.go
Normal file
148
api/client/event/event_stream.go
Normal file
@@ -0,0 +1,148 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/api"
|
||||
"github.com/prysmaticlabs/prysm/v5/api/client"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
EventHead = "head"
|
||||
EventBlock = "block"
|
||||
EventAttestation = "attestation"
|
||||
EventVoluntaryExit = "voluntary_exit"
|
||||
EventBlsToExecutionChange = "bls_to_execution_change"
|
||||
EventProposerSlashing = "proposer_slashing"
|
||||
EventAttesterSlashing = "attester_slashing"
|
||||
EventFinalizedCheckpoint = "finalized_checkpoint"
|
||||
EventChainReorg = "chain_reorg"
|
||||
EventContributionAndProof = "contribution_and_proof"
|
||||
EventLightClientFinalityUpdate = "light_client_finality_update"
|
||||
EventLightClientOptimisticUpdate = "light_client_optimistic_update"
|
||||
EventPayloadAttributes = "payload_attributes"
|
||||
EventBlobSidecar = "blob_sidecar"
|
||||
EventError = "error"
|
||||
EventConnectionError = "connection_error"
|
||||
)
|
||||
|
||||
var (
|
||||
_ = EventStreamClient(&EventStream{})
|
||||
)
|
||||
|
||||
var DefaultEventTopics = []string{EventHead}
|
||||
|
||||
type EventStreamClient interface {
|
||||
Subscribe(eventsChannel chan<- *Event)
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
EventType string
|
||||
Data []byte
|
||||
}
|
||||
|
||||
// EventStream is responsible for subscribing to the Beacon API events endpoint
|
||||
// and dispatching received events to subscribers.
|
||||
type EventStream struct {
|
||||
ctx context.Context
|
||||
httpClient *http.Client
|
||||
host string
|
||||
topics []string
|
||||
}
|
||||
|
||||
func NewEventStream(ctx context.Context, httpClient *http.Client, host string, topics []string) (*EventStream, error) {
|
||||
// Check if the host is a valid URL
|
||||
_, err := url.ParseRequestURI(host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(topics) == 0 {
|
||||
return nil, errors.New("no topics provided")
|
||||
}
|
||||
|
||||
return &EventStream{
|
||||
ctx: ctx,
|
||||
httpClient: httpClient,
|
||||
host: host,
|
||||
topics: topics,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (h *EventStream) Subscribe(eventsChannel chan<- *Event) {
|
||||
allTopics := strings.Join(h.topics, ",")
|
||||
log.WithField("topics", allTopics).Info("Listening to Beacon API events")
|
||||
fullUrl := h.host + "/eth/v1/events?topics=" + allTopics
|
||||
req, err := http.NewRequestWithContext(h.ctx, http.MethodGet, fullUrl, nil)
|
||||
if err != nil {
|
||||
eventsChannel <- &Event{
|
||||
EventType: EventConnectionError,
|
||||
Data: []byte(errors.Wrap(err, "failed to create HTTP request").Error()),
|
||||
}
|
||||
}
|
||||
req.Header.Set("Accept", api.EventStreamMediaType)
|
||||
req.Header.Set("Connection", api.KeepAlive)
|
||||
resp, err := h.httpClient.Do(req)
|
||||
if err != nil {
|
||||
eventsChannel <- &Event{
|
||||
EventType: EventConnectionError,
|
||||
Data: []byte(errors.Wrap(err, client.ErrConnectionIssue.Error()).Error()),
|
||||
}
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if closeErr := resp.Body.Close(); closeErr != nil {
|
||||
log.WithError(closeErr).Error("Failed to close events response body")
|
||||
}
|
||||
}()
|
||||
// Create a new scanner to read lines from the response body
|
||||
scanner := bufio.NewScanner(resp.Body)
|
||||
|
||||
var eventType, data string // Variables to store event type and data
|
||||
|
||||
// Iterate over lines of the event stream
|
||||
for scanner.Scan() {
|
||||
select {
|
||||
case <-h.ctx.Done():
|
||||
log.Info("Context canceled, stopping event stream")
|
||||
close(eventsChannel)
|
||||
return
|
||||
default:
|
||||
line := scanner.Text() // TODO(13730): scanner does not handle /r and does not fully adhere to https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface
|
||||
// Handle the event based on your specific format
|
||||
if line == "" {
|
||||
// Empty line indicates the end of an event
|
||||
if eventType != "" && data != "" {
|
||||
// Process the event when both eventType and data are set
|
||||
eventsChannel <- &Event{EventType: eventType, Data: []byte(data)}
|
||||
}
|
||||
|
||||
// Reset eventType and data for the next event
|
||||
eventType, data = "", ""
|
||||
continue
|
||||
}
|
||||
et, ok := strings.CutPrefix(line, "event: ")
|
||||
if ok {
|
||||
// Extract event type from the "event" field
|
||||
eventType = et
|
||||
}
|
||||
d, ok := strings.CutPrefix(line, "data: ")
|
||||
if ok {
|
||||
// Extract data from the "data" field
|
||||
data = d
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
eventsChannel <- &Event{
|
||||
EventType: EventConnectionError,
|
||||
Data: []byte(errors.Wrap(err, errors.Wrap(client.ErrConnectionIssue, "scanner failed").Error()).Error()),
|
||||
}
|
||||
}
|
||||
}
|
||||
80
api/client/event/event_stream_test.go
Normal file
80
api/client/event/event_stream_test.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func TestNewEventStream(t *testing.T) {
|
||||
validURL := "http://localhost:8080"
|
||||
invalidURL := "://invalid"
|
||||
topics := []string{"topic1", "topic2"}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
host string
|
||||
topics []string
|
||||
wantErr bool
|
||||
}{
|
||||
{"Valid input", validURL, topics, false},
|
||||
{"Invalid URL", invalidURL, topics, true},
|
||||
{"No topics", validURL, []string{}, true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
_, err := NewEventStream(context.Background(), &http.Client{}, tt.host, tt.topics)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("NewEventStream() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventStream(t *testing.T) {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/eth/v1/events", func(w http.ResponseWriter, r *http.Request) {
|
||||
flusher, ok := w.(http.Flusher)
|
||||
require.Equal(t, true, ok)
|
||||
for i := 1; i <= 2; i++ {
|
||||
_, err := fmt.Fprintf(w, "event: head\ndata: data%d\n\n", i)
|
||||
require.NoError(t, err)
|
||||
flusher.Flush() // Trigger flush to simulate streaming data
|
||||
time.Sleep(100 * time.Millisecond) // Simulate delay between events
|
||||
}
|
||||
})
|
||||
server := httptest.NewServer(mux)
|
||||
defer server.Close()
|
||||
|
||||
topics := []string{"head"}
|
||||
eventsChannel := make(chan *Event, 1)
|
||||
stream, err := NewEventStream(context.Background(), http.DefaultClient, server.URL, topics)
|
||||
require.NoError(t, err)
|
||||
go stream.Subscribe(eventsChannel)
|
||||
|
||||
// Collect events
|
||||
var events []*Event
|
||||
|
||||
for len(events) != 2 {
|
||||
select {
|
||||
case event := <-eventsChannel:
|
||||
log.Info(event)
|
||||
events = append(events, event)
|
||||
}
|
||||
}
|
||||
|
||||
// Assertions to verify the events content
|
||||
expectedData := []string{"data1", "data2"}
|
||||
for i, event := range events {
|
||||
if string(event.Data) != expectedData[i] {
|
||||
t.Errorf("Expected event data %q, got %q", expectedData[i], string(event.Data))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -563,3 +563,9 @@ func (s *Service) RecentBlockSlot(root [32]byte) (primitives.Slot, error) {
|
||||
func (s *Service) inRegularSync() bool {
|
||||
return s.cfg.SyncChecker.Synced()
|
||||
}
|
||||
|
||||
// validating returns true if the beacon is tracking some validators that have
|
||||
// registered for proposing.
|
||||
func (s *Service) validating() bool {
|
||||
return s.cfg.TrackedValidatorsCache.Validating()
|
||||
}
|
||||
|
||||
@@ -18,17 +18,63 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/time/slots"
|
||||
)
|
||||
|
||||
func (s *Service) getRecentPreState(ctx context.Context, c *ethpb.Checkpoint) state.ReadOnlyBeaconState {
|
||||
headEpoch := slots.ToEpoch(s.HeadSlot())
|
||||
if c.Epoch < headEpoch {
|
||||
return nil
|
||||
}
|
||||
if !s.cfg.ForkChoiceStore.IsCanonical([32]byte(c.Root)) {
|
||||
return nil
|
||||
}
|
||||
if c.Epoch == headEpoch {
|
||||
targetSlot, err := s.cfg.ForkChoiceStore.Slot([32]byte(c.Root))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if slots.ToEpoch(targetSlot)+1 < headEpoch {
|
||||
return nil
|
||||
}
|
||||
st, err := s.HeadStateReadOnly(ctx)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return st
|
||||
}
|
||||
slot, err := slots.EpochStart(c.Epoch)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
// Try if we have already set the checkpoint cache
|
||||
epochKey := strconv.FormatUint(uint64(c.Epoch), 10 /* base 10 */)
|
||||
lock := async.NewMultilock(string(c.Root) + epochKey)
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
cachedState, err := s.checkpointStateCache.StateByCheckpoint(c)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if cachedState != nil && !cachedState.IsNil() {
|
||||
return cachedState
|
||||
}
|
||||
st, err := s.HeadState(ctx)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
st, err = transition.ProcessSlotsUsingNextSlotCache(ctx, st, c.Root, slot)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if err := s.checkpointStateCache.AddCheckpointState(c, st); err != nil {
|
||||
return nil
|
||||
}
|
||||
return st
|
||||
}
|
||||
|
||||
// getAttPreState retrieves the att pre state by either from the cache or the DB.
|
||||
func (s *Service) getAttPreState(ctx context.Context, c *ethpb.Checkpoint) (state.ReadOnlyBeaconState, error) {
|
||||
// If the attestation is recent and canonical we can use the head state to compute the shuffling.
|
||||
headEpoch := slots.ToEpoch(s.HeadSlot())
|
||||
if c.Epoch == headEpoch {
|
||||
targetSlot, err := s.cfg.ForkChoiceStore.Slot([32]byte(c.Root))
|
||||
if err == nil && slots.ToEpoch(targetSlot)+1 >= headEpoch {
|
||||
if s.cfg.ForkChoiceStore.IsCanonical([32]byte(c.Root)) {
|
||||
return s.HeadStateReadOnly(ctx)
|
||||
}
|
||||
}
|
||||
if st := s.getRecentPreState(ctx, c); st != nil {
|
||||
return st, nil
|
||||
}
|
||||
// Use a multilock to allow scoped holding of a mutex by a checkpoint root + epoch
|
||||
// allowing us to behave smarter in terms of how this function is used concurrently.
|
||||
|
||||
@@ -146,6 +146,28 @@ func TestStore_OnAttestation_Ok_DoublyLinkedTree(t *testing.T) {
|
||||
require.NoError(t, service.OnAttestation(ctx, att[0], 0))
|
||||
}
|
||||
|
||||
func TestService_GetRecentPreState(t *testing.T) {
|
||||
service, _ := minimalTestService(t)
|
||||
ctx := context.Background()
|
||||
|
||||
s, err := util.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
ckRoot := bytesutil.PadTo([]byte{'A'}, fieldparams.RootLength)
|
||||
cp0 := ðpb.Checkpoint{Epoch: 0, Root: ckRoot}
|
||||
err = s.SetFinalizedCheckpoint(cp0)
|
||||
require.NoError(t, err)
|
||||
|
||||
st, root, err := prepareForkchoiceState(ctx, 31, [32]byte(ckRoot), [32]byte{}, [32]byte{'R'}, cp0, cp0)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, service.cfg.ForkChoiceStore.InsertNode(ctx, st, root))
|
||||
service.head = &head{
|
||||
root: [32]byte(ckRoot),
|
||||
state: s,
|
||||
slot: 31,
|
||||
}
|
||||
require.NotNil(t, service.getRecentPreState(ctx, ðpb.Checkpoint{Epoch: 1, Root: ckRoot}))
|
||||
}
|
||||
|
||||
func TestService_GetAttPreState_Concurrency(t *testing.T) {
|
||||
service, _ := minimalTestService(t)
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -95,7 +95,9 @@ func (s *Service) spawnProcessAttestationsRoutine() {
|
||||
return
|
||||
case slotInterval := <-ticker.C():
|
||||
if slotInterval.Interval > 0 {
|
||||
s.UpdateHead(s.ctx, slotInterval.Slot+1)
|
||||
if s.validating() {
|
||||
s.UpdateHead(s.ctx, slotInterval.Slot+1)
|
||||
}
|
||||
} else {
|
||||
s.cfg.ForkChoiceStore.Lock()
|
||||
if err := s.cfg.ForkChoiceStore.NewSlot(s.ctx, slotInterval.Slot); err != nil {
|
||||
|
||||
8
beacon-chain/cache/skip_slot_cache.go
vendored
8
beacon-chain/cache/skip_slot_cache.go
vendored
@@ -109,10 +109,6 @@ func (c *SkipSlotCache) Get(ctx context.Context, r [32]byte) (state.BeaconState,
|
||||
// MarkInProgress a request so that any other similar requests will block on
|
||||
// Get until MarkNotInProgress is called.
|
||||
func (c *SkipSlotCache) MarkInProgress(r [32]byte) error {
|
||||
if c.disabled {
|
||||
return nil
|
||||
}
|
||||
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
@@ -126,10 +122,6 @@ func (c *SkipSlotCache) MarkInProgress(r [32]byte) error {
|
||||
// MarkNotInProgress will release the lock on a given request. This should be
|
||||
// called after put.
|
||||
func (c *SkipSlotCache) MarkNotInProgress(r [32]byte) {
|
||||
if c.disabled {
|
||||
return
|
||||
}
|
||||
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
|
||||
26
beacon-chain/cache/skip_slot_cache_test.go
vendored
26
beacon-chain/cache/skip_slot_cache_test.go
vendored
@@ -2,6 +2,7 @@ package cache_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/cache"
|
||||
@@ -35,3 +36,28 @@ func TestSkipSlotCache_RoundTrip(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, res.ToProto(), s.ToProto(), "Expected equal protos to return from cache")
|
||||
}
|
||||
|
||||
func TestSkipSlotCache_DisabledAndEnabled(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
c := cache.NewSkipSlotCache()
|
||||
|
||||
r := [32]byte{'a'}
|
||||
c.Disable()
|
||||
|
||||
require.NoError(t, c.MarkInProgress(r))
|
||||
|
||||
c.Enable()
|
||||
wg := new(sync.WaitGroup)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
// Get call will only terminate when
|
||||
// it is not longer in progress.
|
||||
obj, err := c.Get(ctx, r)
|
||||
require.NoError(t, err)
|
||||
require.IsNil(t, obj)
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
c.MarkNotInProgress(r)
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
6
beacon-chain/cache/tracked_validators.go
vendored
6
beacon-chain/cache/tracked_validators.go
vendored
@@ -41,3 +41,9 @@ func (t *TrackedValidatorsCache) Prune() {
|
||||
defer t.Unlock()
|
||||
t.trackedValidators = make(map[primitives.ValidatorIndex]TrackedValidator)
|
||||
}
|
||||
|
||||
func (t *TrackedValidatorsCache) Validating() bool {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
return len(t.trackedValidators) > 0
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ go_library(
|
||||
visibility = [
|
||||
"//beacon-chain:__subpackages__",
|
||||
"//testing/spectest:__subpackages__",
|
||||
"//tools:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
|
||||
@@ -201,21 +201,20 @@ func (s *Store) BackfillFinalizedIndex(ctx context.Context, blocks []blocks.ROBl
|
||||
return err
|
||||
}
|
||||
encs[i-1] = penc
|
||||
|
||||
// The final element is the parent of finalizedChildRoot. This is checked inside the db transaction using
|
||||
// the parent_root value stored in the index data for finalizedChildRoot.
|
||||
if i == len(blocks)-1 {
|
||||
fbrs[i].ChildRoot = finalizedChildRoot[:]
|
||||
// Final element is complete, so it is pre-encoded like the others.
|
||||
enc, err := encode(ctx, fbrs[i])
|
||||
if err != nil {
|
||||
tracing.AnnotateError(span, err)
|
||||
return err
|
||||
}
|
||||
encs[i] = enc
|
||||
}
|
||||
}
|
||||
|
||||
// The final element is the parent of finalizedChildRoot. This is checked inside the db transaction using
|
||||
// the parent_root value stored in the index data for finalizedChildRoot.
|
||||
lastIdx := len(blocks) - 1
|
||||
fbrs[lastIdx].ChildRoot = finalizedChildRoot[:]
|
||||
// Final element is complete, so it is pre-encoded like the others.
|
||||
enc, err := encode(ctx, fbrs[lastIdx])
|
||||
if err != nil {
|
||||
tracing.AnnotateError(span, err)
|
||||
return err
|
||||
}
|
||||
encs[lastIdx] = enc
|
||||
|
||||
return s.db.Update(func(tx *bolt.Tx) error {
|
||||
bkt := tx.Bucket(finalizedBlockRootsIndexBucket)
|
||||
child := bkt.Get(finalizedChildRoot[:])
|
||||
|
||||
@@ -237,6 +237,50 @@ func makeBlocksAltair(t *testing.T, startIdx, num uint64, previousRoot [32]byte)
|
||||
return ifaceBlocks
|
||||
}
|
||||
|
||||
func TestStore_BackfillFinalizedIndexSingle(t *testing.T) {
|
||||
db := setupDB(t)
|
||||
ctx := context.Background()
|
||||
// we're making 4 blocks so we can test an element without a valid child at the end
|
||||
blks, err := consensusblocks.NewROBlockSlice(makeBlocks(t, 0, 4, [32]byte{}))
|
||||
require.NoError(t, err)
|
||||
|
||||
// existing is the child that we'll set up in the index by hand to seed the index.
|
||||
existing := blks[3]
|
||||
|
||||
// toUpdate is a single item update, emulating a backfill batch size of 1. it is the parent of `existing`.
|
||||
toUpdate := blks[2]
|
||||
|
||||
// set up existing finalized block
|
||||
ebpr := existing.Block().ParentRoot()
|
||||
ebr := existing.Root()
|
||||
ebf := ðpb.FinalizedBlockRootContainer{
|
||||
ParentRoot: ebpr[:],
|
||||
ChildRoot: make([]byte, 32), // we're bypassing validation to seed the db, so we don't need a valid child.
|
||||
}
|
||||
enc, err := encode(ctx, ebf)
|
||||
require.NoError(t, err)
|
||||
// writing this to the index outside of the validating function to seed the test.
|
||||
err = db.db.Update(func(tx *bolt.Tx) error {
|
||||
bkt := tx.Bucket(finalizedBlockRootsIndexBucket)
|
||||
return bkt.Put(ebr[:], enc)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, db.BackfillFinalizedIndex(ctx, []consensusblocks.ROBlock{toUpdate}, ebr))
|
||||
|
||||
// make sure that we still correctly validate descendents in the single item case.
|
||||
noChild := blks[0] // will fail to update because we don't have blks[1] in the db.
|
||||
// test wrong child param
|
||||
require.ErrorIs(t, db.BackfillFinalizedIndex(ctx, []consensusblocks.ROBlock{noChild}, ebr), errNotConnectedToFinalized)
|
||||
// test parent of child that isn't finalized
|
||||
require.ErrorIs(t, db.BackfillFinalizedIndex(ctx, []consensusblocks.ROBlock{noChild}, blks[1].Root()), errFinalizedChildNotFound)
|
||||
|
||||
// now make it work by writing the missing block
|
||||
require.NoError(t, db.BackfillFinalizedIndex(ctx, []consensusblocks.ROBlock{blks[1]}, blks[2].Root()))
|
||||
// since blks[1] is now in the index, we should be able to update blks[0]
|
||||
require.NoError(t, db.BackfillFinalizedIndex(ctx, []consensusblocks.ROBlock{blks[0]}, blks[1].Root()))
|
||||
}
|
||||
|
||||
func TestStore_BackfillFinalizedIndex(t *testing.T) {
|
||||
db := setupDB(t)
|
||||
ctx := context.Background()
|
||||
@@ -252,23 +296,23 @@ func TestStore_BackfillFinalizedIndex(t *testing.T) {
|
||||
ParentRoot: ebpr[:],
|
||||
ChildRoot: chldr[:],
|
||||
}
|
||||
disjoint := []consensusblocks.ROBlock{
|
||||
blks[0],
|
||||
blks[2],
|
||||
}
|
||||
enc, err := encode(ctx, ebf)
|
||||
require.NoError(t, err)
|
||||
err = db.db.Update(func(tx *bolt.Tx) error {
|
||||
bkt := tx.Bucket(finalizedBlockRootsIndexBucket)
|
||||
return bkt.Put(ebr[:], enc)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// reslice to remove the existing blocks
|
||||
blks = blks[0:64]
|
||||
// check the other error conditions with a descendent root that really doesn't exist
|
||||
require.NoError(t, err)
|
||||
|
||||
disjoint := []consensusblocks.ROBlock{
|
||||
blks[0],
|
||||
blks[2],
|
||||
}
|
||||
require.ErrorIs(t, db.BackfillFinalizedIndex(ctx, disjoint, [32]byte{}), errIncorrectBlockParent)
|
||||
require.NoError(t, err)
|
||||
require.ErrorIs(t, errFinalizedChildNotFound, db.BackfillFinalizedIndex(ctx, blks, [32]byte{}))
|
||||
|
||||
// use the real root so that it succeeds
|
||||
|
||||
@@ -7,9 +7,11 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
@@ -127,51 +129,16 @@ type BeaconNode struct {
|
||||
// New creates a new node instance, sets up configuration options, and registers
|
||||
// every required service to the node.
|
||||
func New(cliCtx *cli.Context, cancel context.CancelFunc, opts ...Option) (*BeaconNode, error) {
|
||||
if err := configureTracing(cliCtx); err != nil {
|
||||
return nil, err
|
||||
if err := configureBeacon(cliCtx); err != nil {
|
||||
return nil, errors.Wrap(err, "could not set beacon configuration options")
|
||||
}
|
||||
prereqs.WarnIfPlatformNotSupported(cliCtx.Context)
|
||||
if hasNetworkFlag(cliCtx) && cliCtx.IsSet(cmd.ChainConfigFileFlag.Name) {
|
||||
return nil, fmt.Errorf("%s cannot be passed concurrently with network flag", cmd.ChainConfigFileFlag.Name)
|
||||
}
|
||||
if err := features.ConfigureBeaconChain(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := cmd.ConfigureBeaconChain(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
flags.ConfigureGlobalFlags(cliCtx)
|
||||
if err := configureChainConfig(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := configureHistoricalSlasher(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err := configureBuilderCircuitBreaker(cliCtx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := configureSlotsPerArchivedPoint(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := configureEth1Config(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
configureNetwork(cliCtx)
|
||||
if err := configureInteropConfig(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := configureExecutionSetting(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
configureFastSSZHashingAlgorithm()
|
||||
|
||||
// Initializes any forks here.
|
||||
params.BeaconConfig().InitializeForkSchedule()
|
||||
|
||||
registry := runtime.NewServiceRegistry()
|
||||
|
||||
ctx := cliCtx.Context
|
||||
|
||||
beacon := &BeaconNode{
|
||||
cliCtx: cliCtx,
|
||||
ctx: ctx,
|
||||
@@ -191,10 +158,10 @@ func New(cliCtx *cli.Context, cancel context.CancelFunc, opts ...Option) (*Beaco
|
||||
slasherBlockHeadersFeed: new(event.Feed),
|
||||
slasherAttestationsFeed: new(event.Feed),
|
||||
serviceFlagOpts: &serviceFlagOpts{},
|
||||
initialSyncComplete: make(chan struct{}),
|
||||
syncChecker: &initialsync.SyncChecker{},
|
||||
}
|
||||
|
||||
beacon.initialSyncComplete = make(chan struct{})
|
||||
beacon.syncChecker = &initialsync.SyncChecker{}
|
||||
for _, opt := range opts {
|
||||
if err := opt(beacon); err != nil {
|
||||
return nil, err
|
||||
@@ -203,8 +170,8 @@ func New(cliCtx *cli.Context, cancel context.CancelFunc, opts ...Option) (*Beaco
|
||||
|
||||
synchronizer := startup.NewClockSynchronizer()
|
||||
beacon.clockWaiter = synchronizer
|
||||
|
||||
beacon.forkChoicer = doublylinkedtree.New()
|
||||
|
||||
depositAddress, err := execution.DepositContractAddress()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -220,112 +187,29 @@ func New(cliCtx *cli.Context, cancel context.CancelFunc, opts ...Option) (*Beaco
|
||||
beacon.BlobStorage = blobs
|
||||
}
|
||||
|
||||
log.Debugln("Starting DB")
|
||||
if err := beacon.startDB(cliCtx, depositAddress); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
beacon.BlobStorage.WarmCache()
|
||||
|
||||
log.Debugln("Starting Slashing DB")
|
||||
if err := beacon.startSlasherDB(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugln("Registering P2P Service")
|
||||
if err := beacon.registerP2P(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bfs, err := backfill.NewUpdater(ctx, beacon.db)
|
||||
bfs, err := startBaseServices(cliCtx, beacon, depositAddress)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "backfill status initialization error")
|
||||
}
|
||||
|
||||
log.Debugln("Starting State Gen")
|
||||
if err := beacon.startStateGen(ctx, bfs, beacon.forkChoicer); err != nil {
|
||||
if errors.Is(err, stategen.ErrNoGenesisBlock) {
|
||||
log.Errorf("No genesis block/state is found. Prysm only provides a mainnet genesis "+
|
||||
"state bundled in the application. You must provide the --%s or --%s flag to load "+
|
||||
"a genesis block/state for this network.", "genesis-state", "genesis-beacon-api-url")
|
||||
}
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "could not start modules")
|
||||
}
|
||||
|
||||
beacon.verifyInitWaiter = verification.NewInitializerWaiter(
|
||||
beacon.clockWaiter, forkchoice.NewROForkChoice(beacon.forkChoicer), beacon.stateGen)
|
||||
|
||||
pa := peers.NewAssigner(beacon.fetchP2P().Peers(), beacon.forkChoicer)
|
||||
beacon.BackfillOpts = append(beacon.BackfillOpts, backfill.WithVerifierWaiter(beacon.verifyInitWaiter),
|
||||
backfill.WithInitSyncWaiter(initSyncWaiter(ctx, beacon.initialSyncComplete)))
|
||||
|
||||
beacon.BackfillOpts = append(
|
||||
beacon.BackfillOpts,
|
||||
backfill.WithVerifierWaiter(beacon.verifyInitWaiter),
|
||||
backfill.WithInitSyncWaiter(initSyncWaiter(ctx, beacon.initialSyncComplete)),
|
||||
)
|
||||
|
||||
bf, err := backfill.NewService(ctx, bfs, beacon.BlobStorage, beacon.clockWaiter, beacon.fetchP2P(), pa, beacon.BackfillOpts...)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error initializing backfill service")
|
||||
}
|
||||
if err := beacon.services.RegisterService(bf); err != nil {
|
||||
return nil, errors.Wrap(err, "error registering backfill service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering POW Chain Service")
|
||||
if err := beacon.registerPOWChainService(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugln("Registering Attestation Pool Service")
|
||||
if err := beacon.registerAttestationPool(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugln("Registering Deterministic Genesis Service")
|
||||
if err := beacon.registerDeterministicGenesisService(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugln("Registering Blockchain Service")
|
||||
if err := beacon.registerBlockchainService(beacon.forkChoicer, synchronizer, beacon.initialSyncComplete); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugln("Registering Initial Sync Service")
|
||||
if err := beacon.registerInitialSyncService(beacon.initialSyncComplete); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugln("Registering Sync Service")
|
||||
if err := beacon.registerSyncService(beacon.initialSyncComplete, bfs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugln("Registering Slasher Service")
|
||||
if err := beacon.registerSlasherService(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugln("Registering builder service")
|
||||
if err := beacon.registerBuilderService(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugln("Registering RPC Service")
|
||||
router := newRouter(cliCtx)
|
||||
if err := beacon.registerRPCService(router); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugln("Registering GRPC Gateway Service")
|
||||
if err := beacon.registerGRPCGateway(router); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugln("Registering Validator Monitoring Service")
|
||||
if err := beacon.registerValidatorMonitorService(beacon.initialSyncComplete); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !cliCtx.Bool(cmd.DisableMonitoringFlag.Name) {
|
||||
log.Debugln("Registering Prometheus Service")
|
||||
if err := beacon.registerPrometheusService(cliCtx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := registerServices(cliCtx, beacon, synchronizer, bf, bfs); err != nil {
|
||||
return nil, errors.Wrap(err, "could not register services")
|
||||
}
|
||||
|
||||
// db.DatabasePath is the path to the containing directory
|
||||
@@ -343,6 +227,170 @@ func New(cliCtx *cli.Context, cancel context.CancelFunc, opts ...Option) (*Beaco
|
||||
|
||||
return beacon, nil
|
||||
}
|
||||
|
||||
func configureBeacon(cliCtx *cli.Context) error {
|
||||
if err := configureTracing(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not configure tracing")
|
||||
}
|
||||
|
||||
prereqs.WarnIfPlatformNotSupported(cliCtx.Context)
|
||||
|
||||
if hasNetworkFlag(cliCtx) && cliCtx.IsSet(cmd.ChainConfigFileFlag.Name) {
|
||||
return fmt.Errorf("%s cannot be passed concurrently with network flag", cmd.ChainConfigFileFlag.Name)
|
||||
}
|
||||
|
||||
if err := features.ConfigureBeaconChain(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not configure beacon chain")
|
||||
}
|
||||
|
||||
if err := cmd.ConfigureBeaconChain(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not configure beacon chain")
|
||||
}
|
||||
|
||||
flags.ConfigureGlobalFlags(cliCtx)
|
||||
|
||||
if err := configureChainConfig(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not configure chain config")
|
||||
}
|
||||
|
||||
if err := configureHistoricalSlasher(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not configure historical slasher")
|
||||
}
|
||||
|
||||
if err := configureBuilderCircuitBreaker(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not configure builder circuit breaker")
|
||||
}
|
||||
|
||||
if err := configureSlotsPerArchivedPoint(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not configure slots per archived point")
|
||||
}
|
||||
|
||||
if err := configureEth1Config(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not configure eth1 config")
|
||||
}
|
||||
|
||||
configureNetwork(cliCtx)
|
||||
|
||||
if err := configureInteropConfig(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not configure interop config")
|
||||
}
|
||||
|
||||
if err := configureExecutionSetting(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not configure execution setting")
|
||||
}
|
||||
|
||||
configureFastSSZHashingAlgorithm()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func startBaseServices(cliCtx *cli.Context, beacon *BeaconNode, depositAddress string) (*backfill.Store, error) {
|
||||
ctx := cliCtx.Context
|
||||
log.Debugln("Starting DB")
|
||||
if err := beacon.startDB(cliCtx, depositAddress); err != nil {
|
||||
return nil, errors.Wrap(err, "could not start DB")
|
||||
}
|
||||
beacon.BlobStorage.WarmCache()
|
||||
|
||||
log.Debugln("Starting Slashing DB")
|
||||
if err := beacon.startSlasherDB(cliCtx); err != nil {
|
||||
return nil, errors.Wrap(err, "could not start slashing DB")
|
||||
}
|
||||
|
||||
log.Debugln("Registering P2P Service")
|
||||
if err := beacon.registerP2P(cliCtx); err != nil {
|
||||
return nil, errors.Wrap(err, "could not register P2P service")
|
||||
}
|
||||
|
||||
bfs, err := backfill.NewUpdater(ctx, beacon.db)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not create backfill updater")
|
||||
}
|
||||
|
||||
log.Debugln("Starting State Gen")
|
||||
if err := beacon.startStateGen(ctx, bfs, beacon.forkChoicer); err != nil {
|
||||
if errors.Is(err, stategen.ErrNoGenesisBlock) {
|
||||
log.Errorf("No genesis block/state is found. Prysm only provides a mainnet genesis "+
|
||||
"state bundled in the application. You must provide the --%s or --%s flag to load "+
|
||||
"a genesis block/state for this network.", "genesis-state", "genesis-beacon-api-url")
|
||||
}
|
||||
return nil, errors.Wrap(err, "could not start state generation")
|
||||
}
|
||||
|
||||
return bfs, nil
|
||||
}
|
||||
|
||||
func registerServices(cliCtx *cli.Context, beacon *BeaconNode, synchronizer *startup.ClockSynchronizer, bf *backfill.Service, bfs *backfill.Store) error {
|
||||
if err := beacon.services.RegisterService(bf); err != nil {
|
||||
return errors.Wrap(err, "could not register backfill service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering POW Chain Service")
|
||||
if err := beacon.registerPOWChainService(); err != nil {
|
||||
return errors.Wrap(err, "could not register POW chain service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering Attestation Pool Service")
|
||||
if err := beacon.registerAttestationPool(); err != nil {
|
||||
return errors.Wrap(err, "could not register attestation pool service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering Deterministic Genesis Service")
|
||||
if err := beacon.registerDeterministicGenesisService(); err != nil {
|
||||
return errors.Wrap(err, "could not register deterministic genesis service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering Blockchain Service")
|
||||
if err := beacon.registerBlockchainService(beacon.forkChoicer, synchronizer, beacon.initialSyncComplete); err != nil {
|
||||
return errors.Wrap(err, "could not register blockchain service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering Initial Sync Service")
|
||||
if err := beacon.registerInitialSyncService(beacon.initialSyncComplete); err != nil {
|
||||
return errors.Wrap(err, "could not register initial sync service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering Sync Service")
|
||||
if err := beacon.registerSyncService(beacon.initialSyncComplete, bfs); err != nil {
|
||||
return errors.Wrap(err, "could not register sync service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering Slasher Service")
|
||||
if err := beacon.registerSlasherService(); err != nil {
|
||||
return errors.Wrap(err, "could not register slasher service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering builder service")
|
||||
if err := beacon.registerBuilderService(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not register builder service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering RPC Service")
|
||||
router := newRouter(cliCtx)
|
||||
if err := beacon.registerRPCService(router); err != nil {
|
||||
return errors.Wrap(err, "could not register RPC service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering GRPC Gateway Service")
|
||||
if err := beacon.registerGRPCGateway(router); err != nil {
|
||||
return errors.Wrap(err, "could not register GRPC gateway service")
|
||||
}
|
||||
|
||||
log.Debugln("Registering Validator Monitoring Service")
|
||||
if err := beacon.registerValidatorMonitorService(beacon.initialSyncComplete); err != nil {
|
||||
return errors.Wrap(err, "could not register validator monitoring service")
|
||||
}
|
||||
|
||||
if !cliCtx.Bool(cmd.DisableMonitoringFlag.Name) {
|
||||
log.Debugln("Registering Prometheus Service")
|
||||
if err := beacon.registerPrometheusService(cliCtx); err != nil {
|
||||
return errors.Wrap(err, "could not register prometheus service")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func initSyncWaiter(ctx context.Context, complete chan struct{}) func() error {
|
||||
return func() error {
|
||||
select {
|
||||
@@ -431,40 +479,86 @@ func (b *BeaconNode) Close() {
|
||||
close(b.stop)
|
||||
}
|
||||
|
||||
func (b *BeaconNode) clearDB(clearDB, forceClearDB bool, d *kv.Store, dbPath string) (*kv.Store, error) {
|
||||
var err error
|
||||
clearDBConfirmed := false
|
||||
|
||||
if clearDB && !forceClearDB {
|
||||
const (
|
||||
actionText = "This will delete your beacon chain database stored in your data directory. " +
|
||||
"Your database backups will not be removed - do you want to proceed? (Y/N)"
|
||||
|
||||
deniedText = "Database will not be deleted. No changes have been made."
|
||||
)
|
||||
|
||||
clearDBConfirmed, err = cmd.ConfirmAction(actionText, deniedText)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not confirm action")
|
||||
}
|
||||
}
|
||||
|
||||
if clearDBConfirmed || forceClearDB {
|
||||
log.Warning("Removing database")
|
||||
if err := d.ClearDB(); err != nil {
|
||||
return nil, errors.Wrap(err, "could not clear database")
|
||||
}
|
||||
|
||||
if err := b.BlobStorage.Clear(); err != nil {
|
||||
return nil, errors.Wrap(err, "could not clear blob storage")
|
||||
}
|
||||
|
||||
d, err = kv.NewKVStore(b.ctx, dbPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not create new database")
|
||||
}
|
||||
}
|
||||
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (b *BeaconNode) checkAndSaveDepositContract(depositAddress string) error {
|
||||
knownContract, err := b.db.DepositContractAddress(b.ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not get deposit contract address")
|
||||
}
|
||||
|
||||
addr := common.HexToAddress(depositAddress)
|
||||
if len(knownContract) == 0 {
|
||||
if err := b.db.SaveDepositContractAddress(b.ctx, addr); err != nil {
|
||||
return errors.Wrap(err, "could not save deposit contract")
|
||||
}
|
||||
}
|
||||
|
||||
if len(knownContract) > 0 && !bytes.Equal(addr.Bytes(), knownContract) {
|
||||
return fmt.Errorf("database contract is %#x but tried to run with %#x. This likely means "+
|
||||
"you are trying to run on a different network than what the database contains. You can run once with "+
|
||||
"--%s to wipe the old database or use an alternative data directory with --%s",
|
||||
knownContract, addr.Bytes(), cmd.ClearDB.Name, cmd.DataDirFlag.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *BeaconNode) startDB(cliCtx *cli.Context, depositAddress string) error {
|
||||
var depositCache cache.DepositCache
|
||||
|
||||
baseDir := cliCtx.String(cmd.DataDirFlag.Name)
|
||||
dbPath := filepath.Join(baseDir, kv.BeaconNodeDbDirName)
|
||||
clearDB := cliCtx.Bool(cmd.ClearDB.Name)
|
||||
forceClearDB := cliCtx.Bool(cmd.ForceClearDB.Name)
|
||||
clearDBRequired := cliCtx.Bool(cmd.ClearDB.Name)
|
||||
forceClearDBRequired := cliCtx.Bool(cmd.ForceClearDB.Name)
|
||||
|
||||
log.WithField("databasePath", dbPath).Info("Checking DB")
|
||||
|
||||
d, err := kv.NewKVStore(b.ctx, dbPath)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrapf(err, "could not create database at %s", dbPath)
|
||||
}
|
||||
clearDBConfirmed := false
|
||||
if clearDB && !forceClearDB {
|
||||
actionText := "This will delete your beacon chain database stored in your data directory. " +
|
||||
"Your database backups will not be removed - do you want to proceed? (Y/N)"
|
||||
deniedText := "Database will not be deleted. No changes have been made."
|
||||
clearDBConfirmed, err = cmd.ConfirmAction(actionText, deniedText)
|
||||
|
||||
if clearDBRequired || forceClearDBRequired {
|
||||
d, err = b.clearDB(clearDBRequired, forceClearDBRequired, d, dbPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if clearDBConfirmed || forceClearDB {
|
||||
log.Warning("Removing database")
|
||||
if err := d.ClearDB(); err != nil {
|
||||
return errors.Wrap(err, "could not clear database")
|
||||
}
|
||||
if err := b.BlobStorage.Clear(); err != nil {
|
||||
return errors.Wrap(err, "could not clear blob storage")
|
||||
}
|
||||
d, err = kv.NewKVStore(b.ctx, dbPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not create new database")
|
||||
}
|
||||
}
|
||||
|
||||
if err := d.RunMigrations(b.ctx); err != nil {
|
||||
@@ -473,7 +567,6 @@ func (b *BeaconNode) startDB(cliCtx *cli.Context, depositAddress string) error {
|
||||
|
||||
b.db = d
|
||||
|
||||
var depositCache cache.DepositCache
|
||||
if features.Get().EnableEIP4881 {
|
||||
depositCache, err = depositsnapshot.New()
|
||||
} else {
|
||||
@@ -488,16 +581,17 @@ func (b *BeaconNode) startDB(cliCtx *cli.Context, depositAddress string) error {
|
||||
if b.GenesisInitializer != nil {
|
||||
if err := b.GenesisInitializer.Initialize(b.ctx, d); err != nil {
|
||||
if err == db.ErrExistingGenesisState {
|
||||
return errors.New("Genesis state flag specified but a genesis state " +
|
||||
"exists already. Run again with --clear-db and/or ensure you are using the " +
|
||||
"appropriate testnet flag to load the given genesis state.")
|
||||
return errors.Errorf("Genesis state flag specified but a genesis state "+
|
||||
"exists already. Run again with --%s and/or ensure you are using the "+
|
||||
"appropriate testnet flag to load the given genesis state.", cmd.ClearDB.Name)
|
||||
}
|
||||
|
||||
return errors.Wrap(err, "could not load genesis from file")
|
||||
}
|
||||
}
|
||||
|
||||
if err := b.db.EnsureEmbeddedGenesis(b.ctx); err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "could not ensure embedded genesis")
|
||||
}
|
||||
|
||||
if b.CheckpointInitializer != nil {
|
||||
@@ -506,23 +600,11 @@ func (b *BeaconNode) startDB(cliCtx *cli.Context, depositAddress string) error {
|
||||
}
|
||||
}
|
||||
|
||||
knownContract, err := b.db.DepositContractAddress(b.ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
if err := b.checkAndSaveDepositContract(depositAddress); err != nil {
|
||||
return errors.Wrap(err, "could not check and save deposit contract")
|
||||
}
|
||||
addr := common.HexToAddress(depositAddress)
|
||||
if len(knownContract) == 0 {
|
||||
if err := b.db.SaveDepositContractAddress(b.ctx, addr); err != nil {
|
||||
return errors.Wrap(err, "could not save deposit contract")
|
||||
}
|
||||
}
|
||||
if len(knownContract) > 0 && !bytes.Equal(addr.Bytes(), knownContract) {
|
||||
return fmt.Errorf("database contract is %#x but tried to run with %#x. This likely means "+
|
||||
"you are trying to run on a different network than what the database contains. You can run once with "+
|
||||
"'--clear-db' to wipe the old database or use an alternative data directory with '--datadir'",
|
||||
knownContract, addr.Bytes())
|
||||
}
|
||||
log.Infof("Deposit contract: %#x", addr.Bytes())
|
||||
|
||||
log.WithField("address", depositAddress).Info("Deposit contract")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -610,31 +692,31 @@ func (b *BeaconNode) startStateGen(ctx context.Context, bfs coverage.AvailableBl
|
||||
func (b *BeaconNode) registerP2P(cliCtx *cli.Context) error {
|
||||
bootstrapNodeAddrs, dataDir, err := registration.P2PPreregistration(cliCtx)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrapf(err, "could not register p2p service")
|
||||
}
|
||||
|
||||
svc, err := p2p.NewService(b.ctx, &p2p.Config{
|
||||
NoDiscovery: cliCtx.Bool(cmd.NoDiscovery.Name),
|
||||
StaticPeers: slice.SplitCommaSeparated(cliCtx.StringSlice(cmd.StaticPeers.Name)),
|
||||
BootstrapNodeAddr: bootstrapNodeAddrs,
|
||||
RelayNodeAddr: cliCtx.String(cmd.RelayNode.Name),
|
||||
DataDir: dataDir,
|
||||
LocalIP: cliCtx.String(cmd.P2PIP.Name),
|
||||
HostAddress: cliCtx.String(cmd.P2PHost.Name),
|
||||
HostDNS: cliCtx.String(cmd.P2PHostDNS.Name),
|
||||
PrivateKey: cliCtx.String(cmd.P2PPrivKey.Name),
|
||||
StaticPeerID: cliCtx.Bool(cmd.P2PStaticID.Name),
|
||||
MetaDataDir: cliCtx.String(cmd.P2PMetadata.Name),
|
||||
TCPPort: cliCtx.Uint(cmd.P2PTCPPort.Name),
|
||||
UDPPort: cliCtx.Uint(cmd.P2PUDPPort.Name),
|
||||
MaxPeers: cliCtx.Uint(cmd.P2PMaxPeers.Name),
|
||||
QueueSize: cliCtx.Uint(cmd.PubsubQueueSize.Name),
|
||||
AllowListCIDR: cliCtx.String(cmd.P2PAllowList.Name),
|
||||
DenyListCIDR: slice.SplitCommaSeparated(cliCtx.StringSlice(cmd.P2PDenyList.Name)),
|
||||
EnableUPnP: cliCtx.Bool(cmd.EnableUPnPFlag.Name),
|
||||
StateNotifier: b,
|
||||
DB: b.db,
|
||||
ClockWaiter: b.clockWaiter,
|
||||
NoDiscovery: cliCtx.Bool(cmd.NoDiscovery.Name),
|
||||
StaticPeers: slice.SplitCommaSeparated(cliCtx.StringSlice(cmd.StaticPeers.Name)),
|
||||
Discv5BootStrapAddrs: p2p.ParseBootStrapAddrs(bootstrapNodeAddrs),
|
||||
RelayNodeAddr: cliCtx.String(cmd.RelayNode.Name),
|
||||
DataDir: dataDir,
|
||||
LocalIP: cliCtx.String(cmd.P2PIP.Name),
|
||||
HostAddress: cliCtx.String(cmd.P2PHost.Name),
|
||||
HostDNS: cliCtx.String(cmd.P2PHostDNS.Name),
|
||||
PrivateKey: cliCtx.String(cmd.P2PPrivKey.Name),
|
||||
StaticPeerID: cliCtx.Bool(cmd.P2PStaticID.Name),
|
||||
MetaDataDir: cliCtx.String(cmd.P2PMetadata.Name),
|
||||
TCPPort: cliCtx.Uint(cmd.P2PTCPPort.Name),
|
||||
UDPPort: cliCtx.Uint(cmd.P2PUDPPort.Name),
|
||||
MaxPeers: cliCtx.Uint(cmd.P2PMaxPeers.Name),
|
||||
QueueSize: cliCtx.Uint(cmd.PubsubQueueSize.Name),
|
||||
AllowListCIDR: cliCtx.String(cmd.P2PAllowList.Name),
|
||||
DenyListCIDR: slice.SplitCommaSeparated(cliCtx.StringSlice(cmd.P2PDenyList.Name)),
|
||||
EnableUPnP: cliCtx.Bool(cmd.EnableUPnPFlag.Name),
|
||||
StateNotifier: b,
|
||||
DB: b.db,
|
||||
ClockWaiter: b.clockWaiter,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -976,11 +1058,13 @@ func (b *BeaconNode) registerGRPCGateway(router *mux.Router) error {
|
||||
if b.cliCtx.Bool(flags.DisableGRPCGateway.Name) {
|
||||
return nil
|
||||
}
|
||||
gatewayPort := b.cliCtx.Int(flags.GRPCGatewayPort.Name)
|
||||
gatewayHost := b.cliCtx.String(flags.GRPCGatewayHost.Name)
|
||||
gatewayPort := b.cliCtx.Int(flags.GRPCGatewayPort.Name)
|
||||
rpcHost := b.cliCtx.String(flags.RPCHost.Name)
|
||||
selfAddress := fmt.Sprintf("%s:%d", rpcHost, b.cliCtx.Int(flags.RPCPort.Name))
|
||||
gatewayAddress := fmt.Sprintf("%s:%d", gatewayHost, gatewayPort)
|
||||
rpcPort := b.cliCtx.Int(flags.RPCPort.Name)
|
||||
|
||||
selfAddress := net.JoinHostPort(rpcHost, strconv.Itoa(rpcPort))
|
||||
gatewayAddress := net.JoinHostPort(gatewayHost, strconv.Itoa(gatewayPort))
|
||||
allowedOrigins := strings.Split(b.cliCtx.String(flags.GPRCGatewayCorsDomain.Name), ",")
|
||||
enableDebugRPCEndpoints := b.cliCtx.Bool(flags.EnableDebugRPCEndpoints.Name)
|
||||
selfCert := b.cliCtx.String(flags.CertFlag.Name)
|
||||
@@ -1074,9 +1158,9 @@ func (b *BeaconNode) registerBuilderService(cliCtx *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
opts := append(b.serviceFlagOpts.builderOpts,
|
||||
builder.WithHeadFetcher(chainService),
|
||||
builder.WithDatabase(b.db))
|
||||
opts := b.serviceFlagOpts.builderOpts
|
||||
opts = append(opts, builder.WithHeadFetcher(chainService), builder.WithDatabase(b.db))
|
||||
|
||||
// make cache the default.
|
||||
if !cliCtx.Bool(features.DisableRegistrationCache.Name) {
|
||||
opts = append(opts, builder.WithRegistrationCache())
|
||||
|
||||
@@ -11,6 +11,7 @@ go_library(
|
||||
deps = [
|
||||
"//cmd:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
"@in_gopkg_yaml_v2//:go_default_library",
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/cmd"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/urfave/cli/v2"
|
||||
@@ -31,9 +32,9 @@ func P2PPreregistration(cliCtx *cli.Context) (bootstrapNodeAddrs []string, dataD
|
||||
if dataDir == "" {
|
||||
dataDir = cmd.DefaultDataDir()
|
||||
if dataDir == "" {
|
||||
log.Fatal(
|
||||
"Could not determine your system's HOME path, please specify a --datadir you wish " +
|
||||
"to use for your chain data",
|
||||
err = errors.Errorf(
|
||||
"Could not determine your system's HOME path, please specify a --%s you wish to use for your chain data",
|
||||
cmd.DataDirFlag.Name,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,9 +240,8 @@ func TestService_BroadcastAttestationWithDiscoveryAttempts(t *testing.T) {
|
||||
var hosts []host.Host
|
||||
// setup other nodes.
|
||||
cfg = &Config{
|
||||
BootstrapNodeAddr: []string{bootNode.String()},
|
||||
Discv5BootStrapAddr: []string{bootNode.String()},
|
||||
MaxPeers: 30,
|
||||
Discv5BootStrapAddrs: []string{bootNode.String()},
|
||||
MaxPeers: 30,
|
||||
}
|
||||
// Setup 2 different hosts
|
||||
for i := 1; i <= 2; i++ {
|
||||
|
||||
@@ -12,28 +12,27 @@ const defaultPubsubQueueSize = 600
|
||||
// Config for the p2p service. These parameters are set from application level flags
|
||||
// to initialize the p2p service.
|
||||
type Config struct {
|
||||
NoDiscovery bool
|
||||
EnableUPnP bool
|
||||
StaticPeerID bool
|
||||
StaticPeers []string
|
||||
BootstrapNodeAddr []string
|
||||
Discv5BootStrapAddr []string
|
||||
RelayNodeAddr string
|
||||
LocalIP string
|
||||
HostAddress string
|
||||
HostDNS string
|
||||
PrivateKey string
|
||||
DataDir string
|
||||
MetaDataDir string
|
||||
TCPPort uint
|
||||
UDPPort uint
|
||||
MaxPeers uint
|
||||
QueueSize uint
|
||||
AllowListCIDR string
|
||||
DenyListCIDR []string
|
||||
StateNotifier statefeed.Notifier
|
||||
DB db.ReadOnlyDatabase
|
||||
ClockWaiter startup.ClockWaiter
|
||||
NoDiscovery bool
|
||||
EnableUPnP bool
|
||||
StaticPeerID bool
|
||||
StaticPeers []string
|
||||
Discv5BootStrapAddrs []string
|
||||
RelayNodeAddr string
|
||||
LocalIP string
|
||||
HostAddress string
|
||||
HostDNS string
|
||||
PrivateKey string
|
||||
DataDir string
|
||||
MetaDataDir string
|
||||
TCPPort uint
|
||||
UDPPort uint
|
||||
MaxPeers uint
|
||||
QueueSize uint
|
||||
AllowListCIDR string
|
||||
DenyListCIDR []string
|
||||
StateNotifier statefeed.Notifier
|
||||
DB db.ReadOnlyDatabase
|
||||
ClockWaiter startup.ClockWaiter
|
||||
}
|
||||
|
||||
// validateConfig validates whether the values provided are accurate and will set
|
||||
|
||||
@@ -25,7 +25,7 @@ const (
|
||||
)
|
||||
|
||||
// InterceptPeerDial tests whether we're permitted to Dial the specified peer.
|
||||
func (_ *Service) InterceptPeerDial(_ peer.ID) (allow bool) {
|
||||
func (*Service) InterceptPeerDial(_ peer.ID) (allow bool) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -63,12 +63,12 @@ func (s *Service) InterceptAccept(n network.ConnMultiaddrs) (allow bool) {
|
||||
|
||||
// InterceptSecured tests whether a given connection, now authenticated,
|
||||
// is allowed.
|
||||
func (_ *Service) InterceptSecured(_ network.Direction, _ peer.ID, _ network.ConnMultiaddrs) (allow bool) {
|
||||
func (*Service) InterceptSecured(_ network.Direction, _ peer.ID, _ network.ConnMultiaddrs) (allow bool) {
|
||||
return true
|
||||
}
|
||||
|
||||
// InterceptUpgraded tests whether a fully capable connection is allowed.
|
||||
func (_ *Service) InterceptUpgraded(_ network.Conn) (allow bool, reason control.DisconnectReason) {
|
||||
func (*Service) InterceptUpgraded(_ network.Conn) (allow bool, reason control.DisconnectReason) {
|
||||
return true, 0
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,11 @@ type Listener interface {
|
||||
LocalNode() *enode.LocalNode
|
||||
}
|
||||
|
||||
const (
|
||||
udp4 = iota
|
||||
udp6
|
||||
)
|
||||
|
||||
// RefreshENR uses an epoch to refresh the enr entry for our node
|
||||
// with the tracked committee ids for the epoch, allowing our node
|
||||
// to be dynamically discoverable by others given our tracked committee ids.
|
||||
@@ -62,8 +67,14 @@ func (s *Service) RefreshENR() {
|
||||
// Compare current epoch with our fork epochs
|
||||
altairForkEpoch := params.BeaconConfig().AltairForkEpoch
|
||||
switch {
|
||||
// Altair Behaviour
|
||||
case currEpoch >= altairForkEpoch:
|
||||
case currEpoch < altairForkEpoch:
|
||||
// Phase 0 behaviour.
|
||||
if bytes.Equal(bitV, currentBitV) {
|
||||
// return early if bitfield hasn't changed
|
||||
return
|
||||
}
|
||||
s.updateSubnetRecordWithMetadata(bitV)
|
||||
default:
|
||||
// Retrieve sync subnets from application level
|
||||
// cache.
|
||||
bitS := bitfield.Bitvector4{byte(0x00)}
|
||||
@@ -82,13 +93,6 @@ func (s *Service) RefreshENR() {
|
||||
return
|
||||
}
|
||||
s.updateSubnetRecordWithMetadataV2(bitV, bitS)
|
||||
default:
|
||||
// Phase 0 behaviour.
|
||||
if bytes.Equal(bitV, currentBitV) {
|
||||
// return early if bitfield hasn't changed
|
||||
return
|
||||
}
|
||||
s.updateSubnetRecordWithMetadata(bitV)
|
||||
}
|
||||
// ping all peers to inform them of new metadata
|
||||
s.pingPeers()
|
||||
@@ -140,9 +144,9 @@ func (s *Service) createListener(
|
||||
// by default we will listen to all interfaces.
|
||||
var bindIP net.IP
|
||||
switch udpVersionFromIP(ipAddr) {
|
||||
case "udp4":
|
||||
case udp4:
|
||||
bindIP = net.IPv4zero
|
||||
case "udp6":
|
||||
case udp6:
|
||||
bindIP = net.IPv6zero
|
||||
default:
|
||||
return nil, errors.New("invalid ip provided")
|
||||
@@ -160,6 +164,7 @@ func (s *Service) createListener(
|
||||
IP: bindIP,
|
||||
Port: int(s.cfg.UDPPort),
|
||||
}
|
||||
|
||||
// Listen to all network interfaces
|
||||
// for both ip protocols.
|
||||
networkVersion := "udp"
|
||||
@@ -177,44 +182,27 @@ func (s *Service) createListener(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not create local node")
|
||||
}
|
||||
if s.cfg.HostAddress != "" {
|
||||
hostIP := net.ParseIP(s.cfg.HostAddress)
|
||||
if hostIP.To4() == nil && hostIP.To16() == nil {
|
||||
log.Errorf("Invalid host address given: %s", hostIP.String())
|
||||
} else {
|
||||
localNode.SetFallbackIP(hostIP)
|
||||
localNode.SetStaticIP(hostIP)
|
||||
}
|
||||
}
|
||||
if s.cfg.HostDNS != "" {
|
||||
host := s.cfg.HostDNS
|
||||
ips, err := net.LookupIP(host)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not resolve host address")
|
||||
}
|
||||
if len(ips) > 0 {
|
||||
// Use first IP returned from the
|
||||
// resolver.
|
||||
firstIP := ips[0]
|
||||
localNode.SetFallbackIP(firstIP)
|
||||
}
|
||||
}
|
||||
dv5Cfg := discover.Config{
|
||||
PrivateKey: privKey,
|
||||
}
|
||||
dv5Cfg.Bootnodes = []*enode.Node{}
|
||||
for _, addr := range s.cfg.Discv5BootStrapAddr {
|
||||
|
||||
bootNodes := make([]*enode.Node, 0, len(s.cfg.Discv5BootStrapAddrs))
|
||||
for _, addr := range s.cfg.Discv5BootStrapAddrs {
|
||||
bootNode, err := enode.Parse(enode.ValidSchemes, addr)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not bootstrap addr")
|
||||
}
|
||||
dv5Cfg.Bootnodes = append(dv5Cfg.Bootnodes, bootNode)
|
||||
|
||||
bootNodes = append(bootNodes, bootNode)
|
||||
}
|
||||
|
||||
dv5Cfg := discover.Config{
|
||||
PrivateKey: privKey,
|
||||
Bootnodes: bootNodes,
|
||||
}
|
||||
|
||||
listener, err := discover.ListenV5(conn, localNode, dv5Cfg)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not listen to discV5")
|
||||
}
|
||||
|
||||
return listener, nil
|
||||
}
|
||||
|
||||
@@ -242,8 +230,35 @@ func (s *Service) createLocalNode(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not add eth2 fork version entry to enr")
|
||||
}
|
||||
|
||||
localNode = initializeAttSubnets(localNode)
|
||||
return initializeSyncCommSubnets(localNode), nil
|
||||
localNode = initializeSyncCommSubnets(localNode)
|
||||
|
||||
if s.cfg != nil && s.cfg.HostAddress != "" {
|
||||
hostIP := net.ParseIP(s.cfg.HostAddress)
|
||||
if hostIP.To4() == nil && hostIP.To16() == nil {
|
||||
return nil, errors.Errorf("invalid host address: %s", s.cfg.HostAddress)
|
||||
} else {
|
||||
localNode.SetFallbackIP(hostIP)
|
||||
localNode.SetStaticIP(hostIP)
|
||||
}
|
||||
}
|
||||
|
||||
if s.cfg != nil && s.cfg.HostDNS != "" {
|
||||
host := s.cfg.HostDNS
|
||||
ips, err := net.LookupIP(host)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not resolve host address: %s", host)
|
||||
}
|
||||
if len(ips) > 0 {
|
||||
// Use first IP returned from the
|
||||
// resolver.
|
||||
firstIP := ips[0]
|
||||
localNode.SetFallbackIP(firstIP)
|
||||
}
|
||||
}
|
||||
|
||||
return localNode, nil
|
||||
}
|
||||
|
||||
func (s *Service) startDiscoveryV5(
|
||||
@@ -363,7 +378,7 @@ func PeersFromStringAddrs(addrs []string) ([]ma.Multiaddr, error) {
|
||||
return allAddrs, nil
|
||||
}
|
||||
|
||||
func parseBootStrapAddrs(addrs []string) (discv5Nodes []string) {
|
||||
func ParseBootStrapAddrs(addrs []string) (discv5Nodes []string) {
|
||||
discv5Nodes, _ = parseGenericAddrs(addrs)
|
||||
if len(discv5Nodes) == 0 {
|
||||
log.Warn("No bootstrap addresses supplied")
|
||||
@@ -483,9 +498,9 @@ func multiAddrFromString(address string) (ma.Multiaddr, error) {
|
||||
return ma.NewMultiaddr(address)
|
||||
}
|
||||
|
||||
func udpVersionFromIP(ipAddr net.IP) string {
|
||||
func udpVersionFromIP(ipAddr net.IP) int {
|
||||
if ipAddr.To4() != nil {
|
||||
return "udp4"
|
||||
return udp4
|
||||
}
|
||||
return "udp6"
|
||||
return udp6
|
||||
}
|
||||
|
||||
@@ -42,10 +42,6 @@ import (
|
||||
|
||||
var discoveryWaitTime = 1 * time.Second
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().Unix())
|
||||
}
|
||||
|
||||
func createAddrAndPrivKey(t *testing.T) (net.IP, *ecdsa.PrivateKey) {
|
||||
ip, err := prysmNetwork.ExternalIPv4()
|
||||
require.NoError(t, err, "Could not get ip")
|
||||
@@ -103,8 +99,8 @@ func TestStartDiscV5_DiscoverAllPeers(t *testing.T) {
|
||||
for i := 1; i <= 5; i++ {
|
||||
port = 3000 + i
|
||||
cfg := &Config{
|
||||
Discv5BootStrapAddr: []string{bootNode.String()},
|
||||
UDPPort: uint(port),
|
||||
Discv5BootStrapAddrs: []string{bootNode.String()},
|
||||
UDPPort: uint(port),
|
||||
}
|
||||
ipAddr, pkey := createAddrAndPrivKey(t)
|
||||
s = &Service{
|
||||
@@ -134,6 +130,106 @@ func TestStartDiscV5_DiscoverAllPeers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateLocalNode(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
cfg *Config
|
||||
expectedError bool
|
||||
}{
|
||||
{
|
||||
name: "valid config",
|
||||
cfg: nil,
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "invalid host address",
|
||||
cfg: &Config{HostAddress: "invalid"},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "valid host address",
|
||||
cfg: &Config{HostAddress: "192.168.0.1"},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "invalid host DNS",
|
||||
cfg: &Config{HostDNS: "invalid"},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "valid host DNS",
|
||||
cfg: &Config{HostDNS: "www.google.com"},
|
||||
expectedError: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range testCases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// Define ports.
|
||||
const (
|
||||
udpPort = 2000
|
||||
tcpPort = 3000
|
||||
)
|
||||
|
||||
// Create a private key.
|
||||
address, privKey := createAddrAndPrivKey(t)
|
||||
|
||||
// Create a service.
|
||||
service := &Service{
|
||||
genesisTime: time.Now(),
|
||||
genesisValidatorsRoot: bytesutil.PadTo([]byte{'A'}, 32),
|
||||
cfg: tt.cfg,
|
||||
}
|
||||
|
||||
localNode, err := service.createLocalNode(privKey, address, udpPort, tcpPort)
|
||||
if tt.expectedError {
|
||||
require.NotNil(t, err)
|
||||
return
|
||||
}
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedAddress := address
|
||||
if tt.cfg != nil && tt.cfg.HostAddress != "" {
|
||||
expectedAddress = net.ParseIP(tt.cfg.HostAddress)
|
||||
}
|
||||
|
||||
// Check IP.
|
||||
// IP is not checked int case of DNS, since it can be resolved to different IPs.
|
||||
if tt.cfg == nil || tt.cfg.HostDNS == "" {
|
||||
ip := new(net.IP)
|
||||
require.NoError(t, localNode.Node().Record().Load(enr.WithEntry("ip", ip)))
|
||||
require.Equal(t, true, ip.Equal(expectedAddress))
|
||||
require.Equal(t, true, localNode.Node().IP().Equal(expectedAddress))
|
||||
}
|
||||
|
||||
// Check UDP.
|
||||
udp := new(uint16)
|
||||
require.NoError(t, localNode.Node().Record().Load(enr.WithEntry("udp", udp)))
|
||||
require.Equal(t, udpPort, localNode.Node().UDP())
|
||||
|
||||
// Check TCP.
|
||||
tcp := new(uint16)
|
||||
require.NoError(t, localNode.Node().Record().Load(enr.WithEntry("tcp", tcp)))
|
||||
require.Equal(t, tcpPort, localNode.Node().TCP())
|
||||
|
||||
// Check fork is set.
|
||||
fork := new([]byte)
|
||||
require.NoError(t, localNode.Node().Record().Load(enr.WithEntry(eth2ENRKey, fork)))
|
||||
require.NotEmpty(t, *fork)
|
||||
|
||||
// Check att subnets.
|
||||
attSubnets := new([]byte)
|
||||
require.NoError(t, localNode.Node().Record().Load(enr.WithEntry(attSubnetEnrKey, attSubnets)))
|
||||
require.DeepSSZEqual(t, []byte{0, 0, 0, 0, 0, 0, 0, 0}, *attSubnets)
|
||||
|
||||
// Check sync committees subnets.
|
||||
syncSubnets := new([]byte)
|
||||
require.NoError(t, localNode.Node().Record().Load(enr.WithEntry(syncCommsSubnetEnrKey, syncSubnets)))
|
||||
require.DeepSSZEqual(t, []byte{0}, *syncSubnets)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMultiAddrsConversion_InvalidIPAddr(t *testing.T) {
|
||||
addr := net.ParseIP("invalidIP")
|
||||
_, pkey := createAddrAndPrivKey(t)
|
||||
@@ -310,12 +406,12 @@ func TestMultipleDiscoveryAddresses(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCorrectUDPVersion(t *testing.T) {
|
||||
assert.Equal(t, "udp4", udpVersionFromIP(net.IPv4zero), "incorrect network version")
|
||||
assert.Equal(t, "udp6", udpVersionFromIP(net.IPv6zero), "incorrect network version")
|
||||
assert.Equal(t, "udp4", udpVersionFromIP(net.IP{200, 20, 12, 255}), "incorrect network version")
|
||||
assert.Equal(t, "udp6", udpVersionFromIP(net.IP{22, 23, 24, 251, 17, 18, 0, 0, 0, 0, 12, 14, 212, 213, 16, 22}), "incorrect network version")
|
||||
assert.Equal(t, udp4, udpVersionFromIP(net.IPv4zero), "incorrect network version")
|
||||
assert.Equal(t, udp6, udpVersionFromIP(net.IPv6zero), "incorrect network version")
|
||||
assert.Equal(t, udp4, udpVersionFromIP(net.IP{200, 20, 12, 255}), "incorrect network version")
|
||||
assert.Equal(t, udp6, udpVersionFromIP(net.IP{22, 23, 24, 251, 17, 18, 0, 0, 0, 0, 12, 14, 212, 213, 16, 22}), "incorrect network version")
|
||||
// v4 in v6
|
||||
assert.Equal(t, "udp4", udpVersionFromIP(net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 212, 213, 16, 22}), "incorrect network version")
|
||||
assert.Equal(t, udp4, udpVersionFromIP(net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 212, 213, 16, 22}), "incorrect network version")
|
||||
}
|
||||
|
||||
// addPeer is a helper to add a peer with a given connection state)
|
||||
|
||||
@@ -46,9 +46,9 @@ func TestStartDiscv5_DifferentForkDigests(t *testing.T) {
|
||||
|
||||
bootNode := bootListener.Self()
|
||||
cfg := &Config{
|
||||
Discv5BootStrapAddr: []string{bootNode.String()},
|
||||
UDPPort: uint(port),
|
||||
StateNotifier: &mock.MockStateNotifier{},
|
||||
Discv5BootStrapAddrs: []string{bootNode.String()},
|
||||
UDPPort: uint(port),
|
||||
StateNotifier: &mock.MockStateNotifier{},
|
||||
}
|
||||
|
||||
var listeners []*discover.UDPv5
|
||||
@@ -132,8 +132,8 @@ func TestStartDiscv5_SameForkDigests_DifferentNextForkData(t *testing.T) {
|
||||
|
||||
bootNode := bootListener.Self()
|
||||
cfg := &Config{
|
||||
Discv5BootStrapAddr: []string{bootNode.String()},
|
||||
UDPPort: uint(port),
|
||||
Discv5BootStrapAddrs: []string{bootNode.String()},
|
||||
UDPPort: uint(port),
|
||||
}
|
||||
|
||||
var listeners []*discover.UDPv5
|
||||
|
||||
@@ -20,7 +20,7 @@ self=%s
|
||||
%d peers
|
||||
%v
|
||||
`,
|
||||
s.cfg.BootstrapNodeAddr,
|
||||
s.cfg.Discv5BootStrapAddrs,
|
||||
s.selfAddresses(),
|
||||
len(s.host.Network().Peers()),
|
||||
formatPeers(s.host), // Must be last. Writes one entry per row.
|
||||
|
||||
@@ -31,29 +31,31 @@ func MultiAddressBuilder(ipAddr string, port uint) (ma.Multiaddr, error) {
|
||||
}
|
||||
|
||||
// buildOptions for the libp2p host.
|
||||
func (s *Service) buildOptions(ip net.IP, priKey *ecdsa.PrivateKey) []libp2p.Option {
|
||||
func (s *Service) buildOptions(ip net.IP, priKey *ecdsa.PrivateKey) ([]libp2p.Option, error) {
|
||||
cfg := s.cfg
|
||||
listen, err := MultiAddressBuilder(ip.String(), cfg.TCPPort)
|
||||
if err != nil {
|
||||
log.WithError(err).Fatal("Failed to p2p listen")
|
||||
return nil, errors.Wrapf(err, "cannot produce multiaddr format from %s:%d", ip.String(), cfg.TCPPort)
|
||||
}
|
||||
if cfg.LocalIP != "" {
|
||||
if net.ParseIP(cfg.LocalIP) == nil {
|
||||
log.Fatalf("Invalid local ip provided: %s", cfg.LocalIP)
|
||||
return nil, errors.Wrapf(err, "invalid local ip provided: %s:%d", cfg.LocalIP, cfg.TCPPort)
|
||||
}
|
||||
|
||||
listen, err = MultiAddressBuilder(cfg.LocalIP, cfg.TCPPort)
|
||||
if err != nil {
|
||||
log.WithError(err).Fatal("Failed to p2p listen")
|
||||
return nil, errors.Wrapf(err, "cannot produce multiaddr format from %s:%d", cfg.LocalIP, cfg.TCPPort)
|
||||
}
|
||||
}
|
||||
ifaceKey, err := ecdsaprysm.ConvertToInterfacePrivkey(priKey)
|
||||
if err != nil {
|
||||
log.WithError(err).Fatal("Failed to retrieve private key")
|
||||
return nil, errors.Wrap(err, "cannot convert private key to interface private key. (Private key not displayed in logs for security reasons)")
|
||||
}
|
||||
id, err := peer.IDFromPublicKey(ifaceKey.GetPublic())
|
||||
if err != nil {
|
||||
log.WithError(err).Fatal("Failed to retrieve peer id")
|
||||
return nil, errors.Wrapf(err, "cannot get ID from public key: %s", ifaceKey.GetPublic().Type().String())
|
||||
}
|
||||
|
||||
log.Infof("Running node with peer id of %s ", id.String())
|
||||
|
||||
options := []libp2p.Option{
|
||||
@@ -64,10 +66,10 @@ func (s *Service) buildOptions(ip net.IP, priKey *ecdsa.PrivateKey) []libp2p.Opt
|
||||
libp2p.Transport(tcp.NewTCPTransport),
|
||||
libp2p.DefaultMuxers,
|
||||
libp2p.Muxer("/mplex/6.7.0", mplex.DefaultTransport),
|
||||
libp2p.Security(noise.ID, noise.New),
|
||||
libp2p.Ping(false), // Disable Ping Service.
|
||||
}
|
||||
|
||||
options = append(options, libp2p.Security(noise.ID, noise.New))
|
||||
|
||||
if cfg.EnableUPnP {
|
||||
options = append(options, libp2p.NATPortMap()) // Allow to use UPnP
|
||||
}
|
||||
@@ -99,12 +101,11 @@ func (s *Service) buildOptions(ip net.IP, priKey *ecdsa.PrivateKey) []libp2p.Opt
|
||||
return addrs
|
||||
}))
|
||||
}
|
||||
// Disable Ping Service.
|
||||
options = append(options, libp2p.Ping(false))
|
||||
|
||||
if features.Get().DisableResourceManager {
|
||||
options = append(options, libp2p.ResourceManager(&network.NullResourceManager{}))
|
||||
}
|
||||
return options
|
||||
return options, nil
|
||||
}
|
||||
|
||||
func multiAddressBuilderWithID(ipAddr, protocol string, port uint, id peer.ID) (ma.Multiaddr, error) {
|
||||
|
||||
@@ -119,7 +119,9 @@ func TestDefaultMultiplexers(t *testing.T) {
|
||||
svc.privKey, err = privKey(svc.cfg)
|
||||
assert.NoError(t, err)
|
||||
ipAddr := network.IPAddr()
|
||||
opts := svc.buildOptions(ipAddr, svc.privKey)
|
||||
opts, err := svc.buildOptions(ipAddr, svc.privKey)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = cfg.Apply(append(opts, libp2p.FallbackDefaults)...)
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
||||
@@ -107,5 +107,4 @@ func TestStore_TrustedPeers(t *testing.T) {
|
||||
assert.Equal(t, false, store.IsTrustedPeer(pid1))
|
||||
assert.Equal(t, false, store.IsTrustedPeer(pid2))
|
||||
assert.Equal(t, false, store.IsTrustedPeer(pid3))
|
||||
|
||||
}
|
||||
|
||||
@@ -56,12 +56,12 @@ func newBadResponsesScorer(store *peerdata.Store, config *BadResponsesScorerConf
|
||||
func (s *BadResponsesScorer) Score(pid peer.ID) float64 {
|
||||
s.store.RLock()
|
||||
defer s.store.RUnlock()
|
||||
return s.score(pid)
|
||||
return s.scoreNoLock(pid)
|
||||
}
|
||||
|
||||
// score is a lock-free version of Score.
|
||||
func (s *BadResponsesScorer) score(pid peer.ID) float64 {
|
||||
if s.isBadPeer(pid) {
|
||||
// scoreNoLock is a lock-free version of Score.
|
||||
func (s *BadResponsesScorer) scoreNoLock(pid peer.ID) float64 {
|
||||
if s.isBadPeerNoLock(pid) {
|
||||
return BadPeerScore
|
||||
}
|
||||
score := float64(0)
|
||||
@@ -87,11 +87,11 @@ func (s *BadResponsesScorer) Params() *BadResponsesScorerConfig {
|
||||
func (s *BadResponsesScorer) Count(pid peer.ID) (int, error) {
|
||||
s.store.RLock()
|
||||
defer s.store.RUnlock()
|
||||
return s.count(pid)
|
||||
return s.countNoLock(pid)
|
||||
}
|
||||
|
||||
// count is a lock-free version of Count.
|
||||
func (s *BadResponsesScorer) count(pid peer.ID) (int, error) {
|
||||
// countNoLock is a lock-free version of Count.
|
||||
func (s *BadResponsesScorer) countNoLock(pid peer.ID) (int, error) {
|
||||
if peerData, ok := s.store.PeerData(pid); ok {
|
||||
return peerData.BadResponses, nil
|
||||
}
|
||||
@@ -119,11 +119,11 @@ func (s *BadResponsesScorer) Increment(pid peer.ID) {
|
||||
func (s *BadResponsesScorer) IsBadPeer(pid peer.ID) bool {
|
||||
s.store.RLock()
|
||||
defer s.store.RUnlock()
|
||||
return s.isBadPeer(pid)
|
||||
return s.isBadPeerNoLock(pid)
|
||||
}
|
||||
|
||||
// isBadPeer is lock-free version of IsBadPeer.
|
||||
func (s *BadResponsesScorer) isBadPeer(pid peer.ID) bool {
|
||||
// isBadPeerNoLock is lock-free version of IsBadPeer.
|
||||
func (s *BadResponsesScorer) isBadPeerNoLock(pid peer.ID) bool {
|
||||
if peerData, ok := s.store.PeerData(pid); ok {
|
||||
return peerData.BadResponses >= s.config.Threshold
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func (s *BadResponsesScorer) BadPeers() []peer.ID {
|
||||
|
||||
badPeers := make([]peer.ID, 0)
|
||||
for pid := range s.store.Peers() {
|
||||
if s.isBadPeer(pid) {
|
||||
if s.isBadPeerNoLock(pid) {
|
||||
badPeers = append(badPeers, pid)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ import (
|
||||
)
|
||||
|
||||
func TestScorers_BadResponses_Score(t *testing.T) {
|
||||
const pid = "peer1"
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
@@ -28,15 +30,23 @@ func TestScorers_BadResponses_Score(t *testing.T) {
|
||||
})
|
||||
scorer := peerStatuses.Scorers().BadResponsesScorer()
|
||||
|
||||
assert.Equal(t, 0.0, scorer.Score("peer1"), "Unexpected score for unregistered peer")
|
||||
scorer.Increment("peer1")
|
||||
assert.Equal(t, -2.5, scorer.Score("peer1"))
|
||||
scorer.Increment("peer1")
|
||||
assert.Equal(t, float64(-5), scorer.Score("peer1"))
|
||||
scorer.Increment("peer1")
|
||||
scorer.Increment("peer1")
|
||||
assert.Equal(t, -100.0, scorer.Score("peer1"))
|
||||
assert.Equal(t, true, scorer.IsBadPeer("peer1"))
|
||||
assert.Equal(t, 0., scorer.Score(pid), "Unexpected score for unregistered peer")
|
||||
|
||||
scorer.Increment(pid)
|
||||
assert.Equal(t, false, scorer.IsBadPeer(pid))
|
||||
assert.Equal(t, -2.5, scorer.Score(pid))
|
||||
|
||||
scorer.Increment(pid)
|
||||
assert.Equal(t, false, scorer.IsBadPeer(pid))
|
||||
assert.Equal(t, float64(-5), scorer.Score(pid))
|
||||
|
||||
scorer.Increment(pid)
|
||||
assert.Equal(t, false, scorer.IsBadPeer(pid))
|
||||
assert.Equal(t, float64(-7.5), scorer.Score(pid))
|
||||
|
||||
scorer.Increment(pid)
|
||||
assert.Equal(t, true, scorer.IsBadPeer(pid))
|
||||
assert.Equal(t, -100.0, scorer.Score(pid))
|
||||
}
|
||||
|
||||
func TestScorers_BadResponses_ParamsThreshold(t *testing.T) {
|
||||
|
||||
@@ -98,11 +98,11 @@ func newBlockProviderScorer(store *peerdata.Store, config *BlockProviderScorerCo
|
||||
func (s *BlockProviderScorer) Score(pid peer.ID) float64 {
|
||||
s.store.RLock()
|
||||
defer s.store.RUnlock()
|
||||
return s.score(pid)
|
||||
return s.scoreNoLock(pid)
|
||||
}
|
||||
|
||||
// score is a lock-free version of Score.
|
||||
func (s *BlockProviderScorer) score(pid peer.ID) float64 {
|
||||
// scoreNoLock is a lock-free version of Score.
|
||||
func (s *BlockProviderScorer) scoreNoLock(pid peer.ID) float64 {
|
||||
score := float64(0)
|
||||
peerData, ok := s.store.PeerData(pid)
|
||||
// Boost score of new peers or peers that haven't been accessed for too long.
|
||||
@@ -126,7 +126,7 @@ func (s *BlockProviderScorer) Params() *BlockProviderScorerConfig {
|
||||
func (s *BlockProviderScorer) IncrementProcessedBlocks(pid peer.ID, cnt uint64) {
|
||||
s.store.Lock()
|
||||
defer s.store.Unlock()
|
||||
defer s.touch(pid)
|
||||
defer s.touchNoLock(pid)
|
||||
|
||||
if cnt <= 0 {
|
||||
return
|
||||
@@ -145,11 +145,11 @@ func (s *BlockProviderScorer) IncrementProcessedBlocks(pid peer.ID, cnt uint64)
|
||||
func (s *BlockProviderScorer) Touch(pid peer.ID, t ...time.Time) {
|
||||
s.store.Lock()
|
||||
defer s.store.Unlock()
|
||||
s.touch(pid, t...)
|
||||
s.touchNoLock(pid, t...)
|
||||
}
|
||||
|
||||
// touch is a lock-free version of Touch.
|
||||
func (s *BlockProviderScorer) touch(pid peer.ID, t ...time.Time) {
|
||||
// touchNoLock is a lock-free version of Touch.
|
||||
func (s *BlockProviderScorer) touchNoLock(pid peer.ID, t ...time.Time) {
|
||||
peerData := s.store.PeerDataGetOrCreate(pid)
|
||||
if len(t) == 1 {
|
||||
peerData.BlockProviderUpdated = t[0]
|
||||
@@ -162,11 +162,11 @@ func (s *BlockProviderScorer) touch(pid peer.ID, t ...time.Time) {
|
||||
func (s *BlockProviderScorer) ProcessedBlocks(pid peer.ID) uint64 {
|
||||
s.store.RLock()
|
||||
defer s.store.RUnlock()
|
||||
return s.processedBlocks(pid)
|
||||
return s.processedBlocksNoLock(pid)
|
||||
}
|
||||
|
||||
// processedBlocks is a lock-free version of ProcessedBlocks.
|
||||
func (s *BlockProviderScorer) processedBlocks(pid peer.ID) uint64 {
|
||||
// processedBlocksNoLock is a lock-free version of ProcessedBlocks.
|
||||
func (s *BlockProviderScorer) processedBlocksNoLock(pid peer.ID) uint64 {
|
||||
if peerData, ok := s.store.PeerData(pid); ok {
|
||||
return peerData.ProcessedBlocks
|
||||
}
|
||||
@@ -177,13 +177,13 @@ func (s *BlockProviderScorer) processedBlocks(pid peer.ID) uint64 {
|
||||
// Block provider scorer cannot guarantee that lower score of a peer is indeed a sign of a bad peer.
|
||||
// Therefore this scorer never marks peers as bad, and relies on scores to probabilistically sort
|
||||
// out low-scorers (see WeightSorted method).
|
||||
func (_ *BlockProviderScorer) IsBadPeer(_ peer.ID) bool {
|
||||
func (*BlockProviderScorer) IsBadPeer(_ peer.ID) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// BadPeers returns the peers that are considered bad.
|
||||
// No peers are considered bad by block providers scorer.
|
||||
func (_ *BlockProviderScorer) BadPeers() []peer.ID {
|
||||
func (*BlockProviderScorer) BadPeers() []peer.ID {
|
||||
return []peer.ID{}
|
||||
}
|
||||
|
||||
@@ -277,9 +277,9 @@ func (s *BlockProviderScorer) mapScoresAndPeers(
|
||||
peers := make([]peer.ID, len(pids))
|
||||
for i, pid := range pids {
|
||||
if scoreFn != nil {
|
||||
scores[pid] = scoreFn(pid, s.score(pid))
|
||||
scores[pid] = scoreFn(pid, s.scoreNoLock(pid))
|
||||
} else {
|
||||
scores[pid] = s.score(pid)
|
||||
scores[pid] = s.scoreNoLock(pid)
|
||||
}
|
||||
peers[i] = pid
|
||||
}
|
||||
@@ -293,9 +293,9 @@ func (s *BlockProviderScorer) FormatScorePretty(pid peer.ID) string {
|
||||
if !features.Get().EnablePeerScorer {
|
||||
return "disabled"
|
||||
}
|
||||
score := s.score(pid)
|
||||
score := s.scoreNoLock(pid)
|
||||
return fmt.Sprintf("[%0.1f%%, raw: %0.2f, blocks: %d/%d]",
|
||||
(score/s.MaxScore())*100, score, s.processedBlocks(pid), s.config.ProcessedBlocksCap)
|
||||
(score/s.MaxScore())*100, score, s.processedBlocksNoLock(pid), s.config.ProcessedBlocksCap)
|
||||
}
|
||||
|
||||
// MaxScore exposes maximum score attainable by peers.
|
||||
|
||||
@@ -38,11 +38,11 @@ func newGossipScorer(store *peerdata.Store, config *GossipScorerConfig) *GossipS
|
||||
func (s *GossipScorer) Score(pid peer.ID) float64 {
|
||||
s.store.RLock()
|
||||
defer s.store.RUnlock()
|
||||
return s.score(pid)
|
||||
return s.scoreNoLock(pid)
|
||||
}
|
||||
|
||||
// score is a lock-free version of Score.
|
||||
func (s *GossipScorer) score(pid peer.ID) float64 {
|
||||
// scoreNoLock is a lock-free version of Score.
|
||||
func (s *GossipScorer) scoreNoLock(pid peer.ID) float64 {
|
||||
peerData, ok := s.store.PeerData(pid)
|
||||
if !ok {
|
||||
return 0
|
||||
@@ -54,11 +54,11 @@ func (s *GossipScorer) score(pid peer.ID) float64 {
|
||||
func (s *GossipScorer) IsBadPeer(pid peer.ID) bool {
|
||||
s.store.RLock()
|
||||
defer s.store.RUnlock()
|
||||
return s.isBadPeer(pid)
|
||||
return s.isBadPeerNoLock(pid)
|
||||
}
|
||||
|
||||
// isBadPeer is lock-free version of IsBadPeer.
|
||||
func (s *GossipScorer) isBadPeer(pid peer.ID) bool {
|
||||
// isBadPeerNoLock is lock-free version of IsBadPeer.
|
||||
func (s *GossipScorer) isBadPeerNoLock(pid peer.ID) bool {
|
||||
peerData, ok := s.store.PeerData(pid)
|
||||
if !ok {
|
||||
return false
|
||||
@@ -73,7 +73,7 @@ func (s *GossipScorer) BadPeers() []peer.ID {
|
||||
|
||||
badPeers := make([]peer.ID, 0)
|
||||
for pid := range s.store.Peers() {
|
||||
if s.isBadPeer(pid) {
|
||||
if s.isBadPeerNoLock(pid) {
|
||||
badPeers = append(badPeers, pid)
|
||||
}
|
||||
}
|
||||
@@ -98,11 +98,11 @@ func (s *GossipScorer) SetGossipData(pid peer.ID, gScore float64,
|
||||
func (s *GossipScorer) GossipData(pid peer.ID) (float64, float64, map[string]*pbrpc.TopicScoreSnapshot, error) {
|
||||
s.store.RLock()
|
||||
defer s.store.RUnlock()
|
||||
return s.gossipData(pid)
|
||||
return s.gossipDataNoLock(pid)
|
||||
}
|
||||
|
||||
// gossipData lock-free version of GossipData.
|
||||
func (s *GossipScorer) gossipData(pid peer.ID) (float64, float64, map[string]*pbrpc.TopicScoreSnapshot, error) {
|
||||
// gossipDataNoLock lock-free version of GossipData.
|
||||
func (s *GossipScorer) gossipDataNoLock(pid peer.ID) (float64, float64, map[string]*pbrpc.TopicScoreSnapshot, error) {
|
||||
if peerData, ok := s.store.PeerData(pid); ok {
|
||||
return peerData.GossipScore, peerData.BehaviourPenalty, peerData.TopicScores, nil
|
||||
}
|
||||
|
||||
@@ -41,12 +41,12 @@ func newPeerStatusScorer(store *peerdata.Store, config *PeerStatusScorerConfig)
|
||||
func (s *PeerStatusScorer) Score(pid peer.ID) float64 {
|
||||
s.store.RLock()
|
||||
defer s.store.RUnlock()
|
||||
return s.score(pid)
|
||||
return s.scoreNoLock(pid)
|
||||
}
|
||||
|
||||
// score is a lock-free version of Score.
|
||||
func (s *PeerStatusScorer) score(pid peer.ID) float64 {
|
||||
if s.isBadPeer(pid) {
|
||||
// scoreNoLock is a lock-free version of Score.
|
||||
func (s *PeerStatusScorer) scoreNoLock(pid peer.ID) float64 {
|
||||
if s.isBadPeerNoLock(pid) {
|
||||
return BadPeerScore
|
||||
}
|
||||
score := float64(0)
|
||||
@@ -70,11 +70,11 @@ func (s *PeerStatusScorer) score(pid peer.ID) float64 {
|
||||
func (s *PeerStatusScorer) IsBadPeer(pid peer.ID) bool {
|
||||
s.store.RLock()
|
||||
defer s.store.RUnlock()
|
||||
return s.isBadPeer(pid)
|
||||
return s.isBadPeerNoLock(pid)
|
||||
}
|
||||
|
||||
// isBadPeer is lock-free version of IsBadPeer.
|
||||
func (s *PeerStatusScorer) isBadPeer(pid peer.ID) bool {
|
||||
// isBadPeerNoLock is lock-free version of IsBadPeer.
|
||||
func (s *PeerStatusScorer) isBadPeerNoLock(pid peer.ID) bool {
|
||||
peerData, ok := s.store.PeerData(pid)
|
||||
if !ok {
|
||||
return false
|
||||
@@ -100,7 +100,7 @@ func (s *PeerStatusScorer) BadPeers() []peer.ID {
|
||||
|
||||
badPeers := make([]peer.ID, 0)
|
||||
for pid := range s.store.Peers() {
|
||||
if s.isBadPeer(pid) {
|
||||
if s.isBadPeerNoLock(pid) {
|
||||
badPeers = append(badPeers, pid)
|
||||
}
|
||||
}
|
||||
@@ -129,11 +129,11 @@ func (s *PeerStatusScorer) SetPeerStatus(pid peer.ID, chainState *pb.Status, val
|
||||
func (s *PeerStatusScorer) PeerStatus(pid peer.ID) (*pb.Status, error) {
|
||||
s.store.RLock()
|
||||
defer s.store.RUnlock()
|
||||
return s.peerStatus(pid)
|
||||
return s.peerStatusNoLock(pid)
|
||||
}
|
||||
|
||||
// peerStatus lock-free version of PeerStatus.
|
||||
func (s *PeerStatusScorer) peerStatus(pid peer.ID) (*pb.Status, error) {
|
||||
// peerStatusNoLock lock-free version of PeerStatus.
|
||||
func (s *PeerStatusScorer) peerStatusNoLock(pid peer.ID) (*pb.Status, error) {
|
||||
if peerData, ok := s.store.PeerData(pid); ok {
|
||||
if peerData.ChainState == nil {
|
||||
return nil, peerdata.ErrNoPeerStatus
|
||||
|
||||
@@ -116,10 +116,10 @@ func (s *Service) ScoreNoLock(pid peer.ID) float64 {
|
||||
if _, ok := s.store.PeerData(pid); !ok {
|
||||
return 0
|
||||
}
|
||||
score += s.scorers.badResponsesScorer.score(pid) * s.scorerWeight(s.scorers.badResponsesScorer)
|
||||
score += s.scorers.blockProviderScorer.score(pid) * s.scorerWeight(s.scorers.blockProviderScorer)
|
||||
score += s.scorers.peerStatusScorer.score(pid) * s.scorerWeight(s.scorers.peerStatusScorer)
|
||||
score += s.scorers.gossipScorer.score(pid) * s.scorerWeight(s.scorers.gossipScorer)
|
||||
score += s.scorers.badResponsesScorer.scoreNoLock(pid) * s.scorerWeight(s.scorers.badResponsesScorer)
|
||||
score += s.scorers.blockProviderScorer.scoreNoLock(pid) * s.scorerWeight(s.scorers.blockProviderScorer)
|
||||
score += s.scorers.peerStatusScorer.scoreNoLock(pid) * s.scorerWeight(s.scorers.peerStatusScorer)
|
||||
score += s.scorers.gossipScorer.scoreNoLock(pid) * s.scorerWeight(s.scorers.gossipScorer)
|
||||
return math.Round(score*ScoreRoundingFactor) / ScoreRoundingFactor
|
||||
}
|
||||
|
||||
@@ -132,14 +132,14 @@ func (s *Service) IsBadPeer(pid peer.ID) bool {
|
||||
|
||||
// IsBadPeerNoLock is a lock-free version of IsBadPeer.
|
||||
func (s *Service) IsBadPeerNoLock(pid peer.ID) bool {
|
||||
if s.scorers.badResponsesScorer.isBadPeer(pid) {
|
||||
if s.scorers.badResponsesScorer.isBadPeerNoLock(pid) {
|
||||
return true
|
||||
}
|
||||
if s.scorers.peerStatusScorer.isBadPeer(pid) {
|
||||
if s.scorers.peerStatusScorer.isBadPeerNoLock(pid) {
|
||||
return true
|
||||
}
|
||||
if features.Get().EnablePeerScorer {
|
||||
if s.scorers.gossipScorer.isBadPeer(pid) {
|
||||
if s.scorers.gossipScorer.isBadPeerNoLock(pid) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,44 +82,49 @@ type Service struct {
|
||||
// NewService initializes a new p2p service compatible with shared.Service interface. No
|
||||
// connections are made until the Start function is called during the service registry startup.
|
||||
func NewService(ctx context.Context, cfg *Config) (*Service, error) {
|
||||
var err error
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
_ = cancel // govet fix for lost cancel. Cancel is handled in service.Stop().
|
||||
|
||||
cfg = validateConfig(cfg)
|
||||
privKey, err := privKey(cfg)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to generate p2p private key")
|
||||
}
|
||||
|
||||
metaData, err := metaDataFromConfig(cfg)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to create peer metadata")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
addrFilter, err := configureFilter(cfg)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to create address filter")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ipLimiter := leakybucket.NewCollector(ipLimit, ipBurst, 30*time.Second, true /* deleteEmptyBuckets */)
|
||||
|
||||
s := &Service{
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg,
|
||||
addrFilter: addrFilter,
|
||||
ipLimiter: ipLimiter,
|
||||
privKey: privKey,
|
||||
metaData: metaData,
|
||||
isPreGenesis: true,
|
||||
joinedTopics: make(map[string]*pubsub.Topic, len(gossipTopicMappings)),
|
||||
subnetsLock: make(map[uint64]*sync.RWMutex),
|
||||
}
|
||||
|
||||
s.cfg = validateConfig(s.cfg)
|
||||
|
||||
dv5Nodes := parseBootStrapAddrs(s.cfg.BootstrapNodeAddr)
|
||||
|
||||
cfg.Discv5BootStrapAddr = dv5Nodes
|
||||
|
||||
ipAddr := prysmnetwork.IPAddr()
|
||||
s.privKey, err = privKey(s.cfg)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to generate p2p private key")
|
||||
return nil, err
|
||||
}
|
||||
s.metaData, err = metaDataFromConfig(s.cfg)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to create peer metadata")
|
||||
return nil, err
|
||||
}
|
||||
s.addrFilter, err = configureFilter(s.cfg)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to create address filter")
|
||||
return nil, err
|
||||
}
|
||||
s.ipLimiter = leakybucket.NewCollector(ipLimit, ipBurst, 30*time.Second, true /* deleteEmptyBuckets */)
|
||||
|
||||
opts := s.buildOptions(ipAddr, s.privKey)
|
||||
opts, err := s.buildOptions(ipAddr, s.privKey)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to build p2p options")
|
||||
}
|
||||
|
||||
h, err := libp2p.New(opts...)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to create p2p host")
|
||||
@@ -285,7 +290,7 @@ func (s *Service) Started() bool {
|
||||
}
|
||||
|
||||
// Encoding returns the configured networking encoding.
|
||||
func (_ *Service) Encoding() encoder.NetworkEncoding {
|
||||
func (*Service) Encoding() encoder.NetworkEncoding {
|
||||
return &encoder.SszNetworkEncoder{}
|
||||
}
|
||||
|
||||
@@ -451,8 +456,8 @@ func (s *Service) connectWithPeer(ctx context.Context, info peer.AddrInfo) error
|
||||
}
|
||||
|
||||
func (s *Service) connectToBootnodes() error {
|
||||
nodes := make([]*enode.Node, 0, len(s.cfg.Discv5BootStrapAddr))
|
||||
for _, addr := range s.cfg.Discv5BootStrapAddr {
|
||||
nodes := make([]*enode.Node, 0, len(s.cfg.Discv5BootStrapAddrs))
|
||||
for _, addr := range s.cfg.Discv5BootStrapAddrs {
|
||||
bootNode, err := enode.Parse(enode.ValidSchemes, addr)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -213,10 +213,9 @@ func TestListenForNewNodes(t *testing.T) {
|
||||
// setup other nodes.
|
||||
cs := startup.NewClockSynchronizer()
|
||||
cfg = &Config{
|
||||
BootstrapNodeAddr: []string{bootNode.String()},
|
||||
Discv5BootStrapAddr: []string{bootNode.String()},
|
||||
MaxPeers: 30,
|
||||
ClockWaiter: cs,
|
||||
Discv5BootStrapAddrs: []string{bootNode.String()},
|
||||
MaxPeers: 30,
|
||||
ClockWaiter: cs,
|
||||
}
|
||||
for i := 1; i <= 5; i++ {
|
||||
h, pkey, ipAddr := createHost(t, port+i)
|
||||
|
||||
@@ -57,10 +57,9 @@ func TestStartDiscV5_DiscoverPeersWithSubnets(t *testing.T) {
|
||||
for i := 1; i <= 3; i++ {
|
||||
port = 3000 + i
|
||||
cfg := &Config{
|
||||
BootstrapNodeAddr: []string{bootNode.String()},
|
||||
Discv5BootStrapAddr: []string{bootNode.String()},
|
||||
MaxPeers: 30,
|
||||
UDPPort: uint(port),
|
||||
Discv5BootStrapAddrs: []string{bootNode.String()},
|
||||
MaxPeers: 30,
|
||||
UDPPort: uint(port),
|
||||
}
|
||||
ipAddr, pkey := createAddrAndPrivKey(t)
|
||||
s = &Service{
|
||||
@@ -88,11 +87,10 @@ func TestStartDiscV5_DiscoverPeersWithSubnets(t *testing.T) {
|
||||
port = 4001
|
||||
gs := startup.NewClockSynchronizer()
|
||||
cfg := &Config{
|
||||
BootstrapNodeAddr: []string{bootNode.String()},
|
||||
Discv5BootStrapAddr: []string{bootNode.String()},
|
||||
MaxPeers: 30,
|
||||
UDPPort: uint(port),
|
||||
ClockWaiter: gs,
|
||||
Discv5BootStrapAddrs: []string{bootNode.String()},
|
||||
MaxPeers: 30,
|
||||
UDPPort: uint(port),
|
||||
ClockWaiter: gs,
|
||||
}
|
||||
s, err = NewService(context.Background(), cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -54,38 +54,45 @@ func privKey(cfg *Config) (*ecdsa.PrivateKey, error) {
|
||||
return privKeyFromFile(cfg.PrivateKey)
|
||||
}
|
||||
|
||||
// Default keys have the next highest precedence, if they exist.
|
||||
_, err := os.Stat(defaultKeyPath)
|
||||
defaultKeysExist := !os.IsNotExist(err)
|
||||
if err != nil && defaultKeysExist {
|
||||
return nil, err
|
||||
}
|
||||
// Default keys have the next highest precedence, if they exist.
|
||||
|
||||
if defaultKeysExist {
|
||||
return privKeyFromFile(defaultKeyPath)
|
||||
}
|
||||
|
||||
// There are no keys on the filesystem, so we need to generate one.
|
||||
priv, _, err := crypto.GenerateSecp256k1Key(rand.Reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// If the StaticPeerID flag is set, save the generated key as the default
|
||||
// key, so that it will be used by default on the next node start.
|
||||
if cfg.StaticPeerID {
|
||||
rawbytes, err := priv.Raw()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dst := make([]byte, hex.EncodedLen(len(rawbytes)))
|
||||
hex.Encode(dst, rawbytes)
|
||||
if err := file.WriteFile(defaultKeyPath, dst); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Infof("Wrote network key to file")
|
||||
// Read the key from the defaultKeyPath file just written
|
||||
// for the strongest guarantee that the next start will be the same as this one.
|
||||
return privKeyFromFile(defaultKeyPath)
|
||||
|
||||
// If the StaticPeerID flag is not set, return the private key.
|
||||
if !cfg.StaticPeerID {
|
||||
return ecdsaprysm.ConvertFromInterfacePrivKey(priv)
|
||||
}
|
||||
return ecdsaprysm.ConvertFromInterfacePrivKey(priv)
|
||||
|
||||
// Save the generated key as the default key, so that it will be used by
|
||||
// default on the next node start.
|
||||
rawbytes, err := priv.Raw()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dst := make([]byte, hex.EncodedLen(len(rawbytes)))
|
||||
hex.Encode(dst, rawbytes)
|
||||
if err := file.WriteFile(defaultKeyPath, dst); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Info("Wrote network key to file")
|
||||
// Read the key from the defaultKeyPath file just written
|
||||
// for the strongest guarantee that the next start will be the same as this one.
|
||||
return privKeyFromFile(defaultKeyPath)
|
||||
}
|
||||
|
||||
// Retrieves a p2p networking private key from a file path.
|
||||
|
||||
@@ -18,8 +18,10 @@ go_library(
|
||||
"@com_github_golang_protobuf//ptypes/timestamp",
|
||||
"@com_github_libp2p_go_libp2p//core/network:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//core/peer:go_default_library",
|
||||
"@io_opencensus_go//trace:go_default_library",
|
||||
"@org_golang_google_grpc//:go_default_library",
|
||||
"@org_golang_google_grpc//codes:go_default_library",
|
||||
"@org_golang_google_grpc//metadata:go_default_library",
|
||||
"@org_golang_google_grpc//status:go_default_library",
|
||||
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
|
||||
],
|
||||
@@ -45,7 +47,9 @@ go_test(
|
||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//crypto:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//p2p/enode:go_default_library",
|
||||
"@com_github_grpc_ecosystem_grpc_gateway_v2//runtime:go_default_library",
|
||||
"@org_golang_google_grpc//:go_default_library",
|
||||
"@org_golang_google_grpc//metadata:go_default_library",
|
||||
"@org_golang_google_grpc//reflection:go_default_library",
|
||||
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
|
||||
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
|
||||
|
||||
@@ -6,7 +6,9 @@ package node
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/empty"
|
||||
@@ -21,8 +23,10 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/io/logs"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v5/runtime/version"
|
||||
"go.opencensus.io/trace"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
@@ -45,6 +49,35 @@ type Server struct {
|
||||
BeaconMonitoringPort int
|
||||
}
|
||||
|
||||
// GetHealth checks the health of the node
|
||||
func (ns *Server) GetHealth(ctx context.Context, request *ethpb.HealthRequest) (*empty.Empty, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "node.GetHealth")
|
||||
defer span.End()
|
||||
|
||||
// Set a timeout for the health check operation
|
||||
timeoutDuration := 10 * time.Second
|
||||
ctx, cancel := context.WithTimeout(ctx, timeoutDuration)
|
||||
defer cancel() // Important to avoid a context leak
|
||||
|
||||
if ns.SyncChecker.Synced() {
|
||||
return &empty.Empty{}, nil
|
||||
}
|
||||
if ns.SyncChecker.Syncing() || ns.SyncChecker.Initialized() {
|
||||
if request.SyncingStatus != 0 {
|
||||
// override the 200 success with the provided request status
|
||||
if err := grpc.SetHeader(ctx, metadata.Pairs("x-http-code", strconv.FormatUint(request.SyncingStatus, 10))); err != nil {
|
||||
return &empty.Empty{}, status.Errorf(codes.Internal, "Could not set custom success code header: %v", err)
|
||||
}
|
||||
return &empty.Empty{}, nil
|
||||
}
|
||||
if err := grpc.SetHeader(ctx, metadata.Pairs("x-http-code", strconv.FormatUint(http.StatusPartialContent, 10))); err != nil {
|
||||
return &empty.Empty{}, status.Errorf(codes.Internal, "Could not set custom success code header: %v", err)
|
||||
}
|
||||
return &empty.Empty{}, nil
|
||||
}
|
||||
return &empty.Empty{}, status.Errorf(codes.Unavailable, "service unavailable")
|
||||
}
|
||||
|
||||
// GetSyncStatus checks the current network sync status of the node.
|
||||
func (ns *Server) GetSyncStatus(_ context.Context, _ *empty.Empty) (*ethpb.SyncStatus, error) {
|
||||
return ðpb.SyncStatus{
|
||||
|
||||
@@ -3,12 +3,14 @@ package node
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
mock "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing"
|
||||
dbutil "github.com/prysmaticlabs/prysm/v5/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p"
|
||||
@@ -22,6 +24,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/util"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/reflection"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
@@ -170,3 +173,53 @@ func TestNodeServer_GetETH1ConnectionStatus(t *testing.T) {
|
||||
assert.Equal(t, ep, res.CurrentAddress)
|
||||
assert.Equal(t, errStr, res.CurrentConnectionError)
|
||||
}
|
||||
|
||||
func TestNodeServer_GetHealth(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *mockSync.Sync
|
||||
customStatus uint64
|
||||
wantedErr string
|
||||
}{
|
||||
{
|
||||
name: "happy path",
|
||||
input: &mockSync.Sync{IsSyncing: false, IsSynced: true},
|
||||
},
|
||||
{
|
||||
name: "syncing",
|
||||
input: &mockSync.Sync{IsSyncing: false},
|
||||
wantedErr: "service unavailable",
|
||||
},
|
||||
{
|
||||
name: "custom sync status",
|
||||
input: &mockSync.Sync{IsSyncing: true},
|
||||
customStatus: 206,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
server := grpc.NewServer()
|
||||
ns := &Server{
|
||||
SyncChecker: tt.input,
|
||||
}
|
||||
ethpb.RegisterNodeServer(server, ns)
|
||||
reflection.Register(server)
|
||||
ctx := grpc.NewContextWithServerTransportStream(context.Background(), &runtime.ServerTransportStream{})
|
||||
_, err := ns.GetHealth(ctx, ðpb.HealthRequest{SyncingStatus: tt.customStatus})
|
||||
if tt.wantedErr == "" {
|
||||
require.NoError(t, err)
|
||||
return
|
||||
}
|
||||
if tt.customStatus != 0 {
|
||||
// Assuming the call was successful, now extract the headers
|
||||
headers, _ := metadata.FromIncomingContext(ctx)
|
||||
// Check for the specific header
|
||||
values, ok := headers["x-http-code"]
|
||||
require.Equal(t, true, ok && len(values) > 0)
|
||||
require.Equal(t, fmt.Sprintf("%d", tt.customStatus), values[0])
|
||||
|
||||
}
|
||||
require.ErrorContains(t, tt.wantedErr, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2697,10 +2697,13 @@ func TestProposer_PrepareBeaconProposer(t *testing.T) {
|
||||
BeaconDB: db,
|
||||
TrackedValidatorsCache: cache.NewTrackedValidatorsCache(),
|
||||
}
|
||||
require.Equal(t, false, proposerServer.TrackedValidatorsCache.Validating())
|
||||
_, err := proposerServer.PrepareBeaconProposer(ctx, tt.args.request)
|
||||
if tt.wantErr != "" {
|
||||
require.ErrorContains(t, tt.wantErr, err)
|
||||
return
|
||||
} else {
|
||||
require.Equal(t, true, proposerServer.TrackedValidatorsCache.Validating())
|
||||
}
|
||||
require.NoError(t, err)
|
||||
val, tracked := proposerServer.TrackedValidatorsCache.Validator(1)
|
||||
|
||||
@@ -108,6 +108,7 @@ go_library(
|
||||
"//crypto/rand:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//encoding/ssz/equality:go_default_library",
|
||||
"//io/file:go_default_library",
|
||||
"//monitoring/tracing:go_default_library",
|
||||
"//network/forks:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
|
||||
@@ -79,6 +79,10 @@ func (c *batchSequencer) update(b batch) {
|
||||
// so we want to copy c to a, then on i=3, d to b, then on i=4 e to c.
|
||||
c.seq[i-done] = c.seq[i]
|
||||
}
|
||||
if done == 1 && len(c.seq) == 1 {
|
||||
c.seq[0] = c.batcher.beforeBatch(c.seq[0])
|
||||
return
|
||||
}
|
||||
// Overwrite the moved batches with the next ones in the sequence.
|
||||
// Continuing the example in the comment above, len(c.seq)==5, done=2, so i=3.
|
||||
// We want to replace index 3 with the batch that should be processed after index 2,
|
||||
|
||||
@@ -64,6 +64,35 @@ func TestBatcherBefore(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBatchSingleItem(t *testing.T) {
|
||||
var min, max, size primitives.Slot
|
||||
// seqLen = 1 means just one worker
|
||||
seqLen := 1
|
||||
min = 0
|
||||
max = 11235
|
||||
size = 64
|
||||
seq := newBatchSequencer(seqLen, min, max, size)
|
||||
got, err := seq.sequence()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(got))
|
||||
b := got[0]
|
||||
|
||||
// calling sequence again should give you the next (earlier) batch
|
||||
seq.update(b.withState(batchImportComplete))
|
||||
next, err := seq.sequence()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(next))
|
||||
require.Equal(t, b.end, next[0].end+size)
|
||||
|
||||
// should get the same batch again when update is called with an error
|
||||
seq.update(next[0].withState(batchErrRetryable))
|
||||
same, err := seq.sequence()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(same))
|
||||
require.Equal(t, next[0].begin, same[0].begin)
|
||||
require.Equal(t, next[0].end, same[0].end)
|
||||
}
|
||||
|
||||
func TestBatchSequencer(t *testing.T) {
|
||||
var min, max, size primitives.Slot
|
||||
seqLen := 8
|
||||
|
||||
@@ -118,6 +118,24 @@ func WithVerifierWaiter(viw InitializerWaiter) ServiceOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithMinimumSlot allows the user to specify a different backfill minimum slot than the spec default of current - MIN_EPOCHS_FOR_BLOCK_REQUESTS.
|
||||
// If this value is greater than current - MIN_EPOCHS_FOR_BLOCK_REQUESTS, it will be ignored with a warning log.
|
||||
func WithMinimumSlot(s primitives.Slot) ServiceOption {
|
||||
ms := func(current primitives.Slot) primitives.Slot {
|
||||
specMin := minimumBackfillSlot(current)
|
||||
if s < specMin {
|
||||
return s
|
||||
}
|
||||
log.WithField("userSlot", s).WithField("specMinSlot", specMin).
|
||||
Warn("Ignoring user-specified slot > MIN_EPOCHS_FOR_BLOCK_REQUESTS.")
|
||||
return specMin
|
||||
}
|
||||
return func(s *Service) error {
|
||||
s.ms = ms
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// NewService initializes the backfill Service. Like all implementations of the Service interface,
|
||||
// the service won't begin its runloop until Start() is called.
|
||||
func NewService(ctx context.Context, su *Store, bStore *filesystem.BlobStorage, cw startup.ClockWaiter, p p2p.P2P, pa PeerAssigner, opts ...ServiceOption) (*Service, error) {
|
||||
@@ -289,7 +307,7 @@ func (s *Service) Start() {
|
||||
if ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
if allComplete := s.updateComplete(); allComplete {
|
||||
if s.updateComplete() {
|
||||
return
|
||||
}
|
||||
s.importBatches(ctx)
|
||||
@@ -316,11 +334,11 @@ func (s *Service) downscore(b batch) {
|
||||
s.p2p.Peers().Scorers().BadResponsesScorer().Increment(b.blockPid)
|
||||
}
|
||||
|
||||
func (s *Service) Stop() error {
|
||||
func (*Service) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) Status() error {
|
||||
func (*Service) Status() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ func (m mockMinimumSlotter) minimumSlot(_ primitives.Slot) primitives.Slot {
|
||||
type mockInitalizerWaiter struct {
|
||||
}
|
||||
|
||||
func (mi *mockInitalizerWaiter) WaitForInitializer(ctx context.Context) (*verification.Initializer, error) {
|
||||
func (*mockInitalizerWaiter) WaitForInitializer(_ context.Context) (*verification.Initializer, error) {
|
||||
return &verification.Initializer{}, nil
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func TestServiceInit(t *testing.T) {
|
||||
}
|
||||
go srv.Start()
|
||||
todo := make([]batch, 0)
|
||||
todo = testReadN(t, ctx, pool.todoChan, nWorkers, todo)
|
||||
todo = testReadN(ctx, t, pool.todoChan, nWorkers, todo)
|
||||
require.Equal(t, nWorkers, len(todo))
|
||||
for i := 0; i < remaining; i++ {
|
||||
b := todo[i]
|
||||
@@ -75,7 +75,7 @@ func TestServiceInit(t *testing.T) {
|
||||
b.state = batchImportable
|
||||
}
|
||||
pool.finishedChan <- b
|
||||
todo = testReadN(t, ctx, pool.todoChan, 1, todo)
|
||||
todo = testReadN(ctx, t, pool.todoChan, 1, todo)
|
||||
}
|
||||
require.Equal(t, remaining+nWorkers, len(todo))
|
||||
for i := remaining; i < remaining+nWorkers; i++ {
|
||||
@@ -90,14 +90,12 @@ func TestMinimumBackfillSlot(t *testing.T) {
|
||||
minSlot := minimumBackfillSlot(primitives.Slot(currSlot))
|
||||
require.Equal(t, 100*params.BeaconConfig().SlotsPerEpoch, minSlot)
|
||||
|
||||
oe = helpers.MinEpochsForBlockRequests()
|
||||
|
||||
currSlot = oe.Mul(uint64(params.BeaconConfig().SlotsPerEpoch))
|
||||
minSlot = minimumBackfillSlot(primitives.Slot(currSlot))
|
||||
require.Equal(t, primitives.Slot(1), minSlot)
|
||||
}
|
||||
|
||||
func testReadN(t *testing.T, ctx context.Context, c chan batch, n int, into []batch) []batch {
|
||||
func testReadN(ctx context.Context, t *testing.T, c chan batch, n int, into []batch) []batch {
|
||||
for i := 0; i < n; i++ {
|
||||
select {
|
||||
case b := <-c:
|
||||
@@ -109,3 +107,28 @@ func testReadN(t *testing.T, ctx context.Context, c chan batch, n int, into []ba
|
||||
}
|
||||
return into
|
||||
}
|
||||
|
||||
func TestBackfillMinSlotDefault(t *testing.T) {
|
||||
oe := helpers.MinEpochsForBlockRequests()
|
||||
current := primitives.Slot((oe + 100).Mul(uint64(params.BeaconConfig().SlotsPerEpoch)))
|
||||
s := &Service{}
|
||||
specMin := minimumBackfillSlot(current)
|
||||
|
||||
t.Run("equal to specMin", func(t *testing.T) {
|
||||
opt := WithMinimumSlot(specMin)
|
||||
require.NoError(t, opt(s))
|
||||
require.Equal(t, specMin, s.ms(current))
|
||||
})
|
||||
t.Run("older than specMin", func(t *testing.T) {
|
||||
opt := WithMinimumSlot(specMin - 1)
|
||||
require.NoError(t, opt(s))
|
||||
// if WithMinimumSlot is older than the spec minimum, we should use it.
|
||||
require.Equal(t, specMin-1, s.ms(current))
|
||||
})
|
||||
t.Run("newer than specMin", func(t *testing.T) {
|
||||
opt := WithMinimumSlot(specMin + 1)
|
||||
require.NoError(t, opt(s))
|
||||
// if WithMinimumSlot is newer than the spec minimum, we should use the spec minimum
|
||||
require.Equal(t, specMin, s.ms(current))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -144,6 +144,12 @@ var (
|
||||
Help: "Time for gossiped blob sidecars to arrive",
|
||||
},
|
||||
)
|
||||
blobSidecarVerificationGossipSummary = promauto.NewSummary(
|
||||
prometheus.SummaryOpts{
|
||||
Name: "gossip_blob_sidecar_verification_milliseconds",
|
||||
Help: "Time to verify gossiped blob sidecars",
|
||||
},
|
||||
)
|
||||
|
||||
// Sync committee verification performance.
|
||||
syncMessagesForUnknownBlocks = promauto.NewCounter(
|
||||
|
||||
@@ -53,7 +53,7 @@ const rangeLimit uint64 = 1024
|
||||
const seenBlockSize = 1000
|
||||
const seenBlobSize = seenBlockSize * 4 // Each block can have max 4 blobs. Worst case 164kB for cache.
|
||||
const seenUnaggregatedAttSize = 20000
|
||||
const seenAggregatedAttSize = 1024
|
||||
const seenAggregatedAttSize = 16384
|
||||
const seenSyncMsgSize = 1000 // Maximum of 512 sync committee members, 1000 is a safe amount.
|
||||
const seenSyncContributionSize = 512 // Maximum of SYNC_COMMITTEE_SIZE as specified by the spec.
|
||||
const seenExitSize = 100
|
||||
|
||||
@@ -321,7 +321,7 @@ func (s *Service) wrapAndReportValidation(topic string, v wrappedVal) (string, p
|
||||
}
|
||||
}
|
||||
|
||||
// subscribe to a static subnet with the given topic and index.A given validator and subscription handler is
|
||||
// subscribe to a static subnet with the given topic and index. A given validator and subscription handler is
|
||||
// used to handle messages from the subnet. The base protobuf message is used to initialize new messages for decoding.
|
||||
func (s *Service) subscribeStaticWithSubnets(topic string, validator wrappedVal, handle subHandler, digest [4]byte, subnetCount uint64) {
|
||||
genRoot := s.cfg.clock.GenesisValidatorsRoot()
|
||||
|
||||
@@ -2,10 +2,16 @@ package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/transition/interop"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/features"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/io/file"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -33,7 +39,10 @@ func (s *Service) beaconBlockSubscriber(ctx context.Context, msg proto.Message)
|
||||
if r != [32]byte{} {
|
||||
s.setBadBlock(ctx, r) // Setting head block as bad.
|
||||
} else {
|
||||
// TODO(13721): Remove this once we can deprecate the flag.
|
||||
interop.WriteBlockToDisk(signed, true /*failed*/)
|
||||
|
||||
saveInvalidBlockToTemp(signed)
|
||||
s.setBadBlock(ctx, root)
|
||||
}
|
||||
}
|
||||
@@ -45,3 +54,21 @@ func (s *Service) beaconBlockSubscriber(ctx context.Context, msg proto.Message)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// WriteInvalidBlockToDisk as a block ssz. Writes to temp directory.
|
||||
func saveInvalidBlockToTemp(block interfaces.ReadOnlySignedBeaconBlock) {
|
||||
if !features.Get().SaveInvalidBlock {
|
||||
return
|
||||
}
|
||||
filename := fmt.Sprintf("beacon_block_%d.ssz", block.Block().Slot())
|
||||
fp := path.Join(os.TempDir(), filename)
|
||||
log.Warnf("Writing invalid block to disk at %s", fp)
|
||||
enc, err := block.MarshalSSZ()
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to ssz encode block")
|
||||
return
|
||||
}
|
||||
if err := file.WriteFile(fp, enc); err != nil {
|
||||
log.WithError(err).Error("Failed to write to disk")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,21 @@ package sync
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/verification"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/features"
|
||||
"github.com/prysmaticlabs/prysm/v5/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/crypto/rand"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v5/io/file"
|
||||
eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
prysmTime "github.com/prysmaticlabs/prysm/v5/time"
|
||||
"github.com/prysmaticlabs/prysm/v5/time/slots"
|
||||
@@ -109,6 +113,7 @@ func (s *Service) validateBlob(ctx context.Context, pid peer.ID, msg *pubsub.Mes
|
||||
}
|
||||
|
||||
if err := vf.SidecarKzgProofVerified(); err != nil {
|
||||
saveInvalidBlobToTemp(blob)
|
||||
return pubsub.ValidationReject, err
|
||||
}
|
||||
|
||||
@@ -118,10 +123,12 @@ func (s *Service) validateBlob(ctx context.Context, pid peer.ID, msg *pubsub.Mes
|
||||
|
||||
fields := blobFields(blob)
|
||||
sinceSlotStartTime := receivedTime.Sub(startTime)
|
||||
validationTime := s.cfg.clock.Now().Sub(receivedTime)
|
||||
fields["sinceSlotStartTime"] = sinceSlotStartTime
|
||||
fields["validationTime"] = s.cfg.clock.Now().Sub(receivedTime)
|
||||
fields["validationTime"] = validationTime
|
||||
log.WithFields(fields).Debug("Received blob sidecar gossip")
|
||||
|
||||
blobSidecarVerificationGossipSummary.Observe(float64(validationTime.Milliseconds()))
|
||||
blobSidecarArrivalGossipSummary.Observe(float64(sinceSlotStartTime.Milliseconds()))
|
||||
|
||||
vBlobData, err := vf.VerifiedROBlob()
|
||||
@@ -165,3 +172,21 @@ func blobFields(b blocks.ROBlob) logrus.Fields {
|
||||
func computeSubnetForBlobSidecar(index uint64) uint64 {
|
||||
return index % params.BeaconConfig().BlobsidecarSubnetCount
|
||||
}
|
||||
|
||||
// saveInvalidBlobToTemp as a block ssz. Writes to temp directory.
|
||||
func saveInvalidBlobToTemp(b blocks.ROBlob) {
|
||||
if !features.Get().SaveInvalidBlob {
|
||||
return
|
||||
}
|
||||
filename := fmt.Sprintf("blob_sidecar_%#x_%d_%d.ssz", b.BlockRoot(), b.Slot(), b.Index)
|
||||
fp := path.Join(os.TempDir(), filename)
|
||||
log.Warnf("Writing invalid blob sidecar to disk at %s", fp)
|
||||
enc, err := b.MarshalSSZ()
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to ssz encode blob sidecar")
|
||||
return
|
||||
}
|
||||
if err := file.WriteFile(fp, enc); err != nil {
|
||||
log.WithError(err).Error("Failed to write to disk")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ go_library(
|
||||
"fake.go",
|
||||
"initializer.go",
|
||||
"interface.go",
|
||||
"metrics.go",
|
||||
"mock.go",
|
||||
"result.go",
|
||||
],
|
||||
@@ -35,6 +36,8 @@ go_library(
|
||||
"//time/slots:go_default_library",
|
||||
"@com_github_hashicorp_golang_lru//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_prometheus_client_golang//prometheus:go_default_library",
|
||||
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -192,10 +192,13 @@ func (bv *ROBlobVerifier) ValidProposerSignature(ctx context.Context) (err error
|
||||
if seen {
|
||||
if err != nil {
|
||||
log.WithFields(logging.BlobFields(bv.blob)).WithError(err).Debug("reusing failed proposer signature validation from cache")
|
||||
blobVerificationProposerSignatureCache.WithLabelValues("hit-invalid").Inc()
|
||||
return ErrInvalidProposerSignature
|
||||
}
|
||||
blobVerificationProposerSignatureCache.WithLabelValues("hit-valid").Inc()
|
||||
return nil
|
||||
}
|
||||
blobVerificationProposerSignatureCache.WithLabelValues("miss").Inc()
|
||||
|
||||
// Retrieve the parent state to fallback to full verification.
|
||||
parent, err := bv.parentState(ctx)
|
||||
|
||||
16
beacon-chain/verification/metrics.go
Normal file
16
beacon-chain/verification/metrics.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package verification
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
var (
|
||||
blobVerificationProposerSignatureCache = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "blob_verification_proposer_signature_cache",
|
||||
Help: "BlobSidecar proposer signature cache result.",
|
||||
},
|
||||
[]string{"result"},
|
||||
)
|
||||
)
|
||||
@@ -38,6 +38,7 @@ go_library(
|
||||
"@com_github_ethereum_go_ethereum//log:go_default_library",
|
||||
"@com_github_ipfs_go_log_v2//:go_default_library",
|
||||
"@com_github_joonix_log//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
],
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
gethlog "github.com/ethereum/go-ethereum/log"
|
||||
golog "github.com/ipfs/go-log/v2"
|
||||
joonix "github.com/joonix/log"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/builder"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/node"
|
||||
"github.com/prysmaticlabs/prysm/v5/cmd"
|
||||
@@ -143,84 +144,96 @@ var appFlags = []cli.Flag{
|
||||
bflags.EnableExperimentalBackfill,
|
||||
bflags.BackfillBatchSize,
|
||||
bflags.BackfillWorkerCount,
|
||||
bflags.BackfillOldestSlot,
|
||||
}
|
||||
|
||||
func init() {
|
||||
appFlags = cmd.WrapFlags(append(appFlags, features.BeaconChainFlags...))
|
||||
}
|
||||
|
||||
func before(ctx *cli.Context) error {
|
||||
// Load flags from config file, if specified.
|
||||
if err := cmd.LoadFlagsFromConfig(ctx, appFlags); err != nil {
|
||||
return errors.Wrap(err, "failed to load flags from config file")
|
||||
}
|
||||
|
||||
format := ctx.String(cmd.LogFormat.Name)
|
||||
|
||||
switch format {
|
||||
case "text":
|
||||
formatter := new(prefixed.TextFormatter)
|
||||
formatter.TimestampFormat = "2006-01-02 15:04:05"
|
||||
formatter.FullTimestamp = true
|
||||
|
||||
// If persistent log files are written - we disable the log messages coloring because
|
||||
// the colors are ANSI codes and seen as gibberish in the log files.
|
||||
formatter.DisableColors = ctx.String(cmd.LogFileName.Name) != ""
|
||||
logrus.SetFormatter(formatter)
|
||||
case "fluentd":
|
||||
f := joonix.NewFormatter()
|
||||
|
||||
if err := joonix.DisableTimestampFormat(f); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
logrus.SetFormatter(f)
|
||||
case "json":
|
||||
logrus.SetFormatter(&logrus.JSONFormatter{})
|
||||
case "journald":
|
||||
if err := journald.Enable(); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unknown log format %s", format)
|
||||
}
|
||||
|
||||
logFileName := ctx.String(cmd.LogFileName.Name)
|
||||
if logFileName != "" {
|
||||
if err := logs.ConfigurePersistentLogging(logFileName); err != nil {
|
||||
log.WithError(err).Error("Failed to configuring logging to disk.")
|
||||
}
|
||||
}
|
||||
|
||||
if err := cmd.ExpandSingleEndpointIfFile(ctx, flags.ExecutionEngineEndpoint); err != nil {
|
||||
return errors.Wrap(err, "failed to expand single endpoint")
|
||||
}
|
||||
|
||||
if ctx.IsSet(flags.SetGCPercent.Name) {
|
||||
runtimeDebug.SetGCPercent(ctx.Int(flags.SetGCPercent.Name))
|
||||
}
|
||||
|
||||
if err := debug.Setup(ctx); err != nil {
|
||||
return errors.Wrap(err, "failed to setup debug")
|
||||
}
|
||||
|
||||
if err := fdlimits.SetMaxFdLimits(); err != nil {
|
||||
return errors.Wrap(err, "failed to set max fd limits")
|
||||
}
|
||||
|
||||
return cmd.ValidateNoArgs(ctx)
|
||||
}
|
||||
|
||||
func main() {
|
||||
// rctx = root context with cancellation.
|
||||
// note other instances of ctx in this func are *cli.Context.
|
||||
rctx, cancel := context.WithCancel(context.Background())
|
||||
app := cli.App{}
|
||||
app.Name = "beacon-chain"
|
||||
app.Usage = "this is a beacon chain implementation for Ethereum"
|
||||
app.Action = func(ctx *cli.Context) error {
|
||||
if err := startNode(ctx, cancel); err != nil {
|
||||
return cli.Exit(err.Error(), 1)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
app.Version = version.Version()
|
||||
app.Commands = []*cli.Command{
|
||||
dbcommands.Commands,
|
||||
jwtcommands.Commands,
|
||||
}
|
||||
|
||||
app.Flags = appFlags
|
||||
|
||||
app.Before = func(ctx *cli.Context) error {
|
||||
// Load flags from config file, if specified.
|
||||
if err := cmd.LoadFlagsFromConfig(ctx, app.Flags); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
format := ctx.String(cmd.LogFormat.Name)
|
||||
switch format {
|
||||
case "text":
|
||||
formatter := new(prefixed.TextFormatter)
|
||||
formatter.TimestampFormat = "2006-01-02 15:04:05"
|
||||
formatter.FullTimestamp = true
|
||||
// If persistent log files are written - we disable the log messages coloring because
|
||||
// the colors are ANSI codes and seen as gibberish in the log files.
|
||||
formatter.DisableColors = ctx.String(cmd.LogFileName.Name) != ""
|
||||
logrus.SetFormatter(formatter)
|
||||
case "fluentd":
|
||||
f := joonix.NewFormatter()
|
||||
if err := joonix.DisableTimestampFormat(f); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
logrus.SetFormatter(f)
|
||||
case "json":
|
||||
logrus.SetFormatter(&logrus.JSONFormatter{})
|
||||
case "journald":
|
||||
if err := journald.Enable(); err != nil {
|
||||
app := cli.App{
|
||||
Name: "beacon-chain",
|
||||
Usage: "this is a beacon chain implementation for Ethereum",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
if err := startNode(ctx, cancel); err != nil {
|
||||
log.Fatal(err.Error())
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unknown log format %s", format)
|
||||
}
|
||||
|
||||
logFileName := ctx.String(cmd.LogFileName.Name)
|
||||
if logFileName != "" {
|
||||
if err := logs.ConfigurePersistentLogging(logFileName); err != nil {
|
||||
log.WithError(err).Error("Failed to configuring logging to disk.")
|
||||
}
|
||||
}
|
||||
if err := cmd.ExpandSingleEndpointIfFile(ctx, flags.ExecutionEngineEndpoint); err != nil {
|
||||
return err
|
||||
}
|
||||
if ctx.IsSet(flags.SetGCPercent.Name) {
|
||||
runtimeDebug.SetGCPercent(ctx.Int(flags.SetGCPercent.Name))
|
||||
}
|
||||
if err := debug.Setup(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := fdlimits.SetMaxFdLimits(); err != nil {
|
||||
return err
|
||||
}
|
||||
return cmd.ValidateNoArgs(ctx)
|
||||
return nil
|
||||
},
|
||||
Version: version.Version(),
|
||||
Commands: []*cli.Command{
|
||||
dbcommands.Commands,
|
||||
jwtcommands.Commands,
|
||||
},
|
||||
Flags: appFlags,
|
||||
Before: before,
|
||||
}
|
||||
|
||||
defer func() {
|
||||
|
||||
@@ -9,6 +9,7 @@ go_library(
|
||||
"//beacon-chain/node:go_default_library",
|
||||
"//beacon-chain/sync/backfill:go_default_library",
|
||||
"//cmd/beacon-chain/sync/backfill/flags:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ var (
|
||||
Usage: "Number of blocks per backfill batch. " +
|
||||
"A larger number will request more blocks at once from peers, but also consume more system memory to " +
|
||||
"hold batches in memory during processing. This has a multiplicative effect with " + backfillWorkerCountName + ".",
|
||||
Value: 64,
|
||||
Value: 32,
|
||||
}
|
||||
// BackfillWorkerCount allows users to tune the number of concurrent backfill batches to download, to maximize
|
||||
// network utilization at the cost of higher memory.
|
||||
@@ -35,4 +35,9 @@ var (
|
||||
"This has a multiplicative effect with " + backfillBatchSizeName + ".",
|
||||
Value: 2,
|
||||
}
|
||||
BackfillOldestSlot = &cli.Uint64Flag{
|
||||
Name: "backfill-oldest-slot",
|
||||
Usage: "Specifies the oldest slot that backfill should download. " +
|
||||
"If this value is greater than current_slot - MIN_EPOCHS_FOR_BLOCK_REQUESTS, it will be ignored with a warning log.",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/node"
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/sync/backfill"
|
||||
"github.com/prysmaticlabs/prysm/v5/cmd/beacon-chain/sync/backfill/flags"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -11,11 +12,17 @@ import (
|
||||
// from flag parsing.
|
||||
func BeaconNodeOptions(c *cli.Context) ([]node.Option, error) {
|
||||
opt := func(node *node.BeaconNode) (err error) {
|
||||
node.BackfillOpts = []backfill.ServiceOption{
|
||||
bno := []backfill.ServiceOption{
|
||||
backfill.WithBatchSize(c.Uint64(flags.BackfillBatchSize.Name)),
|
||||
backfill.WithWorkerCount(c.Int(flags.BackfillWorkerCount.Name)),
|
||||
backfill.WithEnableBackfill(c.Bool(flags.EnableExperimentalBackfill.Name)),
|
||||
}
|
||||
// The zero value of this uint flag would be genesis, so we use IsSet to differentiate nil from zero case.
|
||||
if c.IsSet(flags.BackfillOldestSlot.Name) {
|
||||
uv := c.Uint64(flags.BackfillBatchSize.Name)
|
||||
bno = append(bno, backfill.WithMinimumSlot(primitives.Slot(uv)))
|
||||
}
|
||||
node.BackfillOpts = bno
|
||||
return nil
|
||||
}
|
||||
return []node.Option{opt}, nil
|
||||
|
||||
@@ -140,6 +140,7 @@ var appHelpFlagGroups = []flagGroup{
|
||||
backfill.EnableExperimentalBackfill,
|
||||
backfill.BackfillWorkerCount,
|
||||
backfill.BackfillBatchSize,
|
||||
backfill.BackfillOldestSlot,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -72,6 +72,10 @@ type Flags struct {
|
||||
PrepareAllPayloads bool // PrepareAllPayloads informs the engine to prepare a block on every slot.
|
||||
// BlobSaveFsync requires blob saving to block on fsync to ensure blobs are durably persisted before passing DA.
|
||||
BlobSaveFsync bool
|
||||
|
||||
SaveInvalidBlock bool // SaveInvalidBlock saves invalid block to temp.
|
||||
SaveInvalidBlob bool // SaveInvalidBlob saves invalid blob to temp.
|
||||
|
||||
// KeystoreImportDebounceInterval specifies the time duration the validator waits to reload new keys if they have
|
||||
// changed on disk. This feature is for advanced use cases only.
|
||||
KeystoreImportDebounceInterval time.Duration
|
||||
@@ -187,6 +191,16 @@ func ConfigureBeaconChain(ctx *cli.Context) error {
|
||||
cfg.WriteSSZStateTransitions = true
|
||||
}
|
||||
|
||||
if ctx.Bool(saveInvalidBlockTempFlag.Name) {
|
||||
logEnabled(saveInvalidBlockTempFlag)
|
||||
cfg.SaveInvalidBlock = true
|
||||
}
|
||||
|
||||
if ctx.Bool(saveInvalidBlobTempFlag.Name) {
|
||||
logEnabled(saveInvalidBlobTempFlag)
|
||||
cfg.SaveInvalidBlob = true
|
||||
}
|
||||
|
||||
if ctx.IsSet(disableGRPCConnectionLogging.Name) {
|
||||
logDisabled(disableGRPCConnectionLogging)
|
||||
cfg.DisableGRPCConnectionLogs = true
|
||||
|
||||
@@ -42,6 +42,14 @@ var (
|
||||
Name: "interop-write-ssz-state-transitions",
|
||||
Usage: "Writes SSZ states to disk after attempted state transitio.",
|
||||
}
|
||||
saveInvalidBlockTempFlag = &cli.BoolFlag{
|
||||
Name: "save-invalid-block-temp",
|
||||
Usage: "Writes invalid blocks to temp directory.",
|
||||
}
|
||||
saveInvalidBlobTempFlag = &cli.BoolFlag{
|
||||
Name: "save-invalid-blob-temp",
|
||||
Usage: "Writes invalid blobs to temp directory.",
|
||||
}
|
||||
disableGRPCConnectionLogging = &cli.BoolFlag{
|
||||
Name: "disable-grpc-connection-logging",
|
||||
Usage: "Disables displaying logs for newly connected grpc clients.",
|
||||
@@ -196,6 +204,8 @@ var BeaconChainFlags = append(deprecatedBeaconFlags, append(deprecatedFlags, []c
|
||||
devModeFlag,
|
||||
enableExperimentalState,
|
||||
writeSSZStateTransitionsFlag,
|
||||
saveInvalidBlockTempFlag,
|
||||
saveInvalidBlobTempFlag,
|
||||
disableGRPCConnectionLogging,
|
||||
HoleskyTestnet,
|
||||
PraterTestnet,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
load(
|
||||
"@bazel_skylib//rules:common_settings.bzl",
|
||||
"string_flag",
|
||||
|
||||
@@ -16,8 +16,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v5/runtime/version"
|
||||
)
|
||||
|
||||
var errExecutionUnmarshal = errors.New("unable to unmarshal execution engine data")
|
||||
|
||||
// PayloadIDBytes defines a custom type for Payload IDs used by the engine API
|
||||
// client with proper JSON Marshal and Unmarshal methods to hex.
|
||||
type PayloadIDBytes [8]byte
|
||||
|
||||
@@ -113,7 +113,6 @@ ssz_proto_files(
|
||||
name = "ssz_proto_files",
|
||||
srcs = [
|
||||
"beacon_block.proto",
|
||||
"beacon_state.proto",
|
||||
],
|
||||
config = select({
|
||||
"//conditions:default": "mainnet",
|
||||
|
||||
938
proto/eth/v1/beacon_state.pb.go
generated
938
proto/eth/v1/beacon_state.pb.go
generated
@@ -1,938 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc v4.25.1
|
||||
// source: proto/eth/v1/beacon_state.proto
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
|
||||
github_com_prysmaticlabs_go_bitfield "github.com/prysmaticlabs/go-bitfield"
|
||||
github_com_prysmaticlabs_prysm_v5_consensus_types_primitives "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
_ "github.com/prysmaticlabs/prysm/v5/proto/eth/ext"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
_ "google.golang.org/protobuf/types/descriptorpb"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type BeaconState struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
GenesisTime uint64 `protobuf:"varint,1001,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"`
|
||||
GenesisValidatorsRoot []byte `protobuf:"bytes,1002,opt,name=genesis_validators_root,json=genesisValidatorsRoot,proto3" json:"genesis_validators_root,omitempty" ssz-size:"32"`
|
||||
Slot github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot `protobuf:"varint,1003,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"`
|
||||
Fork *Fork `protobuf:"bytes,1004,opt,name=fork,proto3" json:"fork,omitempty"`
|
||||
LatestBlockHeader *BeaconBlockHeader `protobuf:"bytes,2001,opt,name=latest_block_header,json=latestBlockHeader,proto3" json:"latest_block_header,omitempty"`
|
||||
BlockRoots [][]byte `protobuf:"bytes,2002,rep,name=block_roots,json=blockRoots,proto3" json:"block_roots,omitempty" ssz-size:"8192,32"`
|
||||
StateRoots [][]byte `protobuf:"bytes,2003,rep,name=state_roots,json=stateRoots,proto3" json:"state_roots,omitempty" ssz-size:"8192,32"`
|
||||
HistoricalRoots [][]byte `protobuf:"bytes,2004,rep,name=historical_roots,json=historicalRoots,proto3" json:"historical_roots,omitempty" ssz-max:"16777216" ssz-size:"?,32"`
|
||||
Eth1Data *Eth1Data `protobuf:"bytes,3001,opt,name=eth1_data,json=eth1Data,proto3" json:"eth1_data,omitempty"`
|
||||
Eth1DataVotes []*Eth1Data `protobuf:"bytes,3002,rep,name=eth1_data_votes,json=eth1DataVotes,proto3" json:"eth1_data_votes,omitempty" ssz-max:"2048"`
|
||||
Eth1DepositIndex uint64 `protobuf:"varint,3003,opt,name=eth1_deposit_index,json=eth1DepositIndex,proto3" json:"eth1_deposit_index,omitempty"`
|
||||
Validators []*Validator `protobuf:"bytes,4001,rep,name=validators,proto3" json:"validators,omitempty" ssz-max:"1099511627776"`
|
||||
Balances []uint64 `protobuf:"varint,4002,rep,packed,name=balances,proto3" json:"balances,omitempty" ssz-max:"1099511627776"`
|
||||
RandaoMixes [][]byte `protobuf:"bytes,5001,rep,name=randao_mixes,json=randaoMixes,proto3" json:"randao_mixes,omitempty" ssz-size:"65536,32"`
|
||||
Slashings []uint64 `protobuf:"varint,6001,rep,packed,name=slashings,proto3" json:"slashings,omitempty" ssz-size:"8192"`
|
||||
PreviousEpochAttestations []*PendingAttestation `protobuf:"bytes,7001,rep,name=previous_epoch_attestations,json=previousEpochAttestations,proto3" json:"previous_epoch_attestations,omitempty" ssz-max:"4096"`
|
||||
CurrentEpochAttestations []*PendingAttestation `protobuf:"bytes,7002,rep,name=current_epoch_attestations,json=currentEpochAttestations,proto3" json:"current_epoch_attestations,omitempty" ssz-max:"4096"`
|
||||
JustificationBits github_com_prysmaticlabs_go_bitfield.Bitvector4 `protobuf:"bytes,8001,opt,name=justification_bits,json=justificationBits,proto3" json:"justification_bits,omitempty" cast-type:"github.com/prysmaticlabs/go-bitfield.Bitvector4" ssz-size:"1"`
|
||||
PreviousJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8002,opt,name=previous_justified_checkpoint,json=previousJustifiedCheckpoint,proto3" json:"previous_justified_checkpoint,omitempty"`
|
||||
CurrentJustifiedCheckpoint *Checkpoint `protobuf:"bytes,8003,opt,name=current_justified_checkpoint,json=currentJustifiedCheckpoint,proto3" json:"current_justified_checkpoint,omitempty"`
|
||||
FinalizedCheckpoint *Checkpoint `protobuf:"bytes,8004,opt,name=finalized_checkpoint,json=finalizedCheckpoint,proto3" json:"finalized_checkpoint,omitempty"`
|
||||
}
|
||||
|
||||
func (x *BeaconState) Reset() {
|
||||
*x = BeaconState{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *BeaconState) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BeaconState) ProtoMessage() {}
|
||||
|
||||
func (x *BeaconState) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use BeaconState.ProtoReflect.Descriptor instead.
|
||||
func (*BeaconState) Descriptor() ([]byte, []int) {
|
||||
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetGenesisTime() uint64 {
|
||||
if x != nil {
|
||||
return x.GenesisTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetGenesisValidatorsRoot() []byte {
|
||||
if x != nil {
|
||||
return x.GenesisValidatorsRoot
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetSlot() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot {
|
||||
if x != nil {
|
||||
return x.Slot
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot(0)
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetFork() *Fork {
|
||||
if x != nil {
|
||||
return x.Fork
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetLatestBlockHeader() *BeaconBlockHeader {
|
||||
if x != nil {
|
||||
return x.LatestBlockHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetBlockRoots() [][]byte {
|
||||
if x != nil {
|
||||
return x.BlockRoots
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetStateRoots() [][]byte {
|
||||
if x != nil {
|
||||
return x.StateRoots
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetHistoricalRoots() [][]byte {
|
||||
if x != nil {
|
||||
return x.HistoricalRoots
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetEth1Data() *Eth1Data {
|
||||
if x != nil {
|
||||
return x.Eth1Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetEth1DataVotes() []*Eth1Data {
|
||||
if x != nil {
|
||||
return x.Eth1DataVotes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetEth1DepositIndex() uint64 {
|
||||
if x != nil {
|
||||
return x.Eth1DepositIndex
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetValidators() []*Validator {
|
||||
if x != nil {
|
||||
return x.Validators
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetBalances() []uint64 {
|
||||
if x != nil {
|
||||
return x.Balances
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetRandaoMixes() [][]byte {
|
||||
if x != nil {
|
||||
return x.RandaoMixes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetSlashings() []uint64 {
|
||||
if x != nil {
|
||||
return x.Slashings
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetPreviousEpochAttestations() []*PendingAttestation {
|
||||
if x != nil {
|
||||
return x.PreviousEpochAttestations
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetCurrentEpochAttestations() []*PendingAttestation {
|
||||
if x != nil {
|
||||
return x.CurrentEpochAttestations
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetJustificationBits() github_com_prysmaticlabs_go_bitfield.Bitvector4 {
|
||||
if x != nil {
|
||||
return x.JustificationBits
|
||||
}
|
||||
return github_com_prysmaticlabs_go_bitfield.Bitvector4(nil)
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetPreviousJustifiedCheckpoint() *Checkpoint {
|
||||
if x != nil {
|
||||
return x.PreviousJustifiedCheckpoint
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetCurrentJustifiedCheckpoint() *Checkpoint {
|
||||
if x != nil {
|
||||
return x.CurrentJustifiedCheckpoint
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BeaconState) GetFinalizedCheckpoint() *Checkpoint {
|
||||
if x != nil {
|
||||
return x.FinalizedCheckpoint
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type PendingAttestation struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
AggregationBits github_com_prysmaticlabs_go_bitfield.Bitlist `protobuf:"bytes,1,opt,name=aggregation_bits,json=aggregationBits,proto3" json:"aggregation_bits,omitempty" cast-type:"github.com/prysmaticlabs/go-bitfield.Bitlist" ssz-max:"2048"`
|
||||
Data *AttestationData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
InclusionDelay github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot `protobuf:"varint,3,opt,name=inclusion_delay,json=inclusionDelay,proto3" json:"inclusion_delay,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"`
|
||||
ProposerIndex github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex `protobuf:"varint,4,opt,name=proposer_index,json=proposerIndex,proto3" json:"proposer_index,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"`
|
||||
}
|
||||
|
||||
func (x *PendingAttestation) Reset() {
|
||||
*x = PendingAttestation{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *PendingAttestation) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PendingAttestation) ProtoMessage() {}
|
||||
|
||||
func (x *PendingAttestation) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use PendingAttestation.ProtoReflect.Descriptor instead.
|
||||
func (*PendingAttestation) Descriptor() ([]byte, []int) {
|
||||
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *PendingAttestation) GetAggregationBits() github_com_prysmaticlabs_go_bitfield.Bitlist {
|
||||
if x != nil {
|
||||
return x.AggregationBits
|
||||
}
|
||||
return github_com_prysmaticlabs_go_bitfield.Bitlist(nil)
|
||||
}
|
||||
|
||||
func (x *PendingAttestation) GetData() *AttestationData {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *PendingAttestation) GetInclusionDelay() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot {
|
||||
if x != nil {
|
||||
return x.InclusionDelay
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot(0)
|
||||
}
|
||||
|
||||
func (x *PendingAttestation) GetProposerIndex() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex {
|
||||
if x != nil {
|
||||
return x.ProposerIndex
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex(0)
|
||||
}
|
||||
|
||||
type Committee struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Index github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.CommitteeIndex `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.CommitteeIndex"`
|
||||
Slot github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot `protobuf:"varint,2,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"`
|
||||
Validators []github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex `protobuf:"varint,3,rep,packed,name=validators,proto3" json:"validators,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"`
|
||||
}
|
||||
|
||||
func (x *Committee) Reset() {
|
||||
*x = Committee{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Committee) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Committee) ProtoMessage() {}
|
||||
|
||||
func (x *Committee) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Committee.ProtoReflect.Descriptor instead.
|
||||
func (*Committee) Descriptor() ([]byte, []int) {
|
||||
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Committee) GetIndex() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.CommitteeIndex {
|
||||
if x != nil {
|
||||
return x.Index
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.CommitteeIndex(0)
|
||||
}
|
||||
|
||||
func (x *Committee) GetSlot() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot {
|
||||
if x != nil {
|
||||
return x.Slot
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot(0)
|
||||
}
|
||||
|
||||
func (x *Committee) GetValidators() []github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex {
|
||||
if x != nil {
|
||||
return x.Validators
|
||||
}
|
||||
return []github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.ValidatorIndex(nil)
|
||||
}
|
||||
|
||||
type Fork struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
PreviousVersion []byte `protobuf:"bytes,1,opt,name=previous_version,json=previousVersion,proto3" json:"previous_version,omitempty" ssz-size:"4"`
|
||||
CurrentVersion []byte `protobuf:"bytes,2,opt,name=current_version,json=currentVersion,proto3" json:"current_version,omitempty" ssz-size:"4"`
|
||||
Epoch github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch `protobuf:"varint,3,opt,name=epoch,proto3" json:"epoch,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Epoch"`
|
||||
}
|
||||
|
||||
func (x *Fork) Reset() {
|
||||
*x = Fork{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Fork) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Fork) ProtoMessage() {}
|
||||
|
||||
func (x *Fork) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Fork.ProtoReflect.Descriptor instead.
|
||||
func (*Fork) Descriptor() ([]byte, []int) {
|
||||
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *Fork) GetPreviousVersion() []byte {
|
||||
if x != nil {
|
||||
return x.PreviousVersion
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Fork) GetCurrentVersion() []byte {
|
||||
if x != nil {
|
||||
return x.CurrentVersion
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Fork) GetEpoch() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch {
|
||||
if x != nil {
|
||||
return x.Epoch
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Epoch(0)
|
||||
}
|
||||
|
||||
type ForkChoiceHeadsResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Data []*ForkChoiceHead `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ForkChoiceHeadsResponse) Reset() {
|
||||
*x = ForkChoiceHeadsResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ForkChoiceHeadsResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ForkChoiceHeadsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ForkChoiceHeadsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ForkChoiceHeadsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ForkChoiceHeadsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *ForkChoiceHeadsResponse) GetData() []*ForkChoiceHead {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ForkChoiceHead struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Root []byte `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty" ssz-size:"32"`
|
||||
Slot github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot `protobuf:"varint,2,opt,name=slot,proto3" json:"slot,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"`
|
||||
}
|
||||
|
||||
func (x *ForkChoiceHead) Reset() {
|
||||
*x = ForkChoiceHead{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ForkChoiceHead) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ForkChoiceHead) ProtoMessage() {}
|
||||
|
||||
func (x *ForkChoiceHead) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ForkChoiceHead.ProtoReflect.Descriptor instead.
|
||||
func (*ForkChoiceHead) Descriptor() ([]byte, []int) {
|
||||
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *ForkChoiceHead) GetRoot() []byte {
|
||||
if x != nil {
|
||||
return x.Root
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ForkChoiceHead) GetSlot() github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot {
|
||||
if x != nil {
|
||||
return x.Slot
|
||||
}
|
||||
return github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot(0)
|
||||
}
|
||||
|
||||
type BeaconStateResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Data *BeaconState `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *BeaconStateResponse) Reset() {
|
||||
*x = BeaconStateResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *BeaconStateResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BeaconStateResponse) ProtoMessage() {}
|
||||
|
||||
func (x *BeaconStateResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_eth_v1_beacon_state_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use BeaconStateResponse.ProtoReflect.Descriptor instead.
|
||||
func (*BeaconStateResponse) Descriptor() ([]byte, []int) {
|
||||
return file_proto_eth_v1_beacon_state_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *BeaconStateResponse) GetData() *BeaconState {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_proto_eth_v1_beacon_state_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_proto_eth_v1_beacon_state_proto_rawDesc = []byte{
|
||||
0x0a, 0x1f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x62,
|
||||
0x65, 0x61, 0x63, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x12, 0x0f, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
|
||||
0x76, 0x31, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f,
|
||||
0x65, 0x78, 0x74, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x1a, 0x1e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x1a, 0x1f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x1a, 0x1c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31,
|
||||
0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x22, 0xdb, 0x0b, 0x0a, 0x0b, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65,
|
||||
0x12, 0x22, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65,
|
||||
0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73,
|
||||
0x54, 0x69, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x17, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f,
|
||||
0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18,
|
||||
0xea, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x15,
|
||||
0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72,
|
||||
0x73, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x5a, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0xeb, 0x07,
|
||||
0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
|
||||
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61,
|
||||
0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d,
|
||||
0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f,
|
||||
0x74, 0x12, 0x2a, 0x0a, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x18, 0xec, 0x07, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x15, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
|
||||
0x76, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x52, 0x04, 0x66, 0x6f, 0x72, 0x6b, 0x12, 0x53, 0x0a,
|
||||
0x13, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65,
|
||||
0x61, 0x64, 0x65, 0x72, 0x18, 0xd1, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x65, 0x74,
|
||||
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x65,
|
||||
0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52,
|
||||
0x11, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64,
|
||||
0x65, 0x72, 0x12, 0x2d, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74,
|
||||
0x73, 0x18, 0xd2, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x0b, 0x8a, 0xb5, 0x18, 0x07, 0x38, 0x31,
|
||||
0x39, 0x32, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74,
|
||||
0x73, 0x12, 0x2d, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x73,
|
||||
0x18, 0xd3, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x0b, 0x8a, 0xb5, 0x18, 0x07, 0x38, 0x31, 0x39,
|
||||
0x32, 0x2c, 0x33, 0x32, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x73,
|
||||
0x12, 0x40, 0x0a, 0x10, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x72,
|
||||
0x6f, 0x6f, 0x74, 0x73, 0x18, 0xd4, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x14, 0x8a, 0xb5, 0x18,
|
||||
0x04, 0x3f, 0x2c, 0x33, 0x32, 0x92, 0xb5, 0x18, 0x08, 0x31, 0x36, 0x37, 0x37, 0x37, 0x32, 0x31,
|
||||
0x36, 0x52, 0x0f, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x6f, 0x6f,
|
||||
0x74, 0x73, 0x12, 0x37, 0x0a, 0x09, 0x65, 0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18,
|
||||
0xb9, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
|
||||
0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74,
|
||||
0x61, 0x52, 0x08, 0x65, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61, 0x12, 0x4c, 0x0a, 0x0f, 0x65,
|
||||
0x74, 0x68, 0x31, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x76, 0x6f, 0x74, 0x65, 0x73, 0x18, 0xba,
|
||||
0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x31, 0x44, 0x61, 0x74, 0x61,
|
||||
0x42, 0x08, 0x92, 0xb5, 0x18, 0x04, 0x32, 0x30, 0x34, 0x38, 0x52, 0x0d, 0x65, 0x74, 0x68, 0x31,
|
||||
0x44, 0x61, 0x74, 0x61, 0x56, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x65, 0x74, 0x68,
|
||||
0x31, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18,
|
||||
0xbb, 0x17, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x65, 0x74, 0x68, 0x31, 0x44, 0x65, 0x70, 0x6f,
|
||||
0x73, 0x69, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x4e, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69,
|
||||
0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0xa1, 0x1f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e,
|
||||
0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x42, 0x11, 0x92, 0xb5, 0x18, 0x0d, 0x31,
|
||||
0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x0a, 0x76, 0x61,
|
||||
0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61,
|
||||
0x6e, 0x63, 0x65, 0x73, 0x18, 0xa2, 0x1f, 0x20, 0x03, 0x28, 0x04, 0x42, 0x11, 0x92, 0xb5, 0x18,
|
||||
0x0d, 0x31, 0x30, 0x39, 0x39, 0x35, 0x31, 0x31, 0x36, 0x32, 0x37, 0x37, 0x37, 0x36, 0x52, 0x08,
|
||||
0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x0c, 0x72, 0x61, 0x6e, 0x64,
|
||||
0x61, 0x6f, 0x5f, 0x6d, 0x69, 0x78, 0x65, 0x73, 0x18, 0x89, 0x27, 0x20, 0x03, 0x28, 0x0c, 0x42,
|
||||
0x0c, 0x8a, 0xb5, 0x18, 0x08, 0x36, 0x35, 0x35, 0x33, 0x36, 0x2c, 0x33, 0x32, 0x52, 0x0b, 0x72,
|
||||
0x61, 0x6e, 0x64, 0x61, 0x6f, 0x4d, 0x69, 0x78, 0x65, 0x73, 0x12, 0x27, 0x0a, 0x09, 0x73, 0x6c,
|
||||
0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x73, 0x18, 0xf1, 0x2e, 0x20, 0x03, 0x28, 0x04, 0x42, 0x08,
|
||||
0x8a, 0xb5, 0x18, 0x04, 0x38, 0x31, 0x39, 0x32, 0x52, 0x09, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69,
|
||||
0x6e, 0x67, 0x73, 0x12, 0x6e, 0x0a, 0x1b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f,
|
||||
0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x18, 0xd9, 0x36, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x65, 0x74, 0x68, 0x65,
|
||||
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64,
|
||||
0x69, 0x6e, 0x67, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08,
|
||||
0x92, 0xb5, 0x18, 0x04, 0x34, 0x30, 0x39, 0x36, 0x52, 0x19, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f,
|
||||
0x75, 0x73, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x12, 0x6c, 0x0a, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65,
|
||||
0x70, 0x6f, 0x63, 0x68, 0x5f, 0x61, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x18, 0xda, 0x36, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x65, 0x6e, 0x64, 0x69,
|
||||
0x6e, 0x67, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0x92,
|
||||
0xb5, 0x18, 0x04, 0x34, 0x30, 0x39, 0x36, 0x52, 0x18, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74,
|
||||
0x45, 0x70, 0x6f, 0x63, 0x68, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x12, 0x68, 0x0a, 0x12, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x5f, 0x62, 0x69, 0x74, 0x73, 0x18, 0xc1, 0x3e, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x38,
|
||||
0x82, 0xb5, 0x18, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70,
|
||||
0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x67, 0x6f, 0x2d,
|
||||
0x62, 0x69, 0x74, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x76, 0x65, 0x63, 0x74,
|
||||
0x6f, 0x72, 0x34, 0x8a, 0xb5, 0x18, 0x01, 0x31, 0x52, 0x11, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66,
|
||||
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x69, 0x74, 0x73, 0x12, 0x60, 0x0a, 0x1d, 0x70,
|
||||
0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x65,
|
||||
0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc2, 0x3e, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74,
|
||||
0x52, 0x1b, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66,
|
||||
0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x5e, 0x0a,
|
||||
0x1c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69,
|
||||
0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc3, 0x3e,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e,
|
||||
0x74, 0x52, 0x1a, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x4a, 0x75, 0x73, 0x74, 0x69, 0x66,
|
||||
0x69, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x4f, 0x0a,
|
||||
0x14, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b,
|
||||
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0xc4, 0x3e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x43,
|
||||
0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x13, 0x66, 0x69, 0x6e, 0x61, 0x6c,
|
||||
0x69, 0x7a, 0x65, 0x64, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0x97,
|
||||
0x03, 0x0a, 0x12, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x41, 0x74, 0x74, 0x65, 0x73, 0x74,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x63, 0x0a, 0x10, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x62, 0x69, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42,
|
||||
0x38, 0x82, 0xb5, 0x18, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
|
||||
0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x67, 0x6f,
|
||||
0x2d, 0x62, 0x69, 0x74, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2e, 0x42, 0x69, 0x74, 0x6c, 0x69, 0x73,
|
||||
0x74, 0x92, 0xb5, 0x18, 0x04, 0x32, 0x30, 0x34, 0x38, 0x52, 0x0f, 0x61, 0x67, 0x67, 0x72, 0x65,
|
||||
0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x69, 0x74, 0x73, 0x12, 0x34, 0x0a, 0x04, 0x64, 0x61,
|
||||
0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x74, 0x74, 0x65, 0x73,
|
||||
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61,
|
||||
0x12, 0x6e, 0x0a, 0x0f, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x65,
|
||||
0x6c, 0x61, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18, 0x41, 0x67,
|
||||
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61,
|
||||
0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35,
|
||||
0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73,
|
||||
0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74,
|
||||
0x52, 0x0e, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x6c, 0x61, 0x79,
|
||||
0x12, 0x76, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x64,
|
||||
0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4f, 0x82, 0xb5, 0x18, 0x4b, 0x67, 0x69,
|
||||
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74,
|
||||
0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f,
|
||||
0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f,
|
||||
0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64,
|
||||
0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x70, 0x6f,
|
||||
0x73, 0x65, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x22, 0xbe, 0x02, 0x0a, 0x09, 0x43, 0x6f, 0x6d,
|
||||
0x6d, 0x69, 0x74, 0x74, 0x65, 0x65, 0x12, 0x65, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x4f, 0x82, 0xb5, 0x18, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75,
|
||||
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c,
|
||||
0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69,
|
||||
0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x74, 0x65,
|
||||
0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x59, 0x0a,
|
||||
0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42, 0x45, 0x82, 0xb5, 0x18,
|
||||
0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73,
|
||||
0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f,
|
||||
0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70,
|
||||
0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6c,
|
||||
0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x12, 0x6f, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69,
|
||||
0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x04, 0x42, 0x4f, 0x82, 0xb5,
|
||||
0x18, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79,
|
||||
0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d,
|
||||
0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79,
|
||||
0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56,
|
||||
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0a, 0x76,
|
||||
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x22, 0xc6, 0x01, 0x0a, 0x04, 0x46, 0x6f,
|
||||
0x72, 0x6b, 0x12, 0x30, 0x0a, 0x10, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x76,
|
||||
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x05, 0x8a, 0xb5,
|
||||
0x18, 0x01, 0x34, 0x52, 0x0f, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x56, 0x65, 0x72,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x0a, 0x0f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f,
|
||||
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x05, 0x8a,
|
||||
0xb5, 0x18, 0x01, 0x34, 0x52, 0x0e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x56, 0x65, 0x72,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x12, 0x5c, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x04, 0x42, 0x46, 0x82, 0xb5, 0x18, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
|
||||
0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62,
|
||||
0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x6e, 0x73, 0x75, 0x73, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69,
|
||||
0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x52, 0x05, 0x65, 0x70, 0x6f,
|
||||
0x63, 0x68, 0x22, 0x4e, 0x0a, 0x17, 0x46, 0x6f, 0x72, 0x6b, 0x43, 0x68, 0x6f, 0x69, 0x63, 0x65,
|
||||
0x48, 0x65, 0x61, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a,
|
||||
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x65, 0x74,
|
||||
0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6f,
|
||||
0x72, 0x6b, 0x43, 0x68, 0x6f, 0x69, 0x63, 0x65, 0x48, 0x65, 0x61, 0x64, 0x52, 0x04, 0x64, 0x61,
|
||||
0x74, 0x61, 0x22, 0x87, 0x01, 0x0a, 0x0e, 0x46, 0x6f, 0x72, 0x6b, 0x43, 0x68, 0x6f, 0x69, 0x63,
|
||||
0x65, 0x48, 0x65, 0x61, 0x64, 0x12, 0x1a, 0x0a, 0x04, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x04, 0x72, 0x6f, 0x6f,
|
||||
0x74, 0x12, 0x59, 0x0a, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x42,
|
||||
0x45, 0x82, 0xb5, 0x18, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
|
||||
0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72,
|
||||
0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73,
|
||||
0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65,
|
||||
0x73, 0x2e, 0x53, 0x6c, 0x6f, 0x74, 0x52, 0x04, 0x73, 0x6c, 0x6f, 0x74, 0x22, 0x47, 0x0a, 0x13,
|
||||
0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x0b, 0x32, 0x1c, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52,
|
||||
0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x7d, 0x0a, 0x13, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68,
|
||||
0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x42, 0x10, 0x42, 0x65,
|
||||
0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01,
|
||||
0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79,
|
||||
0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d,
|
||||
0x2f, 0x76, 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31,
|
||||
0xaa, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e,
|
||||
0x56, 0x31, 0xca, 0x02, 0x0f, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74,
|
||||
0x68, 0x5c, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_proto_eth_v1_beacon_state_proto_rawDescOnce sync.Once
|
||||
file_proto_eth_v1_beacon_state_proto_rawDescData = file_proto_eth_v1_beacon_state_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_proto_eth_v1_beacon_state_proto_rawDescGZIP() []byte {
|
||||
file_proto_eth_v1_beacon_state_proto_rawDescOnce.Do(func() {
|
||||
file_proto_eth_v1_beacon_state_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_eth_v1_beacon_state_proto_rawDescData)
|
||||
})
|
||||
return file_proto_eth_v1_beacon_state_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_eth_v1_beacon_state_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_proto_eth_v1_beacon_state_proto_goTypes = []interface{}{
|
||||
(*BeaconState)(nil), // 0: ethereum.eth.v1.BeaconState
|
||||
(*PendingAttestation)(nil), // 1: ethereum.eth.v1.PendingAttestation
|
||||
(*Committee)(nil), // 2: ethereum.eth.v1.Committee
|
||||
(*Fork)(nil), // 3: ethereum.eth.v1.Fork
|
||||
(*ForkChoiceHeadsResponse)(nil), // 4: ethereum.eth.v1.ForkChoiceHeadsResponse
|
||||
(*ForkChoiceHead)(nil), // 5: ethereum.eth.v1.ForkChoiceHead
|
||||
(*BeaconStateResponse)(nil), // 6: ethereum.eth.v1.BeaconStateResponse
|
||||
(*BeaconBlockHeader)(nil), // 7: ethereum.eth.v1.BeaconBlockHeader
|
||||
(*Eth1Data)(nil), // 8: ethereum.eth.v1.Eth1Data
|
||||
(*Validator)(nil), // 9: ethereum.eth.v1.Validator
|
||||
(*Checkpoint)(nil), // 10: ethereum.eth.v1.Checkpoint
|
||||
(*AttestationData)(nil), // 11: ethereum.eth.v1.AttestationData
|
||||
}
|
||||
var file_proto_eth_v1_beacon_state_proto_depIdxs = []int32{
|
||||
3, // 0: ethereum.eth.v1.BeaconState.fork:type_name -> ethereum.eth.v1.Fork
|
||||
7, // 1: ethereum.eth.v1.BeaconState.latest_block_header:type_name -> ethereum.eth.v1.BeaconBlockHeader
|
||||
8, // 2: ethereum.eth.v1.BeaconState.eth1_data:type_name -> ethereum.eth.v1.Eth1Data
|
||||
8, // 3: ethereum.eth.v1.BeaconState.eth1_data_votes:type_name -> ethereum.eth.v1.Eth1Data
|
||||
9, // 4: ethereum.eth.v1.BeaconState.validators:type_name -> ethereum.eth.v1.Validator
|
||||
1, // 5: ethereum.eth.v1.BeaconState.previous_epoch_attestations:type_name -> ethereum.eth.v1.PendingAttestation
|
||||
1, // 6: ethereum.eth.v1.BeaconState.current_epoch_attestations:type_name -> ethereum.eth.v1.PendingAttestation
|
||||
10, // 7: ethereum.eth.v1.BeaconState.previous_justified_checkpoint:type_name -> ethereum.eth.v1.Checkpoint
|
||||
10, // 8: ethereum.eth.v1.BeaconState.current_justified_checkpoint:type_name -> ethereum.eth.v1.Checkpoint
|
||||
10, // 9: ethereum.eth.v1.BeaconState.finalized_checkpoint:type_name -> ethereum.eth.v1.Checkpoint
|
||||
11, // 10: ethereum.eth.v1.PendingAttestation.data:type_name -> ethereum.eth.v1.AttestationData
|
||||
5, // 11: ethereum.eth.v1.ForkChoiceHeadsResponse.data:type_name -> ethereum.eth.v1.ForkChoiceHead
|
||||
0, // 12: ethereum.eth.v1.BeaconStateResponse.data:type_name -> ethereum.eth.v1.BeaconState
|
||||
13, // [13:13] is the sub-list for method output_type
|
||||
13, // [13:13] is the sub-list for method input_type
|
||||
13, // [13:13] is the sub-list for extension type_name
|
||||
13, // [13:13] is the sub-list for extension extendee
|
||||
0, // [0:13] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proto_eth_v1_beacon_state_proto_init() }
|
||||
func file_proto_eth_v1_beacon_state_proto_init() {
|
||||
if File_proto_eth_v1_beacon_state_proto != nil {
|
||||
return
|
||||
}
|
||||
file_proto_eth_v1_attestation_proto_init()
|
||||
file_proto_eth_v1_beacon_block_proto_init()
|
||||
file_proto_eth_v1_validator_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proto_eth_v1_beacon_state_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*BeaconState); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_eth_v1_beacon_state_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*PendingAttestation); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_eth_v1_beacon_state_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Committee); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_eth_v1_beacon_state_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Fork); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_eth_v1_beacon_state_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ForkChoiceHeadsResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_eth_v1_beacon_state_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ForkChoiceHead); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_eth_v1_beacon_state_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*BeaconStateResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_eth_v1_beacon_state_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 7,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_proto_eth_v1_beacon_state_proto_goTypes,
|
||||
DependencyIndexes: file_proto_eth_v1_beacon_state_proto_depIdxs,
|
||||
MessageInfos: file_proto_eth_v1_beacon_state_proto_msgTypes,
|
||||
}.Build()
|
||||
File_proto_eth_v1_beacon_state_proto = out.File
|
||||
file_proto_eth_v1_beacon_state_proto_rawDesc = nil
|
||||
file_proto_eth_v1_beacon_state_proto_goTypes = nil
|
||||
file_proto_eth_v1_beacon_state_proto_depIdxs = nil
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
package ignore
|
||||
@@ -1,107 +0,0 @@
|
||||
// Copyright 2020 Prysmatic Labs.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
syntax = "proto3";
|
||||
|
||||
package ethereum.eth.v1;
|
||||
|
||||
import "google/protobuf/descriptor.proto";
|
||||
|
||||
import "proto/eth/ext/options.proto";
|
||||
import "proto/eth/v1/attestation.proto";
|
||||
import "proto/eth/v1/beacon_block.proto";
|
||||
import "proto/eth/v1/validator.proto";
|
||||
|
||||
option csharp_namespace = "Ethereum.Eth.V1";
|
||||
option go_package = "github.com/prysmaticlabs/prysm/v5/proto/eth/v1";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "BeaconStateProto";
|
||||
option java_package = "org.ethereum.eth.v1";
|
||||
option php_namespace = "Ethereum\\Eth\\v1";
|
||||
|
||||
message BeaconState {
|
||||
// Versioning [1001-2000]
|
||||
uint64 genesis_time = 1001;
|
||||
bytes genesis_validators_root = 1002 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
uint64 slot = 1003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
|
||||
Fork fork = 1004;
|
||||
|
||||
// History [2001-3000]
|
||||
BeaconBlockHeader latest_block_header = 2001;
|
||||
repeated bytes block_roots = 2002 [(ethereum.eth.ext.ssz_size) = "block_roots.size"];
|
||||
repeated bytes state_roots = 2003 [(ethereum.eth.ext.ssz_size) = "state_roots.size"];
|
||||
repeated bytes historical_roots = 2004 [(ethereum.eth.ext.ssz_size) = "?,32", (ethereum.eth.ext.ssz_max) = "16777216"];
|
||||
|
||||
// Eth1 [3001-4000]
|
||||
Eth1Data eth1_data = 3001;
|
||||
repeated Eth1Data eth1_data_votes = 3002 [(ethereum.eth.ext.ssz_max) = "eth1_data_votes.size"];
|
||||
uint64 eth1_deposit_index = 3003;
|
||||
|
||||
// Registry [4001-5000]
|
||||
repeated Validator validators = 4001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
repeated uint64 balances = 4002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
|
||||
// Randomness [5001-6000]
|
||||
repeated bytes randao_mixes = 5001 [(ethereum.eth.ext.ssz_size) = "randao_mixes.size"];
|
||||
|
||||
// Slashings [6001-7000]
|
||||
repeated uint64 slashings = 6001 [(ethereum.eth.ext.ssz_size) = "slashings.size"];
|
||||
|
||||
// Attestations [7001-8000]
|
||||
repeated PendingAttestation previous_epoch_attestations = 7001 [(ethereum.eth.ext.ssz_max) = "previous_epoch_attestations.max"];
|
||||
repeated PendingAttestation current_epoch_attestations = 7002 [(ethereum.eth.ext.ssz_max) = "current_epoch_attestations.max"];
|
||||
|
||||
// Finality [8001-9000]
|
||||
// Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
|
||||
bytes justification_bits = 8001 [(ethereum.eth.ext.ssz_size) = "1", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
|
||||
Checkpoint previous_justified_checkpoint = 8002;
|
||||
Checkpoint current_justified_checkpoint = 8003;
|
||||
Checkpoint finalized_checkpoint = 8004;
|
||||
}
|
||||
|
||||
message PendingAttestation {
|
||||
// Bitfield representation of validator indices that have voted exactly
|
||||
// the same vote and have been aggregated into this attestation.
|
||||
bytes aggregation_bits = 1 [(ethereum.eth.ext.ssz_max) = "2048", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitlist"];
|
||||
AttestationData data = 2;
|
||||
// The difference of when attestation gets created and get included on chain.
|
||||
uint64 inclusion_delay = 3 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
|
||||
// The proposer who included the attestation in the block.
|
||||
uint64 proposer_index = 4 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"];
|
||||
}
|
||||
|
||||
message Committee {
|
||||
uint64 index = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.CommitteeIndex"];
|
||||
uint64 slot = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
|
||||
repeated uint64 validators = 3 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"];
|
||||
}
|
||||
|
||||
// Fork structure used for indicating beacon chain versioning and forks.
|
||||
message Fork {
|
||||
bytes previous_version = 1 [(ethereum.eth.ext.ssz_size) = "4"];
|
||||
bytes current_version = 2 [(ethereum.eth.ext.ssz_size) = "4"];
|
||||
uint64 epoch = 3 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Epoch"];
|
||||
}
|
||||
|
||||
message ForkChoiceHeadsResponse {
|
||||
repeated ForkChoiceHead data = 1;
|
||||
}
|
||||
|
||||
message ForkChoiceHead {
|
||||
bytes root = 1 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
uint64 slot = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
|
||||
}
|
||||
|
||||
message BeaconStateResponse {
|
||||
BeaconState data = 1;
|
||||
}
|
||||
@@ -99,7 +99,6 @@ ssz_proto_files(
|
||||
srcs = [
|
||||
"beacon_block.proto",
|
||||
"beacon_lightclient.proto",
|
||||
"beacon_state.proto",
|
||||
"sync_committee.proto",
|
||||
"validator.proto",
|
||||
"withdrawals.proto",
|
||||
|
||||
2004
proto/eth/v2/beacon_state.pb.go
generated
2004
proto/eth/v2/beacon_state.pb.go
generated
File diff suppressed because it is too large
Load Diff
@@ -1,4 +0,0 @@
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
package ignore
|
||||
@@ -1,243 +0,0 @@
|
||||
// Copyright 2021 Prysmatic Labs.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
syntax = "proto3";
|
||||
|
||||
package ethereum.eth.v2;
|
||||
|
||||
import "proto/eth/ext/options.proto";
|
||||
import "proto/eth/v1/attestation.proto";
|
||||
import "proto/eth/v1/beacon_block.proto";
|
||||
import "proto/eth/v1/beacon_state.proto";
|
||||
import "proto/eth/v1/validator.proto";
|
||||
import "proto/eth/v2/sync_committee.proto";
|
||||
import "proto/eth/v2/version.proto";
|
||||
import "proto/engine/v1/execution_engine.proto";
|
||||
|
||||
option csharp_namespace = "Ethereum.Eth.V2";
|
||||
option go_package = "github.com/prysmaticlabs/prysm/v5/proto/eth/v2;eth";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "SyncCommitteeProto";
|
||||
option java_package = "org.ethereum.eth.v2";
|
||||
option php_namespace = "Ethereum\\Eth\\v2";
|
||||
|
||||
message BeaconState {
|
||||
// Versioning [1001-2000]
|
||||
uint64 genesis_time = 1001;
|
||||
bytes genesis_validators_root = 1002 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
uint64 slot = 1003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
|
||||
v1.Fork fork = 1004;
|
||||
|
||||
// History [2001-3000]
|
||||
v1.BeaconBlockHeader latest_block_header = 2001;
|
||||
repeated bytes block_roots = 2002 [(ethereum.eth.ext.ssz_size) = "block_roots.size"];
|
||||
repeated bytes state_roots = 2003 [(ethereum.eth.ext.ssz_size) = "state_roots.size"];
|
||||
repeated bytes historical_roots = 2004 [(ethereum.eth.ext.ssz_size) = "?,32", (ethereum.eth.ext.ssz_max) = "16777216"];
|
||||
|
||||
// Eth1 [3001-4000]
|
||||
v1.Eth1Data eth1_data = 3001;
|
||||
repeated v1.Eth1Data eth1_data_votes = 3002 [(ethereum.eth.ext.ssz_max) = "eth1_data_votes.size"];
|
||||
uint64 eth1_deposit_index = 3003;
|
||||
|
||||
// Registry [4001-5000]
|
||||
repeated v1.Validator validators = 4001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
repeated uint64 balances = 4002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
|
||||
// Randomness [5001-6000]
|
||||
repeated bytes randao_mixes = 5001 [(ethereum.eth.ext.ssz_size) = "randao_mixes.size"];
|
||||
|
||||
// Slashings [6001-7000]
|
||||
repeated uint64 slashings = 6001 [(ethereum.eth.ext.ssz_size) = "slashings.size"];
|
||||
|
||||
// Participation [7001-8000]
|
||||
bytes previous_epoch_participation = 7001 [(ethereum.eth.ext.ssz_max) = "1099511627776"]; // [New in Altair, replaced previous_epoch_attestations]
|
||||
bytes current_epoch_participation = 7002 [(ethereum.eth.ext.ssz_max) = "1099511627776"]; // [New in Altair, replaced current_epoch_attestations]
|
||||
|
||||
// Finality [8001-9000]
|
||||
// Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
|
||||
bytes justification_bits = 8001 [(ethereum.eth.ext.ssz_size) = "1", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
|
||||
v1.Checkpoint previous_justified_checkpoint = 8002;
|
||||
v1.Checkpoint current_justified_checkpoint = 8003;
|
||||
v1.Checkpoint finalized_checkpoint = 8004;
|
||||
|
||||
// New Altair fields [9001-10000]
|
||||
repeated uint64 inactivity_scores = 9001 [(ethereum.eth.ext.ssz_max) = "1099511627776"]; // [New in Altair]
|
||||
SyncCommittee current_sync_committee = 9002; // [New in Altair]
|
||||
SyncCommittee next_sync_committee = 9003; // [New in Altair]
|
||||
}
|
||||
|
||||
message BeaconStateBellatrix {
|
||||
// Versioning [1001-2000]
|
||||
uint64 genesis_time = 1001;
|
||||
bytes genesis_validators_root = 1002 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
uint64 slot = 1003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
|
||||
v1.Fork fork = 1004;
|
||||
|
||||
// History [2001-3000]
|
||||
v1.BeaconBlockHeader latest_block_header = 2001;
|
||||
repeated bytes block_roots = 2002 [(ethereum.eth.ext.ssz_size) = "block_roots.size"];
|
||||
repeated bytes state_roots = 2003 [(ethereum.eth.ext.ssz_size) = "state_roots.size"];
|
||||
repeated bytes historical_roots = 2004 [(ethereum.eth.ext.ssz_size) = "?,32", (ethereum.eth.ext.ssz_max) = "16777216"];
|
||||
|
||||
// Eth1 [3001-4000]
|
||||
v1.Eth1Data eth1_data = 3001;
|
||||
repeated v1.Eth1Data eth1_data_votes = 3002 [(ethereum.eth.ext.ssz_max) = "eth1_data_votes.size"];
|
||||
uint64 eth1_deposit_index = 3003;
|
||||
|
||||
// Registry [4001-5000]
|
||||
repeated v1.Validator validators = 4001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
repeated uint64 balances = 4002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
|
||||
// Randomness [5001-6000]
|
||||
repeated bytes randao_mixes = 5001 [(ethereum.eth.ext.ssz_size) = "randao_mixes.size"];
|
||||
|
||||
// Slashings [6001-7000]
|
||||
repeated uint64 slashings = 6001 [(ethereum.eth.ext.ssz_size) = "slashings.size"];
|
||||
|
||||
// Participation [7001-8000]
|
||||
bytes previous_epoch_participation = 7001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
bytes current_epoch_participation = 7002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
|
||||
// Finality [8001-9000]
|
||||
// Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
|
||||
bytes justification_bits = 8001 [(ethereum.eth.ext.ssz_size) = "1", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
|
||||
v1.Checkpoint previous_justified_checkpoint = 8002;
|
||||
v1.Checkpoint current_justified_checkpoint = 8003;
|
||||
v1.Checkpoint finalized_checkpoint = 8004;
|
||||
|
||||
// Altair fields [9001-10000]
|
||||
repeated uint64 inactivity_scores = 9001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
SyncCommittee current_sync_committee = 9002; // [New in Altair]
|
||||
SyncCommittee next_sync_committee = 9003; // [New in Altair]
|
||||
|
||||
// Bellatrix fields [10001-11000]
|
||||
engine.v1.ExecutionPayloadHeader latest_execution_payload_header = 10001; // [New in Bellatrix]
|
||||
}
|
||||
|
||||
message BeaconStateCapella {
|
||||
// Versioning [1001-2000]
|
||||
uint64 genesis_time = 1001;
|
||||
bytes genesis_validators_root = 1002 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
uint64 slot = 1003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
|
||||
v1.Fork fork = 1004;
|
||||
|
||||
// History [2001-3000]
|
||||
v1.BeaconBlockHeader latest_block_header = 2001;
|
||||
repeated bytes block_roots = 2002 [(ethereum.eth.ext.ssz_size) = "block_roots.size"];
|
||||
repeated bytes state_roots = 2003 [(ethereum.eth.ext.ssz_size) = "state_roots.size"];
|
||||
repeated bytes historical_roots = 2004 [(ethereum.eth.ext.ssz_size) = "?,32", (ethereum.eth.ext.ssz_max) = "16777216"];
|
||||
|
||||
// Eth1 [3001-4000]
|
||||
v1.Eth1Data eth1_data = 3001;
|
||||
repeated v1.Eth1Data eth1_data_votes = 3002 [(ethereum.eth.ext.ssz_max) = "eth1_data_votes.size"];
|
||||
uint64 eth1_deposit_index = 3003;
|
||||
|
||||
// Registry [4001-5000]
|
||||
repeated v1.Validator validators = 4001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
repeated uint64 balances = 4002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
|
||||
// Randomness [5001-6000]
|
||||
repeated bytes randao_mixes = 5001 [(ethereum.eth.ext.ssz_size) = "randao_mixes.size"];
|
||||
|
||||
// Slashings [6001-7000]
|
||||
repeated uint64 slashings = 6001 [(ethereum.eth.ext.ssz_size) = "slashings.size"];
|
||||
|
||||
// Participation [7001-8000]
|
||||
bytes previous_epoch_participation = 7001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
bytes current_epoch_participation = 7002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
|
||||
// Finality [8001-9000]
|
||||
// Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
|
||||
bytes justification_bits = 8001 [(ethereum.eth.ext.ssz_size) = "1", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
|
||||
v1.Checkpoint previous_justified_checkpoint = 8002;
|
||||
v1.Checkpoint current_justified_checkpoint = 8003;
|
||||
v1.Checkpoint finalized_checkpoint = 8004;
|
||||
|
||||
// Altair fields [9001-10000]
|
||||
repeated uint64 inactivity_scores = 9001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
SyncCommittee current_sync_committee = 9002; // [New in Altair]
|
||||
SyncCommittee next_sync_committee = 9003; // [New in Altair]
|
||||
|
||||
// Bellatrix fields [10001-11000]
|
||||
ethereum.engine.v1.ExecutionPayloadHeaderCapella latest_execution_payload_header = 10001; // [New in Bellatrix]
|
||||
|
||||
// Capella fields [11001-12000]
|
||||
uint64 next_withdrawal_index = 11001; // [New in Capella]
|
||||
uint64 next_withdrawal_validator_index = 11002 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"]; // [New in Capella]
|
||||
|
||||
repeated HistoricalSummary historical_summaries = 11003 [(ethereum.eth.ext.ssz_max) = "16777216"]; // [New in Capella]
|
||||
}
|
||||
|
||||
message BeaconStateDeneb {
|
||||
// Versioning [1001-2000]
|
||||
uint64 genesis_time = 1001;
|
||||
bytes genesis_validators_root = 1002 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
uint64 slot = 1003 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
|
||||
v1.Fork fork = 1004;
|
||||
// History [2001-3000]
|
||||
v1.BeaconBlockHeader latest_block_header = 2001;
|
||||
repeated bytes block_roots = 2002 [(ethereum.eth.ext.ssz_size) = "block_roots.size"];
|
||||
repeated bytes state_roots = 2003 [(ethereum.eth.ext.ssz_size) = "state_roots.size"];
|
||||
repeated bytes historical_roots = 2004 [(ethereum.eth.ext.ssz_size) = "?,32", (ethereum.eth.ext.ssz_max) = "16777216"];
|
||||
// Eth1 [3001-4000]
|
||||
v1.Eth1Data eth1_data = 3001;
|
||||
repeated v1.Eth1Data eth1_data_votes = 3002 [(ethereum.eth.ext.ssz_max) = "eth1_data_votes.size"];
|
||||
uint64 eth1_deposit_index = 3003;
|
||||
// Registry [4001-5000]
|
||||
repeated v1.Validator validators = 4001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
repeated uint64 balances = 4002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
// Randomness [5001-6000]
|
||||
repeated bytes randao_mixes = 5001 [(ethereum.eth.ext.ssz_size) = "randao_mixes.size"];
|
||||
// Slashings [6001-7000]
|
||||
repeated uint64 slashings = 6001 [(ethereum.eth.ext.ssz_size) = "slashings.size"];
|
||||
// Participation [7001-8000]
|
||||
bytes previous_epoch_participation = 7001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
bytes current_epoch_participation = 7002 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
// Finality [8001-9000]
|
||||
// Spec type [4]Bitvector which means this would be a fixed size of 4 bits.
|
||||
bytes justification_bits = 8001 [(ethereum.eth.ext.ssz_size) = "1", (ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/go-bitfield.Bitvector4"];
|
||||
v1.Checkpoint previous_justified_checkpoint = 8002;
|
||||
v1.Checkpoint current_justified_checkpoint = 8003;
|
||||
v1.Checkpoint finalized_checkpoint = 8004;
|
||||
// Altair fields [9001-10000]
|
||||
repeated uint64 inactivity_scores = 9001 [(ethereum.eth.ext.ssz_max) = "1099511627776"];
|
||||
SyncCommittee current_sync_committee = 9002; // [New in Altair]
|
||||
SyncCommittee next_sync_committee = 9003; // [New in Altair]
|
||||
// Bellatrix fields [10001-11000]
|
||||
ethereum.engine.v1.ExecutionPayloadHeaderDeneb latest_execution_payload_header = 10001; // [Updated in Deneb]
|
||||
// Capella fields [11001-12000]
|
||||
uint64 next_withdrawal_index = 11001; // [New in Capella]
|
||||
uint64 next_withdrawal_validator_index = 11002 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.ValidatorIndex"]; // [New in Capella]
|
||||
|
||||
repeated HistoricalSummary historical_summaries = 11003 [(ethereum.eth.ext.ssz_max) = "16777216"]; // [New in Capella]
|
||||
}
|
||||
|
||||
message HistoricalSummary {
|
||||
bytes block_summary_root = 1 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes state_summary_root = 2 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
}
|
||||
|
||||
message BeaconStateSSZResponseV2 {
|
||||
v2.Version version = 1;
|
||||
bytes data = 2;
|
||||
}
|
||||
|
||||
message ForkChoiceHeadsResponse {
|
||||
repeated ForkChoiceHead data = 1;
|
||||
}
|
||||
|
||||
message ForkChoiceHead {
|
||||
bytes root = 1 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
uint64 slot = 2 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
|
||||
bool execution_optimistic = 3;
|
||||
}
|
||||
@@ -6,22 +6,15 @@ go_library(
|
||||
"enums.go",
|
||||
"v1alpha1_to_v1.go",
|
||||
"v1alpha1_to_v2.go",
|
||||
"v2_to_v1alpha1.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/v5/proto/migration",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//encoding/ssz:go_default_library",
|
||||
"//proto/engine/v1:go_default_library",
|
||||
"//proto/eth/v1:go_default_library",
|
||||
"//proto/eth/v2:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
"@org_golang_google_protobuf//proto:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -30,22 +23,13 @@ go_test(
|
||||
srcs = [
|
||||
"enums_test.go",
|
||||
"v1alpha1_to_v1_test.go",
|
||||
"v1alpha1_to_v2_test.go",
|
||||
"v2_to_v1alpha1_test.go",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//proto/engine/v1:go_default_library",
|
||||
"//proto/eth/v1:go_default_library",
|
||||
"//proto/eth/v2:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//testing/assert:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"//testing/util:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,170 +1,10 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
ethpbv1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1"
|
||||
ethpbalpha "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
)
|
||||
|
||||
// BlockIfaceToV1BlockHeader converts a signed beacon block interface into a signed beacon block header.
|
||||
func BlockIfaceToV1BlockHeader(block interfaces.ReadOnlySignedBeaconBlock) (*ethpbv1.SignedBeaconBlockHeader, error) {
|
||||
bodyRoot, err := block.Block().Body().HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get body root of block")
|
||||
}
|
||||
parentRoot := block.Block().ParentRoot()
|
||||
stateRoot := block.Block().StateRoot()
|
||||
sig := block.Signature()
|
||||
return ðpbv1.SignedBeaconBlockHeader{
|
||||
Message: ðpbv1.BeaconBlockHeader{
|
||||
Slot: block.Block().Slot(),
|
||||
ProposerIndex: block.Block().ProposerIndex(),
|
||||
ParentRoot: parentRoot[:],
|
||||
StateRoot: stateRoot[:],
|
||||
BodyRoot: bodyRoot[:],
|
||||
},
|
||||
Signature: sig[:],
|
||||
}, nil
|
||||
}
|
||||
|
||||
// V1Alpha1ToV1SignedBlock converts a v1alpha1 SignedBeaconBlock proto to a v1 proto.
|
||||
func V1Alpha1ToV1SignedBlock(alphaBlk *ethpbalpha.SignedBeaconBlock) (*ethpbv1.SignedBeaconBlock, error) {
|
||||
marshaledBlk, err := proto.Marshal(alphaBlk)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not marshal block")
|
||||
}
|
||||
v1Block := ðpbv1.SignedBeaconBlock{}
|
||||
if err := proto.Unmarshal(marshaledBlk, v1Block); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal block")
|
||||
}
|
||||
return v1Block, nil
|
||||
}
|
||||
|
||||
// V1ToV1Alpha1SignedBlock converts a v1 SignedBeaconBlock proto to a v1alpha1 proto.
|
||||
func V1ToV1Alpha1SignedBlock(v1Blk *ethpbv1.SignedBeaconBlock) (*ethpbalpha.SignedBeaconBlock, error) {
|
||||
marshaledBlk, err := proto.Marshal(v1Blk)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not marshal block")
|
||||
}
|
||||
v1alpha1Block := ðpbalpha.SignedBeaconBlock{}
|
||||
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal block")
|
||||
}
|
||||
return v1alpha1Block, nil
|
||||
}
|
||||
|
||||
// V1Alpha1ToV1Block converts a v1alpha1 ReadOnlyBeaconBlock proto to a v1 proto.
|
||||
func V1Alpha1ToV1Block(alphaBlk *ethpbalpha.BeaconBlock) (*ethpbv1.BeaconBlock, error) {
|
||||
marshaledBlk, err := proto.Marshal(alphaBlk)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not marshal block")
|
||||
}
|
||||
v1Block := ðpbv1.BeaconBlock{}
|
||||
if err := proto.Unmarshal(marshaledBlk, v1Block); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal block")
|
||||
}
|
||||
return v1Block, nil
|
||||
}
|
||||
|
||||
// V1Alpha1AggregateAttAndProofToV1 converts a v1alpha1 aggregate attestation and proof to v1.
|
||||
func V1Alpha1AggregateAttAndProofToV1(v1alpha1Att *ethpbalpha.AggregateAttestationAndProof) *ethpbv1.AggregateAttestationAndProof {
|
||||
if v1alpha1Att == nil {
|
||||
return ðpbv1.AggregateAttestationAndProof{}
|
||||
}
|
||||
return ðpbv1.AggregateAttestationAndProof{
|
||||
AggregatorIndex: v1alpha1Att.AggregatorIndex,
|
||||
Aggregate: V1Alpha1AttestationToV1(v1alpha1Att.Aggregate),
|
||||
SelectionProof: v1alpha1Att.SelectionProof,
|
||||
}
|
||||
}
|
||||
|
||||
// V1SignedAggregateAttAndProofToV1Alpha1 converts a v1 signed aggregate attestation and proof to v1alpha1.
|
||||
func V1SignedAggregateAttAndProofToV1Alpha1(v1Att *ethpbv1.SignedAggregateAttestationAndProof) *ethpbalpha.SignedAggregateAttestationAndProof {
|
||||
if v1Att == nil {
|
||||
return ðpbalpha.SignedAggregateAttestationAndProof{}
|
||||
}
|
||||
return ðpbalpha.SignedAggregateAttestationAndProof{
|
||||
Message: ðpbalpha.AggregateAttestationAndProof{
|
||||
AggregatorIndex: v1Att.Message.AggregatorIndex,
|
||||
Aggregate: V1AttestationToV1Alpha1(v1Att.Message.Aggregate),
|
||||
SelectionProof: v1Att.Message.SelectionProof,
|
||||
},
|
||||
Signature: v1Att.Signature,
|
||||
}
|
||||
}
|
||||
|
||||
// V1Alpha1IndexedAttToV1 converts a v1alpha1 indexed attestation to v1.
|
||||
func V1Alpha1IndexedAttToV1(v1alpha1Att *ethpbalpha.IndexedAttestation) *ethpbv1.IndexedAttestation {
|
||||
if v1alpha1Att == nil {
|
||||
return ðpbv1.IndexedAttestation{}
|
||||
}
|
||||
return ðpbv1.IndexedAttestation{
|
||||
AttestingIndices: v1alpha1Att.AttestingIndices,
|
||||
Data: V1Alpha1AttDataToV1(v1alpha1Att.Data),
|
||||
Signature: v1alpha1Att.Signature,
|
||||
}
|
||||
}
|
||||
|
||||
// V1Alpha1AttestationToV1 converts a v1alpha1 attestation to v1.
|
||||
func V1Alpha1AttestationToV1(v1alpha1Att *ethpbalpha.Attestation) *ethpbv1.Attestation {
|
||||
if v1alpha1Att == nil {
|
||||
return ðpbv1.Attestation{}
|
||||
}
|
||||
return ðpbv1.Attestation{
|
||||
AggregationBits: v1alpha1Att.AggregationBits,
|
||||
Data: V1Alpha1AttDataToV1(v1alpha1Att.Data),
|
||||
Signature: v1alpha1Att.Signature,
|
||||
}
|
||||
}
|
||||
|
||||
// V1AttestationToV1Alpha1 converts a v1 attestation to v1alpha1.
|
||||
func V1AttestationToV1Alpha1(v1Att *ethpbv1.Attestation) *ethpbalpha.Attestation {
|
||||
if v1Att == nil {
|
||||
return ðpbalpha.Attestation{}
|
||||
}
|
||||
return ðpbalpha.Attestation{
|
||||
AggregationBits: v1Att.AggregationBits,
|
||||
Data: V1AttDataToV1Alpha1(v1Att.Data),
|
||||
Signature: v1Att.Signature,
|
||||
}
|
||||
}
|
||||
|
||||
// V1Alpha1AttDataToV1 converts a v1alpha1 attestation data to v1.
|
||||
func V1Alpha1AttDataToV1(v1alpha1AttData *ethpbalpha.AttestationData) *ethpbv1.AttestationData {
|
||||
if v1alpha1AttData == nil || v1alpha1AttData.Source == nil || v1alpha1AttData.Target == nil {
|
||||
return ðpbv1.AttestationData{}
|
||||
}
|
||||
return ðpbv1.AttestationData{
|
||||
Slot: v1alpha1AttData.Slot,
|
||||
Index: v1alpha1AttData.CommitteeIndex,
|
||||
BeaconBlockRoot: v1alpha1AttData.BeaconBlockRoot,
|
||||
Source: ðpbv1.Checkpoint{
|
||||
Root: v1alpha1AttData.Source.Root,
|
||||
Epoch: v1alpha1AttData.Source.Epoch,
|
||||
},
|
||||
Target: ðpbv1.Checkpoint{
|
||||
Root: v1alpha1AttData.Target.Root,
|
||||
Epoch: v1alpha1AttData.Target.Epoch,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// V1Alpha1AttSlashingToV1 converts a v1alpha1 attester slashing to v1.
|
||||
func V1Alpha1AttSlashingToV1(v1alpha1Slashing *ethpbalpha.AttesterSlashing) *ethpbv1.AttesterSlashing {
|
||||
if v1alpha1Slashing == nil {
|
||||
return ðpbv1.AttesterSlashing{}
|
||||
}
|
||||
return ðpbv1.AttesterSlashing{
|
||||
Attestation_1: V1Alpha1IndexedAttToV1(v1alpha1Slashing.Attestation_1),
|
||||
Attestation_2: V1Alpha1IndexedAttToV1(v1alpha1Slashing.Attestation_2),
|
||||
}
|
||||
}
|
||||
|
||||
// V1Alpha1SignedHeaderToV1 converts a v1alpha1 signed beacon block header to v1.
|
||||
func V1Alpha1SignedHeaderToV1(v1alpha1Hdr *ethpbalpha.SignedBeaconBlockHeader) *ethpbv1.SignedBeaconBlockHeader {
|
||||
if v1alpha1Hdr == nil || v1alpha1Hdr.Header == nil {
|
||||
@@ -191,23 +31,6 @@ func V1Alpha1HeaderToV1(v1alpha1Hdr *ethpbalpha.BeaconBlockHeader) *ethpbv1.Beac
|
||||
}
|
||||
}
|
||||
|
||||
// V1SignedHeaderToV1Alpha1 converts a v1 signed beacon block header to v1alpha1.
|
||||
func V1SignedHeaderToV1Alpha1(v1Header *ethpbv1.SignedBeaconBlockHeader) *ethpbalpha.SignedBeaconBlockHeader {
|
||||
if v1Header == nil || v1Header.Message == nil {
|
||||
return ðpbalpha.SignedBeaconBlockHeader{}
|
||||
}
|
||||
return ðpbalpha.SignedBeaconBlockHeader{
|
||||
Header: ðpbalpha.BeaconBlockHeader{
|
||||
Slot: v1Header.Message.Slot,
|
||||
ProposerIndex: v1Header.Message.ProposerIndex,
|
||||
ParentRoot: v1Header.Message.ParentRoot,
|
||||
StateRoot: v1Header.Message.StateRoot,
|
||||
BodyRoot: v1Header.Message.BodyRoot,
|
||||
},
|
||||
Signature: v1Header.Signature,
|
||||
}
|
||||
}
|
||||
|
||||
// V1HeaderToV1Alpha1 converts a v1 beacon block header to v1alpha1.
|
||||
func V1HeaderToV1Alpha1(v1Header *ethpbv1.BeaconBlockHeader) *ethpbalpha.BeaconBlockHeader {
|
||||
if v1Header == nil {
|
||||
@@ -222,128 +45,6 @@ func V1HeaderToV1Alpha1(v1Header *ethpbv1.BeaconBlockHeader) *ethpbalpha.BeaconB
|
||||
}
|
||||
}
|
||||
|
||||
// V1Alpha1ProposerSlashingToV1 converts a v1alpha1 proposer slashing to v1.
|
||||
func V1Alpha1ProposerSlashingToV1(v1alpha1Slashing *ethpbalpha.ProposerSlashing) *ethpbv1.ProposerSlashing {
|
||||
if v1alpha1Slashing == nil {
|
||||
return ðpbv1.ProposerSlashing{}
|
||||
}
|
||||
return ðpbv1.ProposerSlashing{
|
||||
SignedHeader_1: V1Alpha1SignedHeaderToV1(v1alpha1Slashing.Header_1),
|
||||
SignedHeader_2: V1Alpha1SignedHeaderToV1(v1alpha1Slashing.Header_2),
|
||||
}
|
||||
}
|
||||
|
||||
// V1Alpha1ExitToV1 converts a v1alpha1 SignedVoluntaryExit to v1.
|
||||
func V1Alpha1ExitToV1(v1alpha1Exit *ethpbalpha.SignedVoluntaryExit) *ethpbv1.SignedVoluntaryExit {
|
||||
if v1alpha1Exit == nil || v1alpha1Exit.Exit == nil {
|
||||
return ðpbv1.SignedVoluntaryExit{}
|
||||
}
|
||||
return ðpbv1.SignedVoluntaryExit{
|
||||
Message: ðpbv1.VoluntaryExit{
|
||||
Epoch: v1alpha1Exit.Exit.Epoch,
|
||||
ValidatorIndex: v1alpha1Exit.Exit.ValidatorIndex,
|
||||
},
|
||||
Signature: v1alpha1Exit.Signature,
|
||||
}
|
||||
}
|
||||
|
||||
// V1ExitToV1Alpha1 converts a v1 SignedVoluntaryExit to v1alpha1.
|
||||
func V1ExitToV1Alpha1(v1Exit *ethpbv1.SignedVoluntaryExit) *ethpbalpha.SignedVoluntaryExit {
|
||||
if v1Exit == nil || v1Exit.Message == nil {
|
||||
return ðpbalpha.SignedVoluntaryExit{}
|
||||
}
|
||||
return ðpbalpha.SignedVoluntaryExit{
|
||||
Exit: ðpbalpha.VoluntaryExit{
|
||||
Epoch: v1Exit.Message.Epoch,
|
||||
ValidatorIndex: v1Exit.Message.ValidatorIndex,
|
||||
},
|
||||
Signature: v1Exit.Signature,
|
||||
}
|
||||
}
|
||||
|
||||
// V1AttToV1Alpha1 converts a v1 attestation to v1alpha1.
|
||||
func V1AttToV1Alpha1(v1Att *ethpbv1.Attestation) *ethpbalpha.Attestation {
|
||||
if v1Att == nil {
|
||||
return ðpbalpha.Attestation{}
|
||||
}
|
||||
return ðpbalpha.Attestation{
|
||||
AggregationBits: v1Att.AggregationBits,
|
||||
Data: V1AttDataToV1Alpha1(v1Att.Data),
|
||||
Signature: v1Att.Signature,
|
||||
}
|
||||
}
|
||||
|
||||
// V1IndexedAttToV1Alpha1 converts a v1 indexed attestation to v1alpha1.
|
||||
func V1IndexedAttToV1Alpha1(v1Att *ethpbv1.IndexedAttestation) *ethpbalpha.IndexedAttestation {
|
||||
if v1Att == nil {
|
||||
return ðpbalpha.IndexedAttestation{}
|
||||
}
|
||||
return ðpbalpha.IndexedAttestation{
|
||||
AttestingIndices: v1Att.AttestingIndices,
|
||||
Data: V1AttDataToV1Alpha1(v1Att.Data),
|
||||
Signature: v1Att.Signature,
|
||||
}
|
||||
}
|
||||
|
||||
// V1AttDataToV1Alpha1 converts a v1 attestation data to v1alpha1.
|
||||
func V1AttDataToV1Alpha1(v1AttData *ethpbv1.AttestationData) *ethpbalpha.AttestationData {
|
||||
if v1AttData == nil || v1AttData.Source == nil || v1AttData.Target == nil {
|
||||
return ðpbalpha.AttestationData{}
|
||||
}
|
||||
return ðpbalpha.AttestationData{
|
||||
Slot: v1AttData.Slot,
|
||||
CommitteeIndex: v1AttData.Index,
|
||||
BeaconBlockRoot: v1AttData.BeaconBlockRoot,
|
||||
Source: ðpbalpha.Checkpoint{
|
||||
Root: v1AttData.Source.Root,
|
||||
Epoch: v1AttData.Source.Epoch,
|
||||
},
|
||||
Target: ðpbalpha.Checkpoint{
|
||||
Root: v1AttData.Target.Root,
|
||||
Epoch: v1AttData.Target.Epoch,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// V1AttSlashingToV1Alpha1 converts a v1 attester slashing to v1alpha1.
|
||||
func V1AttSlashingToV1Alpha1(v1Slashing *ethpbv1.AttesterSlashing) *ethpbalpha.AttesterSlashing {
|
||||
if v1Slashing == nil {
|
||||
return ðpbalpha.AttesterSlashing{}
|
||||
}
|
||||
return ðpbalpha.AttesterSlashing{
|
||||
Attestation_1: V1IndexedAttToV1Alpha1(v1Slashing.Attestation_1),
|
||||
Attestation_2: V1IndexedAttToV1Alpha1(v1Slashing.Attestation_2),
|
||||
}
|
||||
}
|
||||
|
||||
// V1ProposerSlashingToV1Alpha1 converts a v1 proposer slashing to v1alpha1.
|
||||
func V1ProposerSlashingToV1Alpha1(v1Slashing *ethpbv1.ProposerSlashing) *ethpbalpha.ProposerSlashing {
|
||||
if v1Slashing == nil {
|
||||
return ðpbalpha.ProposerSlashing{}
|
||||
}
|
||||
return ðpbalpha.ProposerSlashing{
|
||||
Header_1: V1SignedHeaderToV1Alpha1(v1Slashing.SignedHeader_1),
|
||||
Header_2: V1SignedHeaderToV1Alpha1(v1Slashing.SignedHeader_2),
|
||||
}
|
||||
}
|
||||
|
||||
// V1Alpha1ValidatorToV1 converts a v1alpha1 validator to v1.
|
||||
func V1Alpha1ValidatorToV1(v1Alpha1Validator *ethpbalpha.Validator) *ethpbv1.Validator {
|
||||
if v1Alpha1Validator == nil {
|
||||
return ðpbv1.Validator{}
|
||||
}
|
||||
return ðpbv1.Validator{
|
||||
Pubkey: v1Alpha1Validator.PublicKey,
|
||||
WithdrawalCredentials: v1Alpha1Validator.WithdrawalCredentials,
|
||||
EffectiveBalance: v1Alpha1Validator.EffectiveBalance,
|
||||
Slashed: v1Alpha1Validator.Slashed,
|
||||
ActivationEligibilityEpoch: v1Alpha1Validator.ActivationEligibilityEpoch,
|
||||
ActivationEpoch: v1Alpha1Validator.ActivationEpoch,
|
||||
ExitEpoch: v1Alpha1Validator.ExitEpoch,
|
||||
WithdrawableEpoch: v1Alpha1Validator.WithdrawableEpoch,
|
||||
}
|
||||
}
|
||||
|
||||
// V1ValidatorToV1Alpha1 converts a v1 validator to v1alpha1.
|
||||
func V1ValidatorToV1Alpha1(v1Validator *ethpbv1.Validator) *ethpbalpha.Validator {
|
||||
if v1Validator == nil {
|
||||
@@ -360,161 +61,3 @@ func V1ValidatorToV1Alpha1(v1Validator *ethpbv1.Validator) *ethpbalpha.Validator
|
||||
WithdrawableEpoch: v1Validator.WithdrawableEpoch,
|
||||
}
|
||||
}
|
||||
|
||||
// SignedBeaconBlock converts a signed beacon block interface to a v1alpha1 block.
|
||||
func SignedBeaconBlock(block interfaces.ReadOnlySignedBeaconBlock) (*ethpbv1.SignedBeaconBlock, error) {
|
||||
if block == nil || block.IsNil() {
|
||||
return nil, errors.New("could not find requested block")
|
||||
}
|
||||
blk, err := block.PbPhase0Block()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get raw block")
|
||||
}
|
||||
|
||||
v1Block, err := V1Alpha1ToV1SignedBlock(blk)
|
||||
if err != nil {
|
||||
return nil, errors.New("could not convert block to v1 block")
|
||||
}
|
||||
|
||||
return v1Block, nil
|
||||
}
|
||||
|
||||
// BeaconStateToProto converts a state.BeaconState object to its protobuf equivalent.
|
||||
func BeaconStateToProto(state state.BeaconState) (*ethpbv1.BeaconState, error) {
|
||||
sourceFork := state.Fork()
|
||||
sourceLatestBlockHeader := state.LatestBlockHeader()
|
||||
sourceEth1Data := state.Eth1Data()
|
||||
sourceEth1DataVotes := state.Eth1DataVotes()
|
||||
sourceValidators := state.Validators()
|
||||
sourcePrevEpochAtts, err := state.PreviousEpochAttestations()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get previous epoch attestations from state")
|
||||
}
|
||||
sourceCurrEpochAtts, err := state.CurrentEpochAttestations()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get current epoch attestations from state")
|
||||
}
|
||||
sourceJustificationBits := state.JustificationBits()
|
||||
sourcePrevJustifiedCheckpoint := state.PreviousJustifiedCheckpoint()
|
||||
sourceCurrJustifiedCheckpoint := state.CurrentJustifiedCheckpoint()
|
||||
sourceFinalizedCheckpoint := state.FinalizedCheckpoint()
|
||||
|
||||
resultEth1DataVotes := make([]*ethpbv1.Eth1Data, len(sourceEth1DataVotes))
|
||||
for i, vote := range sourceEth1DataVotes {
|
||||
resultEth1DataVotes[i] = ðpbv1.Eth1Data{
|
||||
DepositRoot: bytesutil.SafeCopyBytes(vote.DepositRoot),
|
||||
DepositCount: vote.DepositCount,
|
||||
BlockHash: bytesutil.SafeCopyBytes(vote.BlockHash),
|
||||
}
|
||||
}
|
||||
resultValidators := make([]*ethpbv1.Validator, len(sourceValidators))
|
||||
for i, validator := range sourceValidators {
|
||||
resultValidators[i] = ðpbv1.Validator{
|
||||
Pubkey: bytesutil.SafeCopyBytes(validator.PublicKey),
|
||||
WithdrawalCredentials: bytesutil.SafeCopyBytes(validator.WithdrawalCredentials),
|
||||
EffectiveBalance: validator.EffectiveBalance,
|
||||
Slashed: validator.Slashed,
|
||||
ActivationEligibilityEpoch: validator.ActivationEligibilityEpoch,
|
||||
ActivationEpoch: validator.ActivationEpoch,
|
||||
ExitEpoch: validator.ExitEpoch,
|
||||
WithdrawableEpoch: validator.WithdrawableEpoch,
|
||||
}
|
||||
}
|
||||
resultPrevEpochAtts := make([]*ethpbv1.PendingAttestation, len(sourcePrevEpochAtts))
|
||||
for i, att := range sourcePrevEpochAtts {
|
||||
data := att.Data
|
||||
resultPrevEpochAtts[i] = ðpbv1.PendingAttestation{
|
||||
AggregationBits: att.AggregationBits,
|
||||
Data: ðpbv1.AttestationData{
|
||||
Slot: data.Slot,
|
||||
Index: data.CommitteeIndex,
|
||||
BeaconBlockRoot: data.BeaconBlockRoot,
|
||||
Source: ðpbv1.Checkpoint{
|
||||
Epoch: data.Source.Epoch,
|
||||
Root: data.Source.Root,
|
||||
},
|
||||
Target: ðpbv1.Checkpoint{
|
||||
Epoch: data.Target.Epoch,
|
||||
Root: data.Target.Root,
|
||||
},
|
||||
},
|
||||
InclusionDelay: att.InclusionDelay,
|
||||
ProposerIndex: att.ProposerIndex,
|
||||
}
|
||||
}
|
||||
resultCurrEpochAtts := make([]*ethpbv1.PendingAttestation, len(sourceCurrEpochAtts))
|
||||
for i, att := range sourceCurrEpochAtts {
|
||||
data := att.Data
|
||||
resultCurrEpochAtts[i] = ðpbv1.PendingAttestation{
|
||||
AggregationBits: att.AggregationBits,
|
||||
Data: ðpbv1.AttestationData{
|
||||
Slot: data.Slot,
|
||||
Index: data.CommitteeIndex,
|
||||
BeaconBlockRoot: data.BeaconBlockRoot,
|
||||
Source: ðpbv1.Checkpoint{
|
||||
Epoch: data.Source.Epoch,
|
||||
Root: data.Source.Root,
|
||||
},
|
||||
Target: ðpbv1.Checkpoint{
|
||||
Epoch: data.Target.Epoch,
|
||||
Root: data.Target.Root,
|
||||
},
|
||||
},
|
||||
InclusionDelay: att.InclusionDelay,
|
||||
ProposerIndex: att.ProposerIndex,
|
||||
}
|
||||
}
|
||||
|
||||
hRoot, err := state.HistoricalRoots()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get historical roots from state")
|
||||
}
|
||||
result := ðpbv1.BeaconState{
|
||||
GenesisTime: state.GenesisTime(),
|
||||
GenesisValidatorsRoot: bytesutil.SafeCopyBytes(state.GenesisValidatorsRoot()),
|
||||
Slot: state.Slot(),
|
||||
Fork: ðpbv1.Fork{
|
||||
PreviousVersion: bytesutil.SafeCopyBytes(sourceFork.PreviousVersion),
|
||||
CurrentVersion: bytesutil.SafeCopyBytes(sourceFork.CurrentVersion),
|
||||
Epoch: sourceFork.Epoch,
|
||||
},
|
||||
LatestBlockHeader: ðpbv1.BeaconBlockHeader{
|
||||
Slot: sourceLatestBlockHeader.Slot,
|
||||
ProposerIndex: sourceLatestBlockHeader.ProposerIndex,
|
||||
ParentRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.ParentRoot),
|
||||
StateRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.StateRoot),
|
||||
BodyRoot: bytesutil.SafeCopyBytes(sourceLatestBlockHeader.BodyRoot),
|
||||
},
|
||||
BlockRoots: bytesutil.SafeCopy2dBytes(state.BlockRoots()),
|
||||
StateRoots: bytesutil.SafeCopy2dBytes(state.StateRoots()),
|
||||
HistoricalRoots: bytesutil.SafeCopy2dBytes(hRoot),
|
||||
Eth1Data: ðpbv1.Eth1Data{
|
||||
DepositRoot: bytesutil.SafeCopyBytes(sourceEth1Data.DepositRoot),
|
||||
DepositCount: sourceEth1Data.DepositCount,
|
||||
BlockHash: bytesutil.SafeCopyBytes(sourceEth1Data.BlockHash),
|
||||
},
|
||||
Eth1DataVotes: resultEth1DataVotes,
|
||||
Eth1DepositIndex: state.Eth1DepositIndex(),
|
||||
Validators: resultValidators,
|
||||
Balances: state.Balances(),
|
||||
RandaoMixes: bytesutil.SafeCopy2dBytes(state.RandaoMixes()),
|
||||
Slashings: state.Slashings(),
|
||||
PreviousEpochAttestations: resultPrevEpochAtts,
|
||||
CurrentEpochAttestations: resultCurrEpochAtts,
|
||||
JustificationBits: bytesutil.SafeCopyBytes(sourceJustificationBits),
|
||||
PreviousJustifiedCheckpoint: ðpbv1.Checkpoint{
|
||||
Epoch: sourcePrevJustifiedCheckpoint.Epoch,
|
||||
Root: bytesutil.SafeCopyBytes(sourcePrevJustifiedCheckpoint.Root),
|
||||
},
|
||||
CurrentJustifiedCheckpoint: ðpbv1.Checkpoint{
|
||||
Epoch: sourceCurrJustifiedCheckpoint.Epoch,
|
||||
Root: bytesutil.SafeCopyBytes(sourceCurrJustifiedCheckpoint.Root),
|
||||
},
|
||||
FinalizedCheckpoint: ðpbv1.Checkpoint{
|
||||
Epoch: sourceFinalizedCheckpoint.Epoch,
|
||||
Root: bytesutil.SafeCopyBytes(sourceFinalizedCheckpoint.Root),
|
||||
},
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -3,403 +3,12 @@ package migration
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
ethpbv1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1"
|
||||
ethpbalpha "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/util"
|
||||
)
|
||||
|
||||
var (
|
||||
slot = primitives.Slot(1)
|
||||
epoch = primitives.Epoch(1)
|
||||
validatorIndex = primitives.ValidatorIndex(1)
|
||||
committeeIndex = primitives.CommitteeIndex(1)
|
||||
depositCount = uint64(2)
|
||||
attestingIndices = []uint64{1, 2}
|
||||
blockNumber = uint64(10)
|
||||
gasLimit = uint64(10)
|
||||
gasUsed = uint64(10)
|
||||
timestamp = uint64(10)
|
||||
parentRoot = bytesutil.PadTo([]byte("parentroot"), fieldparams.RootLength)
|
||||
stateRoot = bytesutil.PadTo([]byte("stateroot"), fieldparams.RootLength)
|
||||
signature = bytesutil.PadTo([]byte("signature"), 96)
|
||||
randaoReveal = bytesutil.PadTo([]byte("randaoreveal"), 96)
|
||||
depositRoot = bytesutil.PadTo([]byte("depositroot"), fieldparams.RootLength)
|
||||
blockHash = bytesutil.PadTo([]byte("blockhash"), 32)
|
||||
beaconBlockRoot = bytesutil.PadTo([]byte("beaconblockroot"), fieldparams.RootLength)
|
||||
sourceRoot = bytesutil.PadTo([]byte("sourceroot"), fieldparams.RootLength)
|
||||
targetRoot = bytesutil.PadTo([]byte("targetroot"), fieldparams.RootLength)
|
||||
bodyRoot = bytesutil.PadTo([]byte("bodyroot"), fieldparams.RootLength)
|
||||
selectionProof = bytesutil.PadTo([]byte("selectionproof"), 96)
|
||||
parentHash = bytesutil.PadTo([]byte("parenthash"), 32)
|
||||
feeRecipient = bytesutil.PadTo([]byte("feerecipient"), 20)
|
||||
receiptsRoot = bytesutil.PadTo([]byte("receiptsroot"), 32)
|
||||
logsBloom = bytesutil.PadTo([]byte("logsbloom"), 256)
|
||||
prevRandao = bytesutil.PadTo([]byte("prevrandao"), 32)
|
||||
extraData = bytesutil.PadTo([]byte("extradata"), 32)
|
||||
baseFeePerGas = bytesutil.PadTo([]byte("basefeepergas"), 32)
|
||||
transactionsRoot = bytesutil.PadTo([]byte("transactions"), 32)
|
||||
aggregationBits = bitfield.Bitlist{0x01}
|
||||
)
|
||||
|
||||
func Test_BlockIfaceToV1BlockHeader(t *testing.T) {
|
||||
alphaBlock := util.HydrateSignedBeaconBlock(ðpbalpha.SignedBeaconBlock{})
|
||||
alphaBlock.Block.Slot = slot
|
||||
alphaBlock.Block.ProposerIndex = validatorIndex
|
||||
alphaBlock.Block.ParentRoot = parentRoot
|
||||
alphaBlock.Block.StateRoot = stateRoot
|
||||
alphaBlock.Signature = signature
|
||||
|
||||
wsb, err := blocks.NewSignedBeaconBlock(alphaBlock)
|
||||
require.NoError(t, err)
|
||||
v1Header, err := BlockIfaceToV1BlockHeader(wsb)
|
||||
require.NoError(t, err)
|
||||
bodyRoot, err := alphaBlock.Block.Body.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, bodyRoot[:], v1Header.Message.BodyRoot)
|
||||
assert.Equal(t, slot, v1Header.Message.Slot)
|
||||
assert.Equal(t, validatorIndex, v1Header.Message.ProposerIndex)
|
||||
assert.DeepEqual(t, parentRoot, v1Header.Message.ParentRoot)
|
||||
assert.DeepEqual(t, stateRoot, v1Header.Message.StateRoot)
|
||||
assert.DeepEqual(t, signature, v1Header.Signature)
|
||||
}
|
||||
|
||||
func Test_V1Alpha1AggregateAttAndProofToV1(t *testing.T) {
|
||||
proof := [32]byte{1}
|
||||
att := util.HydrateAttestation(ðpbalpha.Attestation{
|
||||
Data: ðpbalpha.AttestationData{
|
||||
Slot: 5,
|
||||
},
|
||||
})
|
||||
alpha := ðpbalpha.AggregateAttestationAndProof{
|
||||
AggregatorIndex: 1,
|
||||
Aggregate: att,
|
||||
SelectionProof: proof[:],
|
||||
}
|
||||
v1 := V1Alpha1AggregateAttAndProofToV1(alpha)
|
||||
assert.Equal(t, v1.AggregatorIndex, primitives.ValidatorIndex(1))
|
||||
assert.DeepSSZEqual(t, v1.Aggregate.Data.Slot, att.Data.Slot)
|
||||
assert.DeepEqual(t, v1.SelectionProof, proof[:])
|
||||
}
|
||||
|
||||
func Test_V1Alpha1ToV1SignedBlock(t *testing.T) {
|
||||
alphaBlock := util.HydrateSignedBeaconBlock(ðpbalpha.SignedBeaconBlock{})
|
||||
alphaBlock.Block.Slot = slot
|
||||
alphaBlock.Block.ProposerIndex = validatorIndex
|
||||
alphaBlock.Block.ParentRoot = parentRoot
|
||||
alphaBlock.Block.StateRoot = stateRoot
|
||||
alphaBlock.Block.Body.RandaoReveal = randaoReveal
|
||||
alphaBlock.Block.Body.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: depositRoot,
|
||||
DepositCount: depositCount,
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
alphaBlock.Signature = signature
|
||||
|
||||
v1Block, err := V1Alpha1ToV1SignedBlock(alphaBlock)
|
||||
require.NoError(t, err)
|
||||
alphaRoot, err := alphaBlock.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Root, err := v1Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, alphaRoot, v1Root)
|
||||
}
|
||||
|
||||
func Test_V1ToV1Alpha1SignedBlock(t *testing.T) {
|
||||
v1Block := util.HydrateV1SignedBeaconBlock(ðpbv1.SignedBeaconBlock{})
|
||||
v1Block.Block.Slot = slot
|
||||
v1Block.Block.ProposerIndex = validatorIndex
|
||||
v1Block.Block.ParentRoot = parentRoot
|
||||
v1Block.Block.StateRoot = stateRoot
|
||||
v1Block.Block.Body.RandaoReveal = randaoReveal
|
||||
v1Block.Block.Body.Eth1Data = ðpbv1.Eth1Data{
|
||||
DepositRoot: depositRoot,
|
||||
DepositCount: depositCount,
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
v1Block.Signature = signature
|
||||
|
||||
alphaBlock, err := V1ToV1Alpha1SignedBlock(v1Block)
|
||||
require.NoError(t, err)
|
||||
alphaRoot, err := alphaBlock.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Root, err := v1Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, v1Root, alphaRoot)
|
||||
}
|
||||
|
||||
func Test_V1ToV1Alpha1Block(t *testing.T) {
|
||||
alphaBlock := util.HydrateBeaconBlock(ðpbalpha.BeaconBlock{})
|
||||
alphaBlock.Slot = slot
|
||||
alphaBlock.ProposerIndex = validatorIndex
|
||||
alphaBlock.ParentRoot = parentRoot
|
||||
alphaBlock.StateRoot = stateRoot
|
||||
alphaBlock.Body.RandaoReveal = randaoReveal
|
||||
alphaBlock.Body.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: depositRoot,
|
||||
DepositCount: depositCount,
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
|
||||
v1Block, err := V1Alpha1ToV1Block(alphaBlock)
|
||||
require.NoError(t, err)
|
||||
v1Root, err := v1Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
alphaRoot, err := alphaBlock.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, alphaRoot, v1Root)
|
||||
}
|
||||
|
||||
func Test_V1Alpha1AttSlashingToV1(t *testing.T) {
|
||||
alphaAttestation := ðpbalpha.IndexedAttestation{
|
||||
AttestingIndices: attestingIndices,
|
||||
Data: ðpbalpha.AttestationData{
|
||||
Slot: slot,
|
||||
CommitteeIndex: committeeIndex,
|
||||
BeaconBlockRoot: beaconBlockRoot,
|
||||
Source: ðpbalpha.Checkpoint{
|
||||
Epoch: epoch,
|
||||
Root: sourceRoot,
|
||||
},
|
||||
Target: ðpbalpha.Checkpoint{
|
||||
Epoch: epoch,
|
||||
Root: targetRoot,
|
||||
},
|
||||
},
|
||||
Signature: signature,
|
||||
}
|
||||
alphaSlashing := ðpbalpha.AttesterSlashing{
|
||||
Attestation_1: alphaAttestation,
|
||||
Attestation_2: alphaAttestation,
|
||||
}
|
||||
|
||||
v1Slashing := V1Alpha1AttSlashingToV1(alphaSlashing)
|
||||
alphaRoot, err := alphaSlashing.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Root, err := v1Slashing.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, alphaRoot, v1Root)
|
||||
}
|
||||
|
||||
func Test_V1Alpha1ProposerSlashingToV1(t *testing.T) {
|
||||
alphaHeader := util.HydrateSignedBeaconHeader(ðpbalpha.SignedBeaconBlockHeader{})
|
||||
alphaHeader.Header.Slot = slot
|
||||
alphaHeader.Header.ProposerIndex = validatorIndex
|
||||
alphaHeader.Header.ParentRoot = parentRoot
|
||||
alphaHeader.Header.StateRoot = stateRoot
|
||||
alphaHeader.Header.BodyRoot = bodyRoot
|
||||
alphaHeader.Signature = signature
|
||||
alphaSlashing := ðpbalpha.ProposerSlashing{
|
||||
Header_1: alphaHeader,
|
||||
Header_2: alphaHeader,
|
||||
}
|
||||
|
||||
v1Slashing := V1Alpha1ProposerSlashingToV1(alphaSlashing)
|
||||
alphaRoot, err := alphaSlashing.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Root, err := v1Slashing.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, alphaRoot, v1Root)
|
||||
}
|
||||
|
||||
func Test_V1Alpha1ExitToV1(t *testing.T) {
|
||||
alphaExit := ðpbalpha.SignedVoluntaryExit{
|
||||
Exit: ðpbalpha.VoluntaryExit{
|
||||
Epoch: epoch,
|
||||
ValidatorIndex: validatorIndex,
|
||||
},
|
||||
Signature: signature,
|
||||
}
|
||||
|
||||
v1Exit := V1Alpha1ExitToV1(alphaExit)
|
||||
alphaRoot, err := alphaExit.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Root, err := v1Exit.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, alphaRoot, v1Root)
|
||||
}
|
||||
|
||||
func Test_V1ExitToV1Alpha1(t *testing.T) {
|
||||
v1Exit := ðpbv1.SignedVoluntaryExit{
|
||||
Message: ðpbv1.VoluntaryExit{
|
||||
Epoch: epoch,
|
||||
ValidatorIndex: validatorIndex,
|
||||
},
|
||||
Signature: signature,
|
||||
}
|
||||
|
||||
alphaExit := V1ExitToV1Alpha1(v1Exit)
|
||||
alphaRoot, err := alphaExit.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Root, err := v1Exit.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, alphaRoot, v1Root)
|
||||
}
|
||||
|
||||
func Test_V1AttSlashingToV1Alpha1(t *testing.T) {
|
||||
v1Attestation := ðpbv1.IndexedAttestation{
|
||||
AttestingIndices: attestingIndices,
|
||||
Data: ðpbv1.AttestationData{
|
||||
Slot: slot,
|
||||
Index: committeeIndex,
|
||||
BeaconBlockRoot: beaconBlockRoot,
|
||||
Source: ðpbv1.Checkpoint{
|
||||
Epoch: epoch,
|
||||
Root: sourceRoot,
|
||||
},
|
||||
Target: ðpbv1.Checkpoint{
|
||||
Epoch: epoch,
|
||||
Root: targetRoot,
|
||||
},
|
||||
},
|
||||
Signature: signature,
|
||||
}
|
||||
v1Slashing := ðpbv1.AttesterSlashing{
|
||||
Attestation_1: v1Attestation,
|
||||
Attestation_2: v1Attestation,
|
||||
}
|
||||
|
||||
alphaSlashing := V1AttSlashingToV1Alpha1(v1Slashing)
|
||||
alphaRoot, err := alphaSlashing.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Root, err := v1Slashing.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, v1Root, alphaRoot)
|
||||
}
|
||||
|
||||
func Test_V1ProposerSlashingToV1Alpha1(t *testing.T) {
|
||||
v1Header := ðpbv1.SignedBeaconBlockHeader{
|
||||
Message: ðpbv1.BeaconBlockHeader{
|
||||
Slot: slot,
|
||||
ProposerIndex: validatorIndex,
|
||||
ParentRoot: parentRoot,
|
||||
StateRoot: stateRoot,
|
||||
BodyRoot: bodyRoot,
|
||||
},
|
||||
Signature: signature,
|
||||
}
|
||||
v1Slashing := ðpbv1.ProposerSlashing{
|
||||
SignedHeader_1: v1Header,
|
||||
SignedHeader_2: v1Header,
|
||||
}
|
||||
|
||||
alphaSlashing := V1ProposerSlashingToV1Alpha1(v1Slashing)
|
||||
alphaRoot, err := alphaSlashing.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Root, err := v1Slashing.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, alphaRoot, v1Root)
|
||||
}
|
||||
|
||||
func Test_V1Alpha1AttToV1(t *testing.T) {
|
||||
alphaAtt := ðpbalpha.Attestation{
|
||||
AggregationBits: aggregationBits,
|
||||
Data: ðpbalpha.AttestationData{
|
||||
Slot: slot,
|
||||
CommitteeIndex: committeeIndex,
|
||||
BeaconBlockRoot: beaconBlockRoot,
|
||||
Source: ðpbalpha.Checkpoint{
|
||||
Epoch: epoch,
|
||||
Root: sourceRoot,
|
||||
},
|
||||
Target: ðpbalpha.Checkpoint{
|
||||
Epoch: epoch,
|
||||
Root: targetRoot,
|
||||
},
|
||||
},
|
||||
Signature: signature,
|
||||
}
|
||||
|
||||
v1Att := V1Alpha1AttestationToV1(alphaAtt)
|
||||
v1Root, err := v1Att.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
alphaRoot, err := alphaAtt.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, v1Root, alphaRoot)
|
||||
}
|
||||
|
||||
func Test_V1AttToV1Alpha1(t *testing.T) {
|
||||
v1Att := ðpbv1.Attestation{
|
||||
AggregationBits: aggregationBits,
|
||||
Data: ðpbv1.AttestationData{
|
||||
Slot: slot,
|
||||
Index: committeeIndex,
|
||||
BeaconBlockRoot: beaconBlockRoot,
|
||||
Source: ðpbv1.Checkpoint{
|
||||
Epoch: epoch,
|
||||
Root: sourceRoot,
|
||||
},
|
||||
Target: ðpbv1.Checkpoint{
|
||||
Epoch: epoch,
|
||||
Root: targetRoot,
|
||||
},
|
||||
},
|
||||
Signature: signature,
|
||||
}
|
||||
|
||||
alphaAtt := V1AttToV1Alpha1(v1Att)
|
||||
alphaRoot, err := alphaAtt.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Root, err := v1Att.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, v1Root, alphaRoot)
|
||||
}
|
||||
|
||||
func Test_BlockInterfaceToV1Block(t *testing.T) {
|
||||
v1Alpha1Block := util.HydrateSignedBeaconBlock(ðpbalpha.SignedBeaconBlock{})
|
||||
v1Alpha1Block.Block.Slot = slot
|
||||
v1Alpha1Block.Block.ProposerIndex = validatorIndex
|
||||
v1Alpha1Block.Block.ParentRoot = parentRoot
|
||||
v1Alpha1Block.Block.StateRoot = stateRoot
|
||||
v1Alpha1Block.Block.Body.RandaoReveal = randaoReveal
|
||||
v1Alpha1Block.Block.Body.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: depositRoot,
|
||||
DepositCount: depositCount,
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
v1Alpha1Block.Signature = signature
|
||||
|
||||
wsb, err := blocks.NewSignedBeaconBlock(v1Alpha1Block)
|
||||
require.NoError(t, err)
|
||||
v1Block, err := SignedBeaconBlock(wsb)
|
||||
require.NoError(t, err)
|
||||
v1Root, err := v1Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Alpha1Root, err := v1Alpha1Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, v1Root, v1Alpha1Root)
|
||||
}
|
||||
|
||||
func Test_V1Alpha1ValidatorToV1(t *testing.T) {
|
||||
v1Alpha1Validator := ðpbalpha.Validator{
|
||||
PublicKey: []byte("pubkey"),
|
||||
WithdrawalCredentials: []byte("withdraw"),
|
||||
EffectiveBalance: 99,
|
||||
Slashed: true,
|
||||
ActivationEligibilityEpoch: 1,
|
||||
ActivationEpoch: 11,
|
||||
ExitEpoch: 111,
|
||||
WithdrawableEpoch: 1111,
|
||||
}
|
||||
|
||||
v1Validator := V1Alpha1ValidatorToV1(v1Alpha1Validator)
|
||||
require.NotNil(t, v1Validator)
|
||||
assert.DeepEqual(t, []byte("pubkey"), v1Validator.Pubkey)
|
||||
assert.DeepEqual(t, []byte("withdraw"), v1Validator.WithdrawalCredentials)
|
||||
assert.Equal(t, uint64(99), v1Validator.EffectiveBalance)
|
||||
assert.Equal(t, true, v1Validator.Slashed)
|
||||
assert.Equal(t, primitives.Epoch(1), v1Validator.ActivationEligibilityEpoch)
|
||||
assert.Equal(t, primitives.Epoch(11), v1Validator.ActivationEpoch)
|
||||
assert.Equal(t, primitives.Epoch(111), v1Validator.ExitEpoch)
|
||||
assert.Equal(t, primitives.Epoch(1111), v1Validator.WithdrawableEpoch)
|
||||
}
|
||||
|
||||
func Test_V1ValidatorToV1Alpha1(t *testing.T) {
|
||||
v1Validator := ðpbv1.Validator{
|
||||
Pubkey: []byte("pubkey"),
|
||||
@@ -423,231 +32,3 @@ func Test_V1ValidatorToV1Alpha1(t *testing.T) {
|
||||
assert.Equal(t, primitives.Epoch(111), v1Alpha1Validator.ExitEpoch)
|
||||
assert.Equal(t, primitives.Epoch(1111), v1Alpha1Validator.WithdrawableEpoch)
|
||||
}
|
||||
|
||||
func Test_V1SignedAggregateAttAndProofToV1Alpha1(t *testing.T) {
|
||||
v1Att := ðpbv1.SignedAggregateAttestationAndProof{
|
||||
Message: ðpbv1.AggregateAttestationAndProof{
|
||||
AggregatorIndex: 1,
|
||||
Aggregate: util.HydrateV1Attestation(ðpbv1.Attestation{}),
|
||||
SelectionProof: selectionProof,
|
||||
},
|
||||
Signature: signature,
|
||||
}
|
||||
v1Alpha1Att := V1SignedAggregateAttAndProofToV1Alpha1(v1Att)
|
||||
|
||||
v1Root, err := v1Att.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Alpha1Root, err := v1Alpha1Att.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, v1Root, v1Alpha1Root)
|
||||
}
|
||||
|
||||
func Test_V1AttestationToV1Alpha1(t *testing.T) {
|
||||
v1Att := util.HydrateV1Attestation(ðpbv1.Attestation{})
|
||||
v1Alpha1Att := V1AttToV1Alpha1(v1Att)
|
||||
|
||||
v1Root, err := v1Att.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v1Alpha1Root, err := v1Alpha1Att.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, v1Root, v1Alpha1Root)
|
||||
}
|
||||
func TestBeaconStateToProto(t *testing.T) {
|
||||
source, err := util.NewBeaconState(util.FillRootsNaturalOpt, func(state *ethpbalpha.BeaconState) error {
|
||||
state.GenesisTime = 1
|
||||
state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32)
|
||||
state.Slot = 2
|
||||
state.Fork = ðpbalpha.Fork{
|
||||
PreviousVersion: bytesutil.PadTo([]byte("123"), 4),
|
||||
CurrentVersion: bytesutil.PadTo([]byte("456"), 4),
|
||||
Epoch: 3,
|
||||
}
|
||||
state.LatestBlockHeader = ðpbalpha.BeaconBlockHeader{
|
||||
Slot: 4,
|
||||
ProposerIndex: 5,
|
||||
ParentRoot: bytesutil.PadTo([]byte("lbhparentroot"), 32),
|
||||
StateRoot: bytesutil.PadTo([]byte("lbhstateroot"), 32),
|
||||
BodyRoot: bytesutil.PadTo([]byte("lbhbodyroot"), 32),
|
||||
}
|
||||
state.BlockRoots = [][]byte{bytesutil.PadTo([]byte("blockroots"), 32)}
|
||||
state.StateRoots = [][]byte{bytesutil.PadTo([]byte("stateroots"), 32)}
|
||||
state.HistoricalRoots = [][]byte{bytesutil.PadTo([]byte("historicalroots"), 32)}
|
||||
state.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: bytesutil.PadTo([]byte("e1ddepositroot"), 32),
|
||||
DepositCount: 6,
|
||||
BlockHash: bytesutil.PadTo([]byte("e1dblockhash"), 32),
|
||||
}
|
||||
state.Eth1DataVotes = []*ethpbalpha.Eth1Data{{
|
||||
DepositRoot: bytesutil.PadTo([]byte("e1dvdepositroot"), 32),
|
||||
DepositCount: 7,
|
||||
BlockHash: bytesutil.PadTo([]byte("e1dvblockhash"), 32),
|
||||
}}
|
||||
state.Eth1DepositIndex = 8
|
||||
state.Validators = []*ethpbalpha.Validator{{
|
||||
PublicKey: bytesutil.PadTo([]byte("publickey"), 48),
|
||||
WithdrawalCredentials: bytesutil.PadTo([]byte("withdrawalcredentials"), 32),
|
||||
EffectiveBalance: 9,
|
||||
Slashed: true,
|
||||
ActivationEligibilityEpoch: 10,
|
||||
ActivationEpoch: 11,
|
||||
ExitEpoch: 12,
|
||||
WithdrawableEpoch: 13,
|
||||
}}
|
||||
state.Balances = []uint64{14}
|
||||
state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)}
|
||||
state.Slashings = []uint64{15}
|
||||
state.PreviousEpochAttestations = []*ethpbalpha.PendingAttestation{{
|
||||
AggregationBits: bitfield.Bitlist{16},
|
||||
Data: ðpbalpha.AttestationData{
|
||||
Slot: 17,
|
||||
CommitteeIndex: 18,
|
||||
BeaconBlockRoot: bytesutil.PadTo([]byte("peabeaconblockroot"), 32),
|
||||
Source: ðpbalpha.Checkpoint{
|
||||
Epoch: 19,
|
||||
Root: bytesutil.PadTo([]byte("peasroot"), 32),
|
||||
},
|
||||
Target: ðpbalpha.Checkpoint{
|
||||
Epoch: 20,
|
||||
Root: bytesutil.PadTo([]byte("peatroot"), 32),
|
||||
},
|
||||
},
|
||||
InclusionDelay: 21,
|
||||
ProposerIndex: 22,
|
||||
}}
|
||||
state.CurrentEpochAttestations = []*ethpbalpha.PendingAttestation{{
|
||||
AggregationBits: bitfield.Bitlist{23},
|
||||
Data: ðpbalpha.AttestationData{
|
||||
Slot: 24,
|
||||
CommitteeIndex: 25,
|
||||
BeaconBlockRoot: bytesutil.PadTo([]byte("ceabeaconblockroot"), 32),
|
||||
Source: ðpbalpha.Checkpoint{
|
||||
Epoch: 26,
|
||||
Root: bytesutil.PadTo([]byte("ceasroot"), 32),
|
||||
},
|
||||
Target: ðpbalpha.Checkpoint{
|
||||
Epoch: 27,
|
||||
Root: bytesutil.PadTo([]byte("ceatroot"), 32),
|
||||
},
|
||||
},
|
||||
InclusionDelay: 28,
|
||||
ProposerIndex: 29,
|
||||
}}
|
||||
state.JustificationBits = bitfield.Bitvector4{1}
|
||||
state.PreviousJustifiedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 30,
|
||||
Root: bytesutil.PadTo([]byte("pjcroot"), 32),
|
||||
}
|
||||
state.CurrentJustifiedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 31,
|
||||
Root: bytesutil.PadTo([]byte("cjcroot"), 32),
|
||||
}
|
||||
state.FinalizedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 32,
|
||||
Root: bytesutil.PadTo([]byte("fcroot"), 32),
|
||||
}
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
result, err := BeaconStateToProto(source)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, result)
|
||||
assert.Equal(t, uint64(1), result.GenesisTime)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32), result.GenesisValidatorsRoot)
|
||||
assert.Equal(t, primitives.Slot(2), result.Slot)
|
||||
resultFork := result.Fork
|
||||
require.NotNil(t, resultFork)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("123"), 4), resultFork.PreviousVersion)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("456"), 4), resultFork.CurrentVersion)
|
||||
assert.Equal(t, primitives.Epoch(3), resultFork.Epoch)
|
||||
resultLatestBlockHeader := result.LatestBlockHeader
|
||||
require.NotNil(t, resultLatestBlockHeader)
|
||||
assert.Equal(t, primitives.Slot(4), resultLatestBlockHeader.Slot)
|
||||
assert.Equal(t, primitives.ValidatorIndex(5), resultLatestBlockHeader.ProposerIndex)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhparentroot"), 32), resultLatestBlockHeader.ParentRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhstateroot"), 32), resultLatestBlockHeader.StateRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhbodyroot"), 32), resultLatestBlockHeader.BodyRoot)
|
||||
assert.Equal(t, 8192, len(result.BlockRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockroots"), 32), result.BlockRoots[0])
|
||||
assert.Equal(t, 8192, len(result.StateRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroots"), 32), result.StateRoots[0])
|
||||
assert.Equal(t, 1, len(result.HistoricalRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("historicalroots"), 32), result.HistoricalRoots[0])
|
||||
resultEth1Data := result.Eth1Data
|
||||
require.NotNil(t, resultEth1Data)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1ddepositroot"), 32), resultEth1Data.DepositRoot)
|
||||
assert.Equal(t, uint64(6), resultEth1Data.DepositCount)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dblockhash"), 32), resultEth1Data.BlockHash)
|
||||
require.Equal(t, 1, len(result.Eth1DataVotes))
|
||||
resultEth1DataVote := result.Eth1DataVotes[0]
|
||||
require.NotNil(t, resultEth1DataVote)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvdepositroot"), 32), resultEth1DataVote.DepositRoot)
|
||||
assert.Equal(t, uint64(7), resultEth1DataVote.DepositCount)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvblockhash"), 32), resultEth1DataVote.BlockHash)
|
||||
assert.Equal(t, uint64(8), result.Eth1DepositIndex)
|
||||
require.Equal(t, 1, len(result.Validators))
|
||||
resultValidator := result.Validators[0]
|
||||
require.NotNil(t, resultValidator)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("publickey"), 48), resultValidator.Pubkey)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalcredentials"), 32), resultValidator.WithdrawalCredentials)
|
||||
assert.Equal(t, uint64(9), resultValidator.EffectiveBalance)
|
||||
assert.Equal(t, true, resultValidator.Slashed)
|
||||
assert.Equal(t, primitives.Epoch(10), resultValidator.ActivationEligibilityEpoch)
|
||||
assert.Equal(t, primitives.Epoch(11), resultValidator.ActivationEpoch)
|
||||
assert.Equal(t, primitives.Epoch(12), resultValidator.ExitEpoch)
|
||||
assert.Equal(t, primitives.Epoch(13), resultValidator.WithdrawableEpoch)
|
||||
assert.DeepEqual(t, []uint64{14}, result.Balances)
|
||||
assert.Equal(t, 65536, len(result.RandaoMixes))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("randaomixes"), 32), result.RandaoMixes[0])
|
||||
assert.DeepEqual(t, []uint64{15}, result.Slashings)
|
||||
require.Equal(t, 1, len(result.PreviousEpochAttestations))
|
||||
resultPrevEpochAtt := result.PreviousEpochAttestations[0]
|
||||
require.NotNil(t, resultPrevEpochAtt)
|
||||
assert.DeepEqual(t, bitfield.Bitlist{16}, resultPrevEpochAtt.AggregationBits)
|
||||
resultPrevEpochAttData := resultPrevEpochAtt.Data
|
||||
require.NotNil(t, resultPrevEpochAttData)
|
||||
assert.Equal(t, primitives.Slot(17), resultPrevEpochAttData.Slot)
|
||||
assert.Equal(t, primitives.CommitteeIndex(18), resultPrevEpochAttData.Index)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("peabeaconblockroot"), 32), resultPrevEpochAttData.BeaconBlockRoot)
|
||||
resultPrevEpochAttSource := resultPrevEpochAttData.Source
|
||||
require.NotNil(t, resultPrevEpochAttSource)
|
||||
assert.Equal(t, primitives.Epoch(19), resultPrevEpochAttSource.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("peasroot"), 32), resultPrevEpochAttSource.Root)
|
||||
resultPrevEpochAttTarget := resultPrevEpochAttData.Target
|
||||
require.NotNil(t, resultPrevEpochAttTarget)
|
||||
assert.Equal(t, primitives.Epoch(20), resultPrevEpochAttTarget.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("peatroot"), 32), resultPrevEpochAttTarget.Root)
|
||||
assert.Equal(t, primitives.Slot(21), resultPrevEpochAtt.InclusionDelay)
|
||||
assert.Equal(t, primitives.ValidatorIndex(22), resultPrevEpochAtt.ProposerIndex)
|
||||
resultCurrEpochAtt := result.CurrentEpochAttestations[0]
|
||||
require.NotNil(t, resultCurrEpochAtt)
|
||||
assert.DeepEqual(t, bitfield.Bitlist{23}, resultCurrEpochAtt.AggregationBits)
|
||||
resultCurrEpochAttData := resultCurrEpochAtt.Data
|
||||
require.NotNil(t, resultCurrEpochAttData)
|
||||
assert.Equal(t, primitives.Slot(24), resultCurrEpochAttData.Slot)
|
||||
assert.Equal(t, primitives.CommitteeIndex(25), resultCurrEpochAttData.Index)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("ceabeaconblockroot"), 32), resultCurrEpochAttData.BeaconBlockRoot)
|
||||
resultCurrEpochAttSource := resultCurrEpochAttData.Source
|
||||
require.NotNil(t, resultCurrEpochAttSource)
|
||||
assert.Equal(t, primitives.Epoch(26), resultCurrEpochAttSource.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("ceasroot"), 32), resultCurrEpochAttSource.Root)
|
||||
resultCurrEpochAttTarget := resultCurrEpochAttData.Target
|
||||
require.NotNil(t, resultCurrEpochAttTarget)
|
||||
assert.Equal(t, primitives.Epoch(27), resultCurrEpochAttTarget.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("ceatroot"), 32), resultCurrEpochAttTarget.Root)
|
||||
assert.Equal(t, primitives.Slot(28), resultCurrEpochAtt.InclusionDelay)
|
||||
assert.Equal(t, primitives.ValidatorIndex(29), resultCurrEpochAtt.ProposerIndex)
|
||||
assert.DeepEqual(t, bitfield.Bitvector4{1}, result.JustificationBits)
|
||||
resultPrevJustifiedCheckpoint := result.PreviousJustifiedCheckpoint
|
||||
require.NotNil(t, resultPrevJustifiedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(30), resultPrevJustifiedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("pjcroot"), 32), resultPrevJustifiedCheckpoint.Root)
|
||||
resultCurrJustifiedCheckpoint := result.CurrentJustifiedCheckpoint
|
||||
require.NotNil(t, resultCurrJustifiedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(31), resultCurrJustifiedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("cjcroot"), 32), resultCurrJustifiedCheckpoint.Root)
|
||||
resultFinalizedCheckpoint := result.FinalizedCheckpoint
|
||||
require.NotNil(t, resultFinalizedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(32), resultFinalizedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("fcroot"), 32), resultFinalizedCheckpoint.Root)
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,901 +0,0 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
|
||||
ethpbalpha "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/util"
|
||||
)
|
||||
|
||||
func TestV1Alpha1SignedContributionAndProofToV2(t *testing.T) {
|
||||
alphaContribution := ðpbalpha.SignedContributionAndProof{
|
||||
Message: ðpbalpha.ContributionAndProof{
|
||||
AggregatorIndex: validatorIndex,
|
||||
Contribution: ðpbalpha.SyncCommitteeContribution{
|
||||
Slot: slot,
|
||||
BlockRoot: blockHash,
|
||||
SubcommitteeIndex: 1,
|
||||
AggregationBits: bitfield.NewBitvector128(),
|
||||
Signature: signature,
|
||||
},
|
||||
SelectionProof: signature,
|
||||
},
|
||||
Signature: signature,
|
||||
}
|
||||
v2Contribution := V1Alpha1SignedContributionAndProofToV2(alphaContribution)
|
||||
require.NotNil(t, v2Contribution)
|
||||
require.NotNil(t, v2Contribution.Message)
|
||||
require.NotNil(t, v2Contribution.Message.Contribution)
|
||||
assert.DeepEqual(t, signature, v2Contribution.Signature)
|
||||
msg := v2Contribution.Message
|
||||
assert.Equal(t, validatorIndex, msg.AggregatorIndex)
|
||||
assert.DeepEqual(t, signature, msg.SelectionProof)
|
||||
contrib := msg.Contribution
|
||||
assert.Equal(t, slot, contrib.Slot)
|
||||
assert.DeepEqual(t, blockHash, contrib.BeaconBlockRoot)
|
||||
assert.Equal(t, uint64(1), contrib.SubcommitteeIndex)
|
||||
assert.DeepEqual(t, bitfield.NewBitvector128(), contrib.AggregationBits)
|
||||
assert.DeepEqual(t, signature, contrib.Signature)
|
||||
}
|
||||
|
||||
func Test_V1Alpha1BeaconBlockAltairToV2(t *testing.T) {
|
||||
alphaBlock := util.HydrateBeaconBlockAltair(ðpbalpha.BeaconBlockAltair{})
|
||||
alphaBlock.Slot = slot
|
||||
alphaBlock.ProposerIndex = validatorIndex
|
||||
alphaBlock.ParentRoot = parentRoot
|
||||
alphaBlock.StateRoot = stateRoot
|
||||
alphaBlock.Body.RandaoReveal = randaoReveal
|
||||
alphaBlock.Body.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: depositRoot,
|
||||
DepositCount: depositCount,
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
syncCommitteeBits := bitfield.NewBitvector512()
|
||||
syncCommitteeBits.SetBitAt(100, true)
|
||||
alphaBlock.Body.SyncAggregate = ðpbalpha.SyncAggregate{
|
||||
SyncCommitteeBits: syncCommitteeBits,
|
||||
SyncCommitteeSignature: signature,
|
||||
}
|
||||
|
||||
v2Block, err := V1Alpha1BeaconBlockAltairToV2(alphaBlock)
|
||||
require.NoError(t, err)
|
||||
alphaRoot, err := alphaBlock.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v2Root, err := v2Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, alphaRoot, v2Root)
|
||||
}
|
||||
|
||||
func Test_V1Alpha1BeaconBlockBellatrixToV2(t *testing.T) {
|
||||
alphaBlock := util.HydrateBeaconBlockBellatrix(ðpbalpha.BeaconBlockBellatrix{})
|
||||
alphaBlock.Slot = slot
|
||||
alphaBlock.ProposerIndex = validatorIndex
|
||||
alphaBlock.ParentRoot = parentRoot
|
||||
alphaBlock.StateRoot = stateRoot
|
||||
alphaBlock.Body.RandaoReveal = randaoReveal
|
||||
alphaBlock.Body.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: depositRoot,
|
||||
DepositCount: depositCount,
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
syncCommitteeBits := bitfield.NewBitvector512()
|
||||
syncCommitteeBits.SetBitAt(100, true)
|
||||
alphaBlock.Body.SyncAggregate = ðpbalpha.SyncAggregate{
|
||||
SyncCommitteeBits: syncCommitteeBits,
|
||||
SyncCommitteeSignature: signature,
|
||||
}
|
||||
|
||||
v2Block, err := V1Alpha1BeaconBlockBellatrixToV2(alphaBlock)
|
||||
require.NoError(t, err)
|
||||
alphaRoot, err := alphaBlock.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v2Root, err := v2Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, alphaRoot, v2Root)
|
||||
}
|
||||
|
||||
func Test_V1Alpha1BeaconBlockBellatrixToV2Blinded(t *testing.T) {
|
||||
alphaBlock := util.HydrateBeaconBlockBellatrix(ðpbalpha.BeaconBlockBellatrix{})
|
||||
alphaBlock.Slot = slot
|
||||
alphaBlock.ProposerIndex = validatorIndex
|
||||
alphaBlock.ParentRoot = parentRoot
|
||||
alphaBlock.StateRoot = stateRoot
|
||||
alphaBlock.Body.RandaoReveal = randaoReveal
|
||||
alphaBlock.Body.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: depositRoot,
|
||||
DepositCount: depositCount,
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
syncCommitteeBits := bitfield.NewBitvector512()
|
||||
syncCommitteeBits.SetBitAt(100, true)
|
||||
alphaBlock.Body.SyncAggregate = ðpbalpha.SyncAggregate{
|
||||
SyncCommitteeBits: syncCommitteeBits,
|
||||
SyncCommitteeSignature: signature,
|
||||
}
|
||||
alphaBlock.Body.ExecutionPayload.Transactions = [][]byte{[]byte("transaction1"), []byte("transaction2")}
|
||||
|
||||
v2Block, err := V1Alpha1BeaconBlockBellatrixToV2Blinded(alphaBlock)
|
||||
require.NoError(t, err)
|
||||
alphaRoot, err := alphaBlock.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v2Root, err := v2Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, alphaRoot, v2Root)
|
||||
}
|
||||
|
||||
func Test_V1Alpha1BeaconBlockCapellaToV2Blinded(t *testing.T) {
|
||||
alphaBlock := util.HydrateBeaconBlockCapella(ðpbalpha.BeaconBlockCapella{})
|
||||
alphaBlock.Slot = slot
|
||||
alphaBlock.ProposerIndex = validatorIndex
|
||||
alphaBlock.ParentRoot = parentRoot
|
||||
alphaBlock.StateRoot = stateRoot
|
||||
alphaBlock.Body.RandaoReveal = randaoReveal
|
||||
alphaBlock.Body.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: depositRoot,
|
||||
DepositCount: depositCount,
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
syncCommitteeBits := bitfield.NewBitvector512()
|
||||
syncCommitteeBits.SetBitAt(100, true)
|
||||
alphaBlock.Body.SyncAggregate = ðpbalpha.SyncAggregate{
|
||||
SyncCommitteeBits: syncCommitteeBits,
|
||||
SyncCommitteeSignature: signature,
|
||||
}
|
||||
alphaBlock.Body.ExecutionPayload.Transactions = [][]byte{[]byte("transaction1"), []byte("transaction2")}
|
||||
|
||||
v2Block, err := V1Alpha1BeaconBlockCapellaToV2Blinded(alphaBlock)
|
||||
require.NoError(t, err)
|
||||
alphaRoot, err := alphaBlock.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v2Root, err := v2Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, alphaRoot, v2Root)
|
||||
}
|
||||
|
||||
func TestBeaconStateAltairToProto(t *testing.T) {
|
||||
source, err := util.NewBeaconStateAltair(util.FillRootsNaturalOptAltair, func(state *ethpbalpha.BeaconStateAltair) error {
|
||||
state.GenesisTime = 1
|
||||
state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32)
|
||||
state.Slot = 2
|
||||
state.Fork = ðpbalpha.Fork{
|
||||
PreviousVersion: bytesutil.PadTo([]byte("123"), 4),
|
||||
CurrentVersion: bytesutil.PadTo([]byte("456"), 4),
|
||||
Epoch: 3,
|
||||
}
|
||||
state.LatestBlockHeader = ðpbalpha.BeaconBlockHeader{
|
||||
Slot: 4,
|
||||
ProposerIndex: 5,
|
||||
ParentRoot: bytesutil.PadTo([]byte("lbhparentroot"), 32),
|
||||
StateRoot: bytesutil.PadTo([]byte("lbhstateroot"), 32),
|
||||
BodyRoot: bytesutil.PadTo([]byte("lbhbodyroot"), 32),
|
||||
}
|
||||
state.BlockRoots = [][]byte{bytesutil.PadTo([]byte("blockroots"), 32)}
|
||||
state.StateRoots = [][]byte{bytesutil.PadTo([]byte("stateroots"), 32)}
|
||||
state.HistoricalRoots = [][]byte{bytesutil.PadTo([]byte("historicalroots"), 32)}
|
||||
state.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: bytesutil.PadTo([]byte("e1ddepositroot"), 32),
|
||||
DepositCount: 6,
|
||||
BlockHash: bytesutil.PadTo([]byte("e1dblockhash"), 32),
|
||||
}
|
||||
state.Eth1DataVotes = []*ethpbalpha.Eth1Data{{
|
||||
DepositRoot: bytesutil.PadTo([]byte("e1dvdepositroot"), 32),
|
||||
DepositCount: 7,
|
||||
BlockHash: bytesutil.PadTo([]byte("e1dvblockhash"), 32),
|
||||
}}
|
||||
state.Eth1DepositIndex = 8
|
||||
state.Validators = []*ethpbalpha.Validator{{
|
||||
PublicKey: bytesutil.PadTo([]byte("publickey"), 48),
|
||||
WithdrawalCredentials: bytesutil.PadTo([]byte("withdrawalcredentials"), 32),
|
||||
EffectiveBalance: 9,
|
||||
Slashed: true,
|
||||
ActivationEligibilityEpoch: 10,
|
||||
ActivationEpoch: 11,
|
||||
ExitEpoch: 12,
|
||||
WithdrawableEpoch: 13,
|
||||
}}
|
||||
state.Balances = []uint64{14}
|
||||
state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)}
|
||||
state.Slashings = []uint64{15}
|
||||
state.JustificationBits = bitfield.Bitvector4{1}
|
||||
state.PreviousJustifiedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 30,
|
||||
Root: bytesutil.PadTo([]byte("pjcroot"), 32),
|
||||
}
|
||||
state.CurrentJustifiedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 31,
|
||||
Root: bytesutil.PadTo([]byte("cjcroot"), 32),
|
||||
}
|
||||
state.FinalizedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 32,
|
||||
Root: bytesutil.PadTo([]byte("fcroot"), 32),
|
||||
}
|
||||
state.PreviousEpochParticipation = []byte("previousepochparticipation")
|
||||
state.CurrentEpochParticipation = []byte("currentepochparticipation")
|
||||
state.InactivityScores = []uint64{1, 2, 3}
|
||||
state.CurrentSyncCommittee = ðpbalpha.SyncCommittee{
|
||||
Pubkeys: [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)},
|
||||
AggregatePubkey: bytesutil.PadTo([]byte("cscaggregatepubkey"), 48),
|
||||
}
|
||||
state.NextSyncCommittee = ðpbalpha.SyncCommittee{
|
||||
Pubkeys: [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)},
|
||||
AggregatePubkey: bytesutil.PadTo([]byte("nscaggregatepubkey"), 48),
|
||||
}
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
result, err := BeaconStateAltairToProto(source)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, result)
|
||||
assert.Equal(t, uint64(1), result.GenesisTime)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32), result.GenesisValidatorsRoot)
|
||||
assert.Equal(t, primitives.Slot(2), result.Slot)
|
||||
resultFork := result.Fork
|
||||
require.NotNil(t, resultFork)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("123"), 4), resultFork.PreviousVersion)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("456"), 4), resultFork.CurrentVersion)
|
||||
assert.Equal(t, primitives.Epoch(3), resultFork.Epoch)
|
||||
resultLatestBlockHeader := result.LatestBlockHeader
|
||||
require.NotNil(t, resultLatestBlockHeader)
|
||||
assert.Equal(t, primitives.Slot(4), resultLatestBlockHeader.Slot)
|
||||
assert.Equal(t, primitives.ValidatorIndex(5), resultLatestBlockHeader.ProposerIndex)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhparentroot"), 32), resultLatestBlockHeader.ParentRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhstateroot"), 32), resultLatestBlockHeader.StateRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhbodyroot"), 32), resultLatestBlockHeader.BodyRoot)
|
||||
assert.Equal(t, 8192, len(result.BlockRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockroots"), 32), result.BlockRoots[0])
|
||||
assert.Equal(t, 8192, len(result.StateRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroots"), 32), result.StateRoots[0])
|
||||
assert.Equal(t, 1, len(result.HistoricalRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("historicalroots"), 32), result.HistoricalRoots[0])
|
||||
resultEth1Data := result.Eth1Data
|
||||
require.NotNil(t, resultEth1Data)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1ddepositroot"), 32), resultEth1Data.DepositRoot)
|
||||
assert.Equal(t, uint64(6), resultEth1Data.DepositCount)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dblockhash"), 32), resultEth1Data.BlockHash)
|
||||
require.Equal(t, 1, len(result.Eth1DataVotes))
|
||||
resultEth1DataVote := result.Eth1DataVotes[0]
|
||||
require.NotNil(t, resultEth1DataVote)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvdepositroot"), 32), resultEth1DataVote.DepositRoot)
|
||||
assert.Equal(t, uint64(7), resultEth1DataVote.DepositCount)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvblockhash"), 32), resultEth1DataVote.BlockHash)
|
||||
assert.Equal(t, uint64(8), result.Eth1DepositIndex)
|
||||
require.Equal(t, 1, len(result.Validators))
|
||||
resultValidator := result.Validators[0]
|
||||
require.NotNil(t, resultValidator)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("publickey"), 48), resultValidator.Pubkey)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalcredentials"), 32), resultValidator.WithdrawalCredentials)
|
||||
assert.Equal(t, uint64(9), resultValidator.EffectiveBalance)
|
||||
assert.Equal(t, true, resultValidator.Slashed)
|
||||
assert.Equal(t, primitives.Epoch(10), resultValidator.ActivationEligibilityEpoch)
|
||||
assert.Equal(t, primitives.Epoch(11), resultValidator.ActivationEpoch)
|
||||
assert.Equal(t, primitives.Epoch(12), resultValidator.ExitEpoch)
|
||||
assert.Equal(t, primitives.Epoch(13), resultValidator.WithdrawableEpoch)
|
||||
assert.DeepEqual(t, []uint64{14}, result.Balances)
|
||||
assert.Equal(t, 65536, len(result.RandaoMixes))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("randaomixes"), 32), result.RandaoMixes[0])
|
||||
assert.DeepEqual(t, []uint64{15}, result.Slashings)
|
||||
assert.DeepEqual(t, bitfield.Bitvector4{1}, result.JustificationBits)
|
||||
resultPrevJustifiedCheckpoint := result.PreviousJustifiedCheckpoint
|
||||
require.NotNil(t, resultPrevJustifiedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(30), resultPrevJustifiedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("pjcroot"), 32), resultPrevJustifiedCheckpoint.Root)
|
||||
resultCurrJustifiedCheckpoint := result.CurrentJustifiedCheckpoint
|
||||
require.NotNil(t, resultCurrJustifiedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(31), resultCurrJustifiedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("cjcroot"), 32), resultCurrJustifiedCheckpoint.Root)
|
||||
resultFinalizedCheckpoint := result.FinalizedCheckpoint
|
||||
require.NotNil(t, resultFinalizedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(32), resultFinalizedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("fcroot"), 32), resultFinalizedCheckpoint.Root)
|
||||
assert.DeepEqual(t, []byte("previousepochparticipation"), result.PreviousEpochParticipation)
|
||||
assert.DeepEqual(t, []byte("currentepochparticipation"), result.CurrentEpochParticipation)
|
||||
assert.DeepEqual(t, []uint64{1, 2, 3}, result.InactivityScores)
|
||||
require.NotNil(t, result.CurrentSyncCommittee)
|
||||
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)}, result.CurrentSyncCommittee.Pubkeys)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("cscaggregatepubkey"), 48), result.CurrentSyncCommittee.AggregatePubkey)
|
||||
require.NotNil(t, result.NextSyncCommittee)
|
||||
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)}, result.NextSyncCommittee.Pubkeys)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("nscaggregatepubkey"), 48), result.NextSyncCommittee.AggregatePubkey)
|
||||
}
|
||||
|
||||
func TestBeaconStateBellatrixToProto(t *testing.T) {
|
||||
source, err := util.NewBeaconStateBellatrix(util.FillRootsNaturalOptBellatrix, func(state *ethpbalpha.BeaconStateBellatrix) error {
|
||||
state.GenesisTime = 1
|
||||
state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32)
|
||||
state.Slot = 2
|
||||
state.Fork = ðpbalpha.Fork{
|
||||
PreviousVersion: bytesutil.PadTo([]byte("123"), 4),
|
||||
CurrentVersion: bytesutil.PadTo([]byte("456"), 4),
|
||||
Epoch: 3,
|
||||
}
|
||||
state.LatestBlockHeader = ðpbalpha.BeaconBlockHeader{
|
||||
Slot: 4,
|
||||
ProposerIndex: 5,
|
||||
ParentRoot: bytesutil.PadTo([]byte("lbhparentroot"), 32),
|
||||
StateRoot: bytesutil.PadTo([]byte("lbhstateroot"), 32),
|
||||
BodyRoot: bytesutil.PadTo([]byte("lbhbodyroot"), 32),
|
||||
}
|
||||
state.BlockRoots = [][]byte{bytesutil.PadTo([]byte("blockroots"), 32)}
|
||||
state.StateRoots = [][]byte{bytesutil.PadTo([]byte("stateroots"), 32)}
|
||||
state.HistoricalRoots = [][]byte{bytesutil.PadTo([]byte("historicalroots"), 32)}
|
||||
state.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: bytesutil.PadTo([]byte("e1ddepositroot"), 32),
|
||||
DepositCount: 6,
|
||||
BlockHash: bytesutil.PadTo([]byte("e1dblockhash"), 32),
|
||||
}
|
||||
state.Eth1DataVotes = []*ethpbalpha.Eth1Data{{
|
||||
DepositRoot: bytesutil.PadTo([]byte("e1dvdepositroot"), 32),
|
||||
DepositCount: 7,
|
||||
BlockHash: bytesutil.PadTo([]byte("e1dvblockhash"), 32),
|
||||
}}
|
||||
state.Eth1DepositIndex = 8
|
||||
state.Validators = []*ethpbalpha.Validator{{
|
||||
PublicKey: bytesutil.PadTo([]byte("publickey"), 48),
|
||||
WithdrawalCredentials: bytesutil.PadTo([]byte("withdrawalcredentials"), 32),
|
||||
EffectiveBalance: 9,
|
||||
Slashed: true,
|
||||
ActivationEligibilityEpoch: 10,
|
||||
ActivationEpoch: 11,
|
||||
ExitEpoch: 12,
|
||||
WithdrawableEpoch: 13,
|
||||
}}
|
||||
state.Balances = []uint64{14}
|
||||
state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)}
|
||||
state.Slashings = []uint64{15}
|
||||
state.JustificationBits = bitfield.Bitvector4{1}
|
||||
state.PreviousJustifiedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 30,
|
||||
Root: bytesutil.PadTo([]byte("pjcroot"), 32),
|
||||
}
|
||||
state.CurrentJustifiedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 31,
|
||||
Root: bytesutil.PadTo([]byte("cjcroot"), 32),
|
||||
}
|
||||
state.FinalizedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 32,
|
||||
Root: bytesutil.PadTo([]byte("fcroot"), 32),
|
||||
}
|
||||
state.PreviousEpochParticipation = []byte("previousepochparticipation")
|
||||
state.CurrentEpochParticipation = []byte("currentepochparticipation")
|
||||
state.InactivityScores = []uint64{1, 2, 3}
|
||||
state.CurrentSyncCommittee = ðpbalpha.SyncCommittee{
|
||||
Pubkeys: [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)},
|
||||
AggregatePubkey: bytesutil.PadTo([]byte("cscaggregatepubkey"), 48),
|
||||
}
|
||||
state.NextSyncCommittee = ðpbalpha.SyncCommittee{
|
||||
Pubkeys: [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)},
|
||||
AggregatePubkey: bytesutil.PadTo([]byte("nscaggregatepubkey"), 48),
|
||||
}
|
||||
state.LatestExecutionPayloadHeader = &enginev1.ExecutionPayloadHeader{
|
||||
ParentHash: bytesutil.PadTo([]byte("parenthash"), 32),
|
||||
FeeRecipient: bytesutil.PadTo([]byte("feerecipient"), 20),
|
||||
StateRoot: bytesutil.PadTo([]byte("stateroot"), 32),
|
||||
ReceiptsRoot: bytesutil.PadTo([]byte("receiptroot"), 32),
|
||||
LogsBloom: bytesutil.PadTo([]byte("logsbloom"), 256),
|
||||
PrevRandao: bytesutil.PadTo([]byte("prevrandao"), 32),
|
||||
BlockNumber: 123,
|
||||
GasLimit: 456,
|
||||
GasUsed: 789,
|
||||
Timestamp: 012,
|
||||
ExtraData: []byte("extradata"),
|
||||
BaseFeePerGas: bytesutil.PadTo([]byte("basefeepergas"), 32),
|
||||
BlockHash: bytesutil.PadTo([]byte("blockhash"), 32),
|
||||
TransactionsRoot: bytesutil.PadTo([]byte("transactionsroot"), 32),
|
||||
}
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
result, err := BeaconStateBellatrixToProto(source)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, result)
|
||||
assert.Equal(t, uint64(1), result.GenesisTime)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32), result.GenesisValidatorsRoot)
|
||||
assert.Equal(t, primitives.Slot(2), result.Slot)
|
||||
resultFork := result.Fork
|
||||
require.NotNil(t, resultFork)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("123"), 4), resultFork.PreviousVersion)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("456"), 4), resultFork.CurrentVersion)
|
||||
assert.Equal(t, primitives.Epoch(3), resultFork.Epoch)
|
||||
resultLatestBlockHeader := result.LatestBlockHeader
|
||||
require.NotNil(t, resultLatestBlockHeader)
|
||||
assert.Equal(t, primitives.Slot(4), resultLatestBlockHeader.Slot)
|
||||
assert.Equal(t, primitives.ValidatorIndex(5), resultLatestBlockHeader.ProposerIndex)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhparentroot"), 32), resultLatestBlockHeader.ParentRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhstateroot"), 32), resultLatestBlockHeader.StateRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhbodyroot"), 32), resultLatestBlockHeader.BodyRoot)
|
||||
assert.Equal(t, 8192, len(result.BlockRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockroots"), 32), result.BlockRoots[0])
|
||||
assert.Equal(t, 8192, len(result.StateRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroots"), 32), result.StateRoots[0])
|
||||
assert.Equal(t, 1, len(result.HistoricalRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("historicalroots"), 32), result.HistoricalRoots[0])
|
||||
resultEth1Data := result.Eth1Data
|
||||
require.NotNil(t, resultEth1Data)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1ddepositroot"), 32), resultEth1Data.DepositRoot)
|
||||
assert.Equal(t, uint64(6), resultEth1Data.DepositCount)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dblockhash"), 32), resultEth1Data.BlockHash)
|
||||
require.Equal(t, 1, len(result.Eth1DataVotes))
|
||||
resultEth1DataVote := result.Eth1DataVotes[0]
|
||||
require.NotNil(t, resultEth1DataVote)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvdepositroot"), 32), resultEth1DataVote.DepositRoot)
|
||||
assert.Equal(t, uint64(7), resultEth1DataVote.DepositCount)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvblockhash"), 32), resultEth1DataVote.BlockHash)
|
||||
assert.Equal(t, uint64(8), result.Eth1DepositIndex)
|
||||
require.Equal(t, 1, len(result.Validators))
|
||||
resultValidator := result.Validators[0]
|
||||
require.NotNil(t, resultValidator)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("publickey"), 48), resultValidator.Pubkey)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalcredentials"), 32), resultValidator.WithdrawalCredentials)
|
||||
assert.Equal(t, uint64(9), resultValidator.EffectiveBalance)
|
||||
assert.Equal(t, true, resultValidator.Slashed)
|
||||
assert.Equal(t, primitives.Epoch(10), resultValidator.ActivationEligibilityEpoch)
|
||||
assert.Equal(t, primitives.Epoch(11), resultValidator.ActivationEpoch)
|
||||
assert.Equal(t, primitives.Epoch(12), resultValidator.ExitEpoch)
|
||||
assert.Equal(t, primitives.Epoch(13), resultValidator.WithdrawableEpoch)
|
||||
assert.DeepEqual(t, []uint64{14}, result.Balances)
|
||||
assert.Equal(t, 65536, len(result.RandaoMixes))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("randaomixes"), 32), result.RandaoMixes[0])
|
||||
assert.DeepEqual(t, []uint64{15}, result.Slashings)
|
||||
assert.DeepEqual(t, bitfield.Bitvector4{1}, result.JustificationBits)
|
||||
resultPrevJustifiedCheckpoint := result.PreviousJustifiedCheckpoint
|
||||
require.NotNil(t, resultPrevJustifiedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(30), resultPrevJustifiedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("pjcroot"), 32), resultPrevJustifiedCheckpoint.Root)
|
||||
resultCurrJustifiedCheckpoint := result.CurrentJustifiedCheckpoint
|
||||
require.NotNil(t, resultCurrJustifiedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(31), resultCurrJustifiedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("cjcroot"), 32), resultCurrJustifiedCheckpoint.Root)
|
||||
resultFinalizedCheckpoint := result.FinalizedCheckpoint
|
||||
require.NotNil(t, resultFinalizedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(32), resultFinalizedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("fcroot"), 32), resultFinalizedCheckpoint.Root)
|
||||
assert.DeepEqual(t, []byte("previousepochparticipation"), result.PreviousEpochParticipation)
|
||||
assert.DeepEqual(t, []byte("currentepochparticipation"), result.CurrentEpochParticipation)
|
||||
assert.DeepEqual(t, []uint64{1, 2, 3}, result.InactivityScores)
|
||||
require.NotNil(t, result.CurrentSyncCommittee)
|
||||
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)}, result.CurrentSyncCommittee.Pubkeys)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("cscaggregatepubkey"), 48), result.CurrentSyncCommittee.AggregatePubkey)
|
||||
require.NotNil(t, result.NextSyncCommittee)
|
||||
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)}, result.NextSyncCommittee.Pubkeys)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("nscaggregatepubkey"), 48), result.NextSyncCommittee.AggregatePubkey)
|
||||
resultLatestExecutionPayloadHeader := result.LatestExecutionPayloadHeader
|
||||
require.NotNil(t, resultLatestExecutionPayloadHeader)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("parenthash"), 32), resultLatestExecutionPayloadHeader.ParentHash)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("feerecipient"), 20), resultLatestExecutionPayloadHeader.FeeRecipient)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroot"), 32), resultLatestExecutionPayloadHeader.StateRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("receiptroot"), 32), resultLatestExecutionPayloadHeader.ReceiptsRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("logsbloom"), 256), resultLatestExecutionPayloadHeader.LogsBloom)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("prevrandao"), 32), resultLatestExecutionPayloadHeader.PrevRandao)
|
||||
assert.Equal(t, uint64(123), resultLatestExecutionPayloadHeader.BlockNumber)
|
||||
assert.Equal(t, uint64(456), resultLatestExecutionPayloadHeader.GasLimit)
|
||||
assert.Equal(t, uint64(789), resultLatestExecutionPayloadHeader.GasUsed)
|
||||
assert.Equal(t, uint64(012), resultLatestExecutionPayloadHeader.Timestamp)
|
||||
assert.DeepEqual(t, []byte("extradata"), resultLatestExecutionPayloadHeader.ExtraData)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("basefeepergas"), 32), resultLatestExecutionPayloadHeader.BaseFeePerGas)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockhash"), 32), resultLatestExecutionPayloadHeader.BlockHash)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("transactionsroot"), 32), resultLatestExecutionPayloadHeader.TransactionsRoot)
|
||||
}
|
||||
|
||||
func TestBeaconStateCapellaToProto(t *testing.T) {
|
||||
source, err := util.NewBeaconStateCapella(util.FillRootsNaturalOptCapella, func(state *ethpbalpha.BeaconStateCapella) error {
|
||||
state.GenesisTime = 1
|
||||
state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32)
|
||||
state.Slot = 2
|
||||
state.Fork = ðpbalpha.Fork{
|
||||
PreviousVersion: bytesutil.PadTo([]byte("123"), 4),
|
||||
CurrentVersion: bytesutil.PadTo([]byte("456"), 4),
|
||||
Epoch: 3,
|
||||
}
|
||||
state.LatestBlockHeader = ðpbalpha.BeaconBlockHeader{
|
||||
Slot: 4,
|
||||
ProposerIndex: 5,
|
||||
ParentRoot: bytesutil.PadTo([]byte("lbhparentroot"), 32),
|
||||
StateRoot: bytesutil.PadTo([]byte("lbhstateroot"), 32),
|
||||
BodyRoot: bytesutil.PadTo([]byte("lbhbodyroot"), 32),
|
||||
}
|
||||
state.BlockRoots = [][]byte{bytesutil.PadTo([]byte("blockroots"), 32)}
|
||||
state.StateRoots = [][]byte{bytesutil.PadTo([]byte("stateroots"), 32)}
|
||||
state.HistoricalRoots = [][]byte{bytesutil.PadTo([]byte("historicalroots"), 32)}
|
||||
state.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: bytesutil.PadTo([]byte("e1ddepositroot"), 32),
|
||||
DepositCount: 6,
|
||||
BlockHash: bytesutil.PadTo([]byte("e1dblockhash"), 32),
|
||||
}
|
||||
state.Eth1DataVotes = []*ethpbalpha.Eth1Data{{
|
||||
DepositRoot: bytesutil.PadTo([]byte("e1dvdepositroot"), 32),
|
||||
DepositCount: 7,
|
||||
BlockHash: bytesutil.PadTo([]byte("e1dvblockhash"), 32),
|
||||
}}
|
||||
state.Eth1DepositIndex = 8
|
||||
state.Validators = []*ethpbalpha.Validator{{
|
||||
PublicKey: bytesutil.PadTo([]byte("publickey"), 48),
|
||||
WithdrawalCredentials: bytesutil.PadTo([]byte("withdrawalcredentials"), 32),
|
||||
EffectiveBalance: 9,
|
||||
Slashed: true,
|
||||
ActivationEligibilityEpoch: 10,
|
||||
ActivationEpoch: 11,
|
||||
ExitEpoch: 12,
|
||||
WithdrawableEpoch: 13,
|
||||
}}
|
||||
state.Balances = []uint64{14}
|
||||
state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)}
|
||||
state.Slashings = []uint64{15}
|
||||
state.JustificationBits = bitfield.Bitvector4{1}
|
||||
state.PreviousJustifiedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 30,
|
||||
Root: bytesutil.PadTo([]byte("pjcroot"), 32),
|
||||
}
|
||||
state.CurrentJustifiedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 31,
|
||||
Root: bytesutil.PadTo([]byte("cjcroot"), 32),
|
||||
}
|
||||
state.FinalizedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 32,
|
||||
Root: bytesutil.PadTo([]byte("fcroot"), 32),
|
||||
}
|
||||
state.PreviousEpochParticipation = []byte("previousepochparticipation")
|
||||
state.CurrentEpochParticipation = []byte("currentepochparticipation")
|
||||
state.InactivityScores = []uint64{1, 2, 3}
|
||||
state.CurrentSyncCommittee = ðpbalpha.SyncCommittee{
|
||||
Pubkeys: [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)},
|
||||
AggregatePubkey: bytesutil.PadTo([]byte("cscaggregatepubkey"), 48),
|
||||
}
|
||||
state.NextSyncCommittee = ðpbalpha.SyncCommittee{
|
||||
Pubkeys: [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)},
|
||||
AggregatePubkey: bytesutil.PadTo([]byte("nscaggregatepubkey"), 48),
|
||||
}
|
||||
state.LatestExecutionPayloadHeader = &enginev1.ExecutionPayloadHeaderCapella{
|
||||
ParentHash: bytesutil.PadTo([]byte("parenthash"), 32),
|
||||
FeeRecipient: bytesutil.PadTo([]byte("feerecipient"), 20),
|
||||
StateRoot: bytesutil.PadTo([]byte("stateroot"), 32),
|
||||
ReceiptsRoot: bytesutil.PadTo([]byte("receiptroot"), 32),
|
||||
LogsBloom: bytesutil.PadTo([]byte("logsbloom"), 256),
|
||||
PrevRandao: bytesutil.PadTo([]byte("prevrandao"), 32),
|
||||
BlockNumber: 123,
|
||||
GasLimit: 456,
|
||||
GasUsed: 789,
|
||||
Timestamp: 012,
|
||||
ExtraData: []byte("extradata"),
|
||||
BaseFeePerGas: bytesutil.PadTo([]byte("basefeepergas"), 32),
|
||||
BlockHash: bytesutil.PadTo([]byte("blockhash"), 32),
|
||||
TransactionsRoot: bytesutil.PadTo([]byte("transactionsroot"), 32),
|
||||
WithdrawalsRoot: bytesutil.PadTo([]byte("withdrawalsroot"), 32),
|
||||
}
|
||||
state.NextWithdrawalIndex = 123
|
||||
state.NextWithdrawalValidatorIndex = 123
|
||||
state.HistoricalSummaries = []*ethpbalpha.HistoricalSummary{
|
||||
{
|
||||
BlockSummaryRoot: bytesutil.PadTo([]byte("blocksummaryroot"), 32),
|
||||
StateSummaryRoot: bytesutil.PadTo([]byte("statesummaryroot"), 32),
|
||||
},
|
||||
{
|
||||
BlockSummaryRoot: bytesutil.PadTo([]byte("blocksummaryroot2"), 32),
|
||||
StateSummaryRoot: bytesutil.PadTo([]byte("statesummaryroot2"), 32),
|
||||
}}
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
result, err := BeaconStateCapellaToProto(source)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, result)
|
||||
assert.Equal(t, uint64(1), result.GenesisTime)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32), result.GenesisValidatorsRoot)
|
||||
assert.Equal(t, primitives.Slot(2), result.Slot)
|
||||
resultFork := result.Fork
|
||||
require.NotNil(t, resultFork)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("123"), 4), resultFork.PreviousVersion)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("456"), 4), resultFork.CurrentVersion)
|
||||
assert.Equal(t, primitives.Epoch(3), resultFork.Epoch)
|
||||
resultLatestBlockHeader := result.LatestBlockHeader
|
||||
require.NotNil(t, resultLatestBlockHeader)
|
||||
assert.Equal(t, primitives.Slot(4), resultLatestBlockHeader.Slot)
|
||||
assert.Equal(t, primitives.ValidatorIndex(5), resultLatestBlockHeader.ProposerIndex)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhparentroot"), 32), resultLatestBlockHeader.ParentRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhstateroot"), 32), resultLatestBlockHeader.StateRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhbodyroot"), 32), resultLatestBlockHeader.BodyRoot)
|
||||
assert.Equal(t, 8192, len(result.BlockRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockroots"), 32), result.BlockRoots[0])
|
||||
assert.Equal(t, 8192, len(result.StateRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroots"), 32), result.StateRoots[0])
|
||||
assert.Equal(t, 1, len(result.HistoricalRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("historicalroots"), 32), result.HistoricalRoots[0])
|
||||
resultEth1Data := result.Eth1Data
|
||||
require.NotNil(t, resultEth1Data)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1ddepositroot"), 32), resultEth1Data.DepositRoot)
|
||||
assert.Equal(t, uint64(6), resultEth1Data.DepositCount)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dblockhash"), 32), resultEth1Data.BlockHash)
|
||||
require.Equal(t, 1, len(result.Eth1DataVotes))
|
||||
resultEth1DataVote := result.Eth1DataVotes[0]
|
||||
require.NotNil(t, resultEth1DataVote)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvdepositroot"), 32), resultEth1DataVote.DepositRoot)
|
||||
assert.Equal(t, uint64(7), resultEth1DataVote.DepositCount)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvblockhash"), 32), resultEth1DataVote.BlockHash)
|
||||
assert.Equal(t, uint64(8), result.Eth1DepositIndex)
|
||||
require.Equal(t, 1, len(result.Validators))
|
||||
resultValidator := result.Validators[0]
|
||||
require.NotNil(t, resultValidator)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("publickey"), 48), resultValidator.Pubkey)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalcredentials"), 32), resultValidator.WithdrawalCredentials)
|
||||
assert.Equal(t, uint64(9), resultValidator.EffectiveBalance)
|
||||
assert.Equal(t, true, resultValidator.Slashed)
|
||||
assert.Equal(t, primitives.Epoch(10), resultValidator.ActivationEligibilityEpoch)
|
||||
assert.Equal(t, primitives.Epoch(11), resultValidator.ActivationEpoch)
|
||||
assert.Equal(t, primitives.Epoch(12), resultValidator.ExitEpoch)
|
||||
assert.Equal(t, primitives.Epoch(13), resultValidator.WithdrawableEpoch)
|
||||
assert.DeepEqual(t, []uint64{14}, result.Balances)
|
||||
assert.Equal(t, 65536, len(result.RandaoMixes))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("randaomixes"), 32), result.RandaoMixes[0])
|
||||
assert.DeepEqual(t, []uint64{15}, result.Slashings)
|
||||
assert.DeepEqual(t, bitfield.Bitvector4{1}, result.JustificationBits)
|
||||
resultPrevJustifiedCheckpoint := result.PreviousJustifiedCheckpoint
|
||||
require.NotNil(t, resultPrevJustifiedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(30), resultPrevJustifiedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("pjcroot"), 32), resultPrevJustifiedCheckpoint.Root)
|
||||
resultCurrJustifiedCheckpoint := result.CurrentJustifiedCheckpoint
|
||||
require.NotNil(t, resultCurrJustifiedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(31), resultCurrJustifiedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("cjcroot"), 32), resultCurrJustifiedCheckpoint.Root)
|
||||
resultFinalizedCheckpoint := result.FinalizedCheckpoint
|
||||
require.NotNil(t, resultFinalizedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(32), resultFinalizedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("fcroot"), 32), resultFinalizedCheckpoint.Root)
|
||||
assert.DeepEqual(t, []byte("previousepochparticipation"), result.PreviousEpochParticipation)
|
||||
assert.DeepEqual(t, []byte("currentepochparticipation"), result.CurrentEpochParticipation)
|
||||
assert.DeepEqual(t, []uint64{1, 2, 3}, result.InactivityScores)
|
||||
require.NotNil(t, result.CurrentSyncCommittee)
|
||||
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)}, result.CurrentSyncCommittee.Pubkeys)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("cscaggregatepubkey"), 48), result.CurrentSyncCommittee.AggregatePubkey)
|
||||
require.NotNil(t, result.NextSyncCommittee)
|
||||
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)}, result.NextSyncCommittee.Pubkeys)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("nscaggregatepubkey"), 48), result.NextSyncCommittee.AggregatePubkey)
|
||||
resultLatestExecutionPayloadHeader := result.LatestExecutionPayloadHeader
|
||||
require.NotNil(t, resultLatestExecutionPayloadHeader)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("parenthash"), 32), resultLatestExecutionPayloadHeader.ParentHash)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("feerecipient"), 20), resultLatestExecutionPayloadHeader.FeeRecipient)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroot"), 32), resultLatestExecutionPayloadHeader.StateRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("receiptroot"), 32), resultLatestExecutionPayloadHeader.ReceiptsRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("logsbloom"), 256), resultLatestExecutionPayloadHeader.LogsBloom)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("prevrandao"), 32), resultLatestExecutionPayloadHeader.PrevRandao)
|
||||
assert.Equal(t, uint64(123), resultLatestExecutionPayloadHeader.BlockNumber)
|
||||
assert.Equal(t, uint64(456), resultLatestExecutionPayloadHeader.GasLimit)
|
||||
assert.Equal(t, uint64(789), resultLatestExecutionPayloadHeader.GasUsed)
|
||||
assert.Equal(t, uint64(012), resultLatestExecutionPayloadHeader.Timestamp)
|
||||
assert.DeepEqual(t, []byte("extradata"), resultLatestExecutionPayloadHeader.ExtraData)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("basefeepergas"), 32), resultLatestExecutionPayloadHeader.BaseFeePerGas)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockhash"), 32), resultLatestExecutionPayloadHeader.BlockHash)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("transactionsroot"), 32), resultLatestExecutionPayloadHeader.TransactionsRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalsroot"), 32), resultLatestExecutionPayloadHeader.WithdrawalsRoot)
|
||||
assert.Equal(t, uint64(123), result.NextWithdrawalIndex)
|
||||
assert.Equal(t, primitives.ValidatorIndex(123), result.NextWithdrawalValidatorIndex)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blocksummaryroot"), 32), result.HistoricalSummaries[0].BlockSummaryRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("statesummaryroot"), 32), result.HistoricalSummaries[0].StateSummaryRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blocksummaryroot2"), 32), result.HistoricalSummaries[1].BlockSummaryRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("statesummaryroot2"), 32), result.HistoricalSummaries[1].StateSummaryRoot)
|
||||
}
|
||||
|
||||
func TestBeaconStateDenebToProto(t *testing.T) {
|
||||
source, err := util.NewBeaconStateDeneb(util.FillRootsNaturalOptDeneb, func(state *ethpbalpha.BeaconStateDeneb) error {
|
||||
state.GenesisTime = 1
|
||||
state.GenesisValidatorsRoot = bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32)
|
||||
state.Slot = 2
|
||||
state.Fork = ðpbalpha.Fork{
|
||||
PreviousVersion: bytesutil.PadTo([]byte("123"), 4),
|
||||
CurrentVersion: bytesutil.PadTo([]byte("456"), 4),
|
||||
Epoch: 3,
|
||||
}
|
||||
state.LatestBlockHeader = ðpbalpha.BeaconBlockHeader{
|
||||
Slot: 4,
|
||||
ProposerIndex: 5,
|
||||
ParentRoot: bytesutil.PadTo([]byte("lbhparentroot"), 32),
|
||||
StateRoot: bytesutil.PadTo([]byte("lbhstateroot"), 32),
|
||||
BodyRoot: bytesutil.PadTo([]byte("lbhbodyroot"), 32),
|
||||
}
|
||||
state.BlockRoots = [][]byte{bytesutil.PadTo([]byte("blockroots"), 32)}
|
||||
state.StateRoots = [][]byte{bytesutil.PadTo([]byte("stateroots"), 32)}
|
||||
state.HistoricalRoots = [][]byte{bytesutil.PadTo([]byte("historicalroots"), 32)}
|
||||
state.Eth1Data = ðpbalpha.Eth1Data{
|
||||
DepositRoot: bytesutil.PadTo([]byte("e1ddepositroot"), 32),
|
||||
DepositCount: 6,
|
||||
BlockHash: bytesutil.PadTo([]byte("e1dblockhash"), 32),
|
||||
}
|
||||
state.Eth1DataVotes = []*ethpbalpha.Eth1Data{{
|
||||
DepositRoot: bytesutil.PadTo([]byte("e1dvdepositroot"), 32),
|
||||
DepositCount: 7,
|
||||
BlockHash: bytesutil.PadTo([]byte("e1dvblockhash"), 32),
|
||||
}}
|
||||
state.Eth1DepositIndex = 8
|
||||
state.Validators = []*ethpbalpha.Validator{{
|
||||
PublicKey: bytesutil.PadTo([]byte("publickey"), 48),
|
||||
WithdrawalCredentials: bytesutil.PadTo([]byte("withdrawalcredentials"), 32),
|
||||
EffectiveBalance: 9,
|
||||
Slashed: true,
|
||||
ActivationEligibilityEpoch: 10,
|
||||
ActivationEpoch: 11,
|
||||
ExitEpoch: 12,
|
||||
WithdrawableEpoch: 13,
|
||||
}}
|
||||
state.Balances = []uint64{14}
|
||||
state.RandaoMixes = [][]byte{bytesutil.PadTo([]byte("randaomixes"), 32)}
|
||||
state.Slashings = []uint64{15}
|
||||
state.JustificationBits = bitfield.Bitvector4{1}
|
||||
state.PreviousJustifiedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 30,
|
||||
Root: bytesutil.PadTo([]byte("pjcroot"), 32),
|
||||
}
|
||||
state.CurrentJustifiedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 31,
|
||||
Root: bytesutil.PadTo([]byte("cjcroot"), 32),
|
||||
}
|
||||
state.FinalizedCheckpoint = ðpbalpha.Checkpoint{
|
||||
Epoch: 32,
|
||||
Root: bytesutil.PadTo([]byte("fcroot"), 32),
|
||||
}
|
||||
state.PreviousEpochParticipation = []byte("previousepochparticipation")
|
||||
state.CurrentEpochParticipation = []byte("currentepochparticipation")
|
||||
state.InactivityScores = []uint64{1, 2, 3}
|
||||
state.CurrentSyncCommittee = ðpbalpha.SyncCommittee{
|
||||
Pubkeys: [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)},
|
||||
AggregatePubkey: bytesutil.PadTo([]byte("cscaggregatepubkey"), 48),
|
||||
}
|
||||
state.NextSyncCommittee = ðpbalpha.SyncCommittee{
|
||||
Pubkeys: [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)},
|
||||
AggregatePubkey: bytesutil.PadTo([]byte("nscaggregatepubkey"), 48),
|
||||
}
|
||||
state.LatestExecutionPayloadHeader = &enginev1.ExecutionPayloadHeaderDeneb{
|
||||
ParentHash: bytesutil.PadTo([]byte("parenthash"), 32),
|
||||
FeeRecipient: bytesutil.PadTo([]byte("feerecipient"), 20),
|
||||
StateRoot: bytesutil.PadTo([]byte("stateroot"), 32),
|
||||
ReceiptsRoot: bytesutil.PadTo([]byte("receiptroot"), 32),
|
||||
LogsBloom: bytesutil.PadTo([]byte("logsbloom"), 256),
|
||||
PrevRandao: bytesutil.PadTo([]byte("prevrandao"), 32),
|
||||
BlockNumber: 123,
|
||||
GasLimit: 456,
|
||||
GasUsed: 789,
|
||||
Timestamp: 012,
|
||||
ExtraData: []byte("extradata"),
|
||||
BaseFeePerGas: bytesutil.PadTo([]byte("basefeepergas"), 32),
|
||||
BlockHash: bytesutil.PadTo([]byte("blockhash"), 32),
|
||||
TransactionsRoot: bytesutil.PadTo([]byte("transactionsroot"), 32),
|
||||
WithdrawalsRoot: bytesutil.PadTo([]byte("withdrawalsroot"), 32),
|
||||
BlobGasUsed: 343,
|
||||
ExcessBlobGas: 676,
|
||||
}
|
||||
state.NextWithdrawalIndex = 123
|
||||
state.NextWithdrawalValidatorIndex = 123
|
||||
state.HistoricalSummaries = []*ethpbalpha.HistoricalSummary{
|
||||
{
|
||||
BlockSummaryRoot: bytesutil.PadTo([]byte("blocksummaryroot"), 32),
|
||||
StateSummaryRoot: bytesutil.PadTo([]byte("statesummaryroot"), 32),
|
||||
},
|
||||
{
|
||||
BlockSummaryRoot: bytesutil.PadTo([]byte("blocksummaryroot2"), 32),
|
||||
StateSummaryRoot: bytesutil.PadTo([]byte("statesummaryroot2"), 32),
|
||||
}}
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
result, err := BeaconStateDenebToProto(source)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, result)
|
||||
assert.Equal(t, uint64(1), result.GenesisTime)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("genesisvalidatorsroot"), 32), result.GenesisValidatorsRoot)
|
||||
assert.Equal(t, primitives.Slot(2), result.Slot)
|
||||
resultFork := result.Fork
|
||||
require.NotNil(t, resultFork)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("123"), 4), resultFork.PreviousVersion)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("456"), 4), resultFork.CurrentVersion)
|
||||
assert.Equal(t, primitives.Epoch(3), resultFork.Epoch)
|
||||
resultLatestBlockHeader := result.LatestBlockHeader
|
||||
require.NotNil(t, resultLatestBlockHeader)
|
||||
assert.Equal(t, primitives.Slot(4), resultLatestBlockHeader.Slot)
|
||||
assert.Equal(t, primitives.ValidatorIndex(5), resultLatestBlockHeader.ProposerIndex)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhparentroot"), 32), resultLatestBlockHeader.ParentRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhstateroot"), 32), resultLatestBlockHeader.StateRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("lbhbodyroot"), 32), resultLatestBlockHeader.BodyRoot)
|
||||
assert.Equal(t, 8192, len(result.BlockRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockroots"), 32), result.BlockRoots[0])
|
||||
assert.Equal(t, 8192, len(result.StateRoots))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroots"), 32), result.StateRoots[0])
|
||||
resultEth1Data := result.Eth1Data
|
||||
require.NotNil(t, resultEth1Data)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1ddepositroot"), 32), resultEth1Data.DepositRoot)
|
||||
assert.Equal(t, uint64(6), resultEth1Data.DepositCount)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dblockhash"), 32), resultEth1Data.BlockHash)
|
||||
require.Equal(t, 1, len(result.Eth1DataVotes))
|
||||
resultEth1DataVote := result.Eth1DataVotes[0]
|
||||
require.NotNil(t, resultEth1DataVote)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvdepositroot"), 32), resultEth1DataVote.DepositRoot)
|
||||
assert.Equal(t, uint64(7), resultEth1DataVote.DepositCount)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("e1dvblockhash"), 32), resultEth1DataVote.BlockHash)
|
||||
assert.Equal(t, uint64(8), result.Eth1DepositIndex)
|
||||
require.Equal(t, 1, len(result.Validators))
|
||||
resultValidator := result.Validators[0]
|
||||
require.NotNil(t, resultValidator)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("publickey"), 48), resultValidator.Pubkey)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalcredentials"), 32), resultValidator.WithdrawalCredentials)
|
||||
assert.Equal(t, uint64(9), resultValidator.EffectiveBalance)
|
||||
assert.Equal(t, true, resultValidator.Slashed)
|
||||
assert.Equal(t, primitives.Epoch(10), resultValidator.ActivationEligibilityEpoch)
|
||||
assert.Equal(t, primitives.Epoch(11), resultValidator.ActivationEpoch)
|
||||
assert.Equal(t, primitives.Epoch(12), resultValidator.ExitEpoch)
|
||||
assert.Equal(t, primitives.Epoch(13), resultValidator.WithdrawableEpoch)
|
||||
assert.DeepEqual(t, []uint64{14}, result.Balances)
|
||||
assert.Equal(t, 65536, len(result.RandaoMixes))
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("randaomixes"), 32), result.RandaoMixes[0])
|
||||
assert.DeepEqual(t, []uint64{15}, result.Slashings)
|
||||
assert.DeepEqual(t, bitfield.Bitvector4{1}, result.JustificationBits)
|
||||
resultPrevJustifiedCheckpoint := result.PreviousJustifiedCheckpoint
|
||||
require.NotNil(t, resultPrevJustifiedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(30), resultPrevJustifiedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("pjcroot"), 32), resultPrevJustifiedCheckpoint.Root)
|
||||
resultCurrJustifiedCheckpoint := result.CurrentJustifiedCheckpoint
|
||||
require.NotNil(t, resultCurrJustifiedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(31), resultCurrJustifiedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("cjcroot"), 32), resultCurrJustifiedCheckpoint.Root)
|
||||
resultFinalizedCheckpoint := result.FinalizedCheckpoint
|
||||
require.NotNil(t, resultFinalizedCheckpoint)
|
||||
assert.Equal(t, primitives.Epoch(32), resultFinalizedCheckpoint.Epoch)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("fcroot"), 32), resultFinalizedCheckpoint.Root)
|
||||
assert.DeepEqual(t, []byte("previousepochparticipation"), result.PreviousEpochParticipation)
|
||||
assert.DeepEqual(t, []byte("currentepochparticipation"), result.CurrentEpochParticipation)
|
||||
assert.DeepEqual(t, []uint64{1, 2, 3}, result.InactivityScores)
|
||||
require.NotNil(t, result.CurrentSyncCommittee)
|
||||
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("cscpubkeys"), 48)}, result.CurrentSyncCommittee.Pubkeys)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("cscaggregatepubkey"), 48), result.CurrentSyncCommittee.AggregatePubkey)
|
||||
require.NotNil(t, result.NextSyncCommittee)
|
||||
assert.DeepEqual(t, [][]byte{bytesutil.PadTo([]byte("nscpubkeys"), 48)}, result.NextSyncCommittee.Pubkeys)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("nscaggregatepubkey"), 48), result.NextSyncCommittee.AggregatePubkey)
|
||||
resultLatestExecutionPayloadHeader := result.LatestExecutionPayloadHeader
|
||||
require.NotNil(t, resultLatestExecutionPayloadHeader)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("parenthash"), 32), resultLatestExecutionPayloadHeader.ParentHash)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("feerecipient"), 20), resultLatestExecutionPayloadHeader.FeeRecipient)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("stateroot"), 32), resultLatestExecutionPayloadHeader.StateRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("receiptroot"), 32), resultLatestExecutionPayloadHeader.ReceiptsRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("logsbloom"), 256), resultLatestExecutionPayloadHeader.LogsBloom)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("prevrandao"), 32), resultLatestExecutionPayloadHeader.PrevRandao)
|
||||
assert.Equal(t, uint64(123), resultLatestExecutionPayloadHeader.BlockNumber)
|
||||
assert.Equal(t, uint64(456), resultLatestExecutionPayloadHeader.GasLimit)
|
||||
assert.Equal(t, uint64(789), resultLatestExecutionPayloadHeader.GasUsed)
|
||||
assert.Equal(t, uint64(012), resultLatestExecutionPayloadHeader.Timestamp)
|
||||
assert.DeepEqual(t, []byte("extradata"), resultLatestExecutionPayloadHeader.ExtraData)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("basefeepergas"), 32), resultLatestExecutionPayloadHeader.BaseFeePerGas)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blockhash"), 32), resultLatestExecutionPayloadHeader.BlockHash)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("transactionsroot"), 32), resultLatestExecutionPayloadHeader.TransactionsRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("withdrawalsroot"), 32), resultLatestExecutionPayloadHeader.WithdrawalsRoot)
|
||||
assert.DeepEqual(t, uint64(343), resultLatestExecutionPayloadHeader.BlobGasUsed)
|
||||
assert.DeepEqual(t, uint64(676), resultLatestExecutionPayloadHeader.ExcessBlobGas)
|
||||
assert.Equal(t, uint64(123), result.NextWithdrawalIndex)
|
||||
assert.Equal(t, primitives.ValidatorIndex(123), result.NextWithdrawalValidatorIndex)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blocksummaryroot"), 32), result.HistoricalSummaries[0].BlockSummaryRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("statesummaryroot"), 32), result.HistoricalSummaries[0].StateSummaryRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("blocksummaryroot2"), 32), result.HistoricalSummaries[1].BlockSummaryRoot)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("statesummaryroot2"), 32), result.HistoricalSummaries[1].StateSummaryRoot)
|
||||
}
|
||||
|
||||
func TestV1Alpha1SignedBLSToExecChangeToV2(t *testing.T) {
|
||||
alphaChange := ðpbalpha.SignedBLSToExecutionChange{
|
||||
Message: ðpbalpha.BLSToExecutionChange{
|
||||
ValidatorIndex: validatorIndex,
|
||||
FromBlsPubkey: bytesutil.PadTo([]byte("fromblspubkey"), 48),
|
||||
ToExecutionAddress: bytesutil.PadTo([]byte("toexecutionaddress"), 20),
|
||||
},
|
||||
Signature: signature,
|
||||
}
|
||||
change := V1Alpha1SignedBLSToExecChangeToV2(alphaChange)
|
||||
require.NotNil(t, change)
|
||||
require.NotNil(t, change.Message)
|
||||
assert.DeepEqual(t, signature, change.Signature)
|
||||
assert.Equal(t, validatorIndex, change.Message.ValidatorIndex)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("fromblspubkey"), 48), change.Message.FromBlsPubkey)
|
||||
assert.DeepEqual(t, bytesutil.PadTo([]byte("toexecutionaddress"), 20), change.Message.ToExecutionAddress)
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
ethpbv2 "github.com/prysmaticlabs/prysm/v5/proto/eth/v2"
|
||||
ethpbalpha "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// AltairToV1Alpha1SignedBlock converts a v2 SignedBeaconBlockAltair proto to a v1alpha1 proto.
|
||||
func AltairToV1Alpha1SignedBlock(altairBlk *ethpbv2.SignedBeaconBlockAltair) (*ethpbalpha.SignedBeaconBlockAltair, error) {
|
||||
marshaledBlk, err := proto.Marshal(altairBlk)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not marshal block")
|
||||
}
|
||||
v1alpha1Block := ðpbalpha.SignedBeaconBlockAltair{}
|
||||
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal block")
|
||||
}
|
||||
return v1alpha1Block, nil
|
||||
}
|
||||
|
||||
// BellatrixToV1Alpha1SignedBlock converts a v2 SignedBeaconBlockBellatrix proto to a v1alpha1 proto.
|
||||
func BellatrixToV1Alpha1SignedBlock(bellatrixBlk *ethpbv2.SignedBeaconBlockBellatrix) (*ethpbalpha.SignedBeaconBlockBellatrix, error) {
|
||||
marshaledBlk, err := proto.Marshal(bellatrixBlk)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not marshal block")
|
||||
}
|
||||
v1alpha1Block := ðpbalpha.SignedBeaconBlockBellatrix{}
|
||||
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal block")
|
||||
}
|
||||
return v1alpha1Block, nil
|
||||
}
|
||||
|
||||
// CapellaToV1Alpha1SignedBlock converts a v2 SignedBeaconBlockCapella proto to a v1alpha1 proto.
|
||||
func CapellaToV1Alpha1SignedBlock(capellaBlk *ethpbv2.SignedBeaconBlockCapella) (*ethpbalpha.SignedBeaconBlockCapella, error) {
|
||||
marshaledBlk, err := proto.Marshal(capellaBlk)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not marshal block")
|
||||
}
|
||||
v1alpha1Block := ðpbalpha.SignedBeaconBlockCapella{}
|
||||
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal block")
|
||||
}
|
||||
return v1alpha1Block, nil
|
||||
}
|
||||
|
||||
// DenebToV1Alpha1SignedBlock converts a v2 SignedBeaconBlockDeneb proto to a v1alpha1 proto.
|
||||
func DenebToV1Alpha1SignedBlock(denebBlk *ethpbv2.SignedBeaconBlockDeneb) (*ethpbalpha.SignedBeaconBlockDeneb, error) {
|
||||
marshaledBlk, err := proto.Marshal(denebBlk)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not marshal block")
|
||||
}
|
||||
v1alpha1Block := ðpbalpha.SignedBeaconBlockDeneb{}
|
||||
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal block")
|
||||
}
|
||||
return v1alpha1Block, nil
|
||||
}
|
||||
|
||||
// V2BeaconBlockDenebToV1Alpha1 converts a v2 Deneb beacon block to a v1alpha1
|
||||
// Deneb block.
|
||||
func V2BeaconBlockDenebToV1Alpha1(v2block *ethpbv2.BeaconBlockDeneb) (*ethpbalpha.BeaconBlockDeneb, error) {
|
||||
marshaledBlk, err := proto.Marshal(v2block)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not marshal block")
|
||||
}
|
||||
v1alpha1block := ðpbalpha.BeaconBlockDeneb{}
|
||||
if err := proto.Unmarshal(marshaledBlk, v1alpha1block); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal block")
|
||||
}
|
||||
return v1alpha1block, nil
|
||||
}
|
||||
|
||||
// BlindedBellatrixToV1Alpha1SignedBlock converts a v2 SignedBlindedBeaconBlockBellatrix proto to a v1alpha1 proto.
|
||||
func BlindedBellatrixToV1Alpha1SignedBlock(bellatrixBlk *ethpbv2.SignedBlindedBeaconBlockBellatrix) (*ethpbalpha.SignedBlindedBeaconBlockBellatrix, error) {
|
||||
marshaledBlk, err := proto.Marshal(bellatrixBlk)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not marshal block")
|
||||
}
|
||||
v1alpha1Block := ðpbalpha.SignedBlindedBeaconBlockBellatrix{}
|
||||
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal block")
|
||||
}
|
||||
return v1alpha1Block, nil
|
||||
}
|
||||
|
||||
// BlindedCapellaToV1Alpha1SignedBlock converts a v2 SignedBlindedBeaconBlockCapella proto to a v1alpha1 proto.
|
||||
func BlindedCapellaToV1Alpha1SignedBlock(capellaBlk *ethpbv2.SignedBlindedBeaconBlockCapella) (*ethpbalpha.SignedBlindedBeaconBlockCapella, error) {
|
||||
marshaledBlk, err := proto.Marshal(capellaBlk)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not marshal block")
|
||||
}
|
||||
v1alpha1Block := ðpbalpha.SignedBlindedBeaconBlockCapella{}
|
||||
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal block")
|
||||
}
|
||||
return v1alpha1Block, nil
|
||||
}
|
||||
|
||||
// BlindedDenebToV1Alpha1SignedBlock converts a v2 SignedBlindedBeaconBlockDeneb proto to a v1alpha1 proto.
|
||||
func BlindedDenebToV1Alpha1SignedBlock(denebBlk *ethpbv2.SignedBlindedBeaconBlockDeneb) (*ethpbalpha.SignedBlindedBeaconBlockDeneb, error) {
|
||||
marshaledBlk, err := proto.Marshal(denebBlk)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not marshal block")
|
||||
}
|
||||
v1alpha1Block := ðpbalpha.SignedBlindedBeaconBlockDeneb{}
|
||||
if err := proto.Unmarshal(marshaledBlk, v1alpha1Block); err != nil {
|
||||
return nil, errors.Wrap(err, "could not unmarshal block")
|
||||
}
|
||||
return v1alpha1Block, nil
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
|
||||
ethpbv1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1"
|
||||
ethpbv2 "github.com/prysmaticlabs/prysm/v5/proto/eth/v2"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
||||
"github.com/prysmaticlabs/prysm/v5/testing/util"
|
||||
)
|
||||
|
||||
func Test_AltairToV1Alpha1SignedBlock(t *testing.T) {
|
||||
v2Block := util.HydrateV2AltairSignedBeaconBlock(ðpbv2.SignedBeaconBlockAltair{})
|
||||
v2Block.Message.Slot = slot
|
||||
v2Block.Message.ProposerIndex = validatorIndex
|
||||
v2Block.Message.ParentRoot = parentRoot
|
||||
v2Block.Message.StateRoot = stateRoot
|
||||
v2Block.Message.Body.RandaoReveal = randaoReveal
|
||||
v2Block.Message.Body.Eth1Data = ðpbv1.Eth1Data{
|
||||
DepositRoot: depositRoot,
|
||||
DepositCount: depositCount,
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
syncCommitteeBits := bitfield.NewBitvector512()
|
||||
syncCommitteeBits.SetBitAt(100, true)
|
||||
v2Block.Message.Body.SyncAggregate = ðpbv1.SyncAggregate{
|
||||
SyncCommitteeBits: syncCommitteeBits,
|
||||
SyncCommitteeSignature: signature,
|
||||
}
|
||||
v2Block.Signature = signature
|
||||
|
||||
alphaBlock, err := AltairToV1Alpha1SignedBlock(v2Block)
|
||||
require.NoError(t, err)
|
||||
alphaRoot, err := alphaBlock.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v2Root, err := v2Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, v2Root, alphaRoot)
|
||||
}
|
||||
|
||||
func Test_BellatrixToV1Alpha1SignedBlock(t *testing.T) {
|
||||
v2Block := util.HydrateV2BellatrixSignedBeaconBlock(ðpbv2.SignedBeaconBlockBellatrix{})
|
||||
v2Block.Message.Slot = slot
|
||||
v2Block.Message.ProposerIndex = validatorIndex
|
||||
v2Block.Message.ParentRoot = parentRoot
|
||||
v2Block.Message.StateRoot = stateRoot
|
||||
v2Block.Message.Body.RandaoReveal = randaoReveal
|
||||
v2Block.Message.Body.Eth1Data = ðpbv1.Eth1Data{
|
||||
DepositRoot: depositRoot,
|
||||
DepositCount: depositCount,
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
syncCommitteeBits := bitfield.NewBitvector512()
|
||||
syncCommitteeBits.SetBitAt(100, true)
|
||||
v2Block.Message.Body.SyncAggregate = ðpbv1.SyncAggregate{
|
||||
SyncCommitteeBits: syncCommitteeBits,
|
||||
SyncCommitteeSignature: signature,
|
||||
}
|
||||
v2Block.Message.Body.ExecutionPayload = &enginev1.ExecutionPayload{
|
||||
ParentHash: parentHash,
|
||||
FeeRecipient: feeRecipient,
|
||||
StateRoot: stateRoot,
|
||||
ReceiptsRoot: receiptsRoot,
|
||||
LogsBloom: logsBloom,
|
||||
PrevRandao: prevRandao,
|
||||
BlockNumber: blockNumber,
|
||||
GasLimit: gasLimit,
|
||||
GasUsed: gasUsed,
|
||||
Timestamp: timestamp,
|
||||
ExtraData: extraData,
|
||||
BaseFeePerGas: baseFeePerGas,
|
||||
BlockHash: blockHash,
|
||||
Transactions: [][]byte{[]byte("transaction1"), []byte("transaction2")},
|
||||
}
|
||||
v2Block.Signature = signature
|
||||
|
||||
alphaBlock, err := BellatrixToV1Alpha1SignedBlock(v2Block)
|
||||
require.NoError(t, err)
|
||||
alphaRoot, err := alphaBlock.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v2Root, err := v2Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, v2Root, alphaRoot)
|
||||
}
|
||||
|
||||
func Test_BlindedBellatrixToV1Alpha1SignedBlock(t *testing.T) {
|
||||
v2Block := util.HydrateV2SignedBlindedBeaconBlockBellatrix(ðpbv2.SignedBlindedBeaconBlockBellatrix{})
|
||||
v2Block.Message.Slot = slot
|
||||
v2Block.Message.ProposerIndex = validatorIndex
|
||||
v2Block.Message.ParentRoot = parentRoot
|
||||
v2Block.Message.StateRoot = stateRoot
|
||||
v2Block.Message.Body.RandaoReveal = randaoReveal
|
||||
v2Block.Message.Body.Eth1Data = ðpbv1.Eth1Data{
|
||||
DepositRoot: depositRoot,
|
||||
DepositCount: depositCount,
|
||||
BlockHash: blockHash,
|
||||
}
|
||||
syncCommitteeBits := bitfield.NewBitvector512()
|
||||
syncCommitteeBits.SetBitAt(100, true)
|
||||
v2Block.Message.Body.SyncAggregate = ðpbv1.SyncAggregate{
|
||||
SyncCommitteeBits: syncCommitteeBits,
|
||||
SyncCommitteeSignature: signature,
|
||||
}
|
||||
v2Block.Message.Body.ExecutionPayloadHeader = &enginev1.ExecutionPayloadHeader{
|
||||
ParentHash: parentHash,
|
||||
FeeRecipient: feeRecipient,
|
||||
StateRoot: stateRoot,
|
||||
ReceiptsRoot: receiptsRoot,
|
||||
LogsBloom: logsBloom,
|
||||
PrevRandao: prevRandao,
|
||||
BlockNumber: blockNumber,
|
||||
GasLimit: gasLimit,
|
||||
GasUsed: gasUsed,
|
||||
Timestamp: timestamp,
|
||||
ExtraData: extraData,
|
||||
BaseFeePerGas: baseFeePerGas,
|
||||
BlockHash: blockHash,
|
||||
TransactionsRoot: transactionsRoot,
|
||||
}
|
||||
v2Block.Signature = signature
|
||||
|
||||
alphaBlock, err := BlindedBellatrixToV1Alpha1SignedBlock(v2Block)
|
||||
require.NoError(t, err)
|
||||
alphaRoot, err := alphaBlock.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
v2Root, err := v2Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
assert.DeepEqual(t, v2Root, alphaRoot)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
515
proto/prysm/v1alpha1/node.pb.go
generated
515
proto/prysm/v1alpha1/node.pb.go
generated
@@ -130,6 +130,53 @@ func (ConnectionState) EnumDescriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
type HealthRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
SyncingStatus uint64 `protobuf:"varint,1,opt,name=syncing_status,json=syncingStatus,proto3" json:"syncing_status,omitempty"`
|
||||
}
|
||||
|
||||
func (x *HealthRequest) Reset() {
|
||||
*x = HealthRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *HealthRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*HealthRequest) ProtoMessage() {}
|
||||
|
||||
func (x *HealthRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use HealthRequest.ProtoReflect.Descriptor instead.
|
||||
func (*HealthRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *HealthRequest) GetSyncingStatus() uint64 {
|
||||
if x != nil {
|
||||
return x.SyncingStatus
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type SyncStatus struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -141,7 +188,7 @@ type SyncStatus struct {
|
||||
func (x *SyncStatus) Reset() {
|
||||
*x = SyncStatus{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[0]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -154,7 +201,7 @@ func (x *SyncStatus) String() string {
|
||||
func (*SyncStatus) ProtoMessage() {}
|
||||
|
||||
func (x *SyncStatus) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[0]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -167,7 +214,7 @@ func (x *SyncStatus) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use SyncStatus.ProtoReflect.Descriptor instead.
|
||||
func (*SyncStatus) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{0}
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *SyncStatus) GetSyncing() bool {
|
||||
@@ -190,7 +237,7 @@ type Genesis struct {
|
||||
func (x *Genesis) Reset() {
|
||||
*x = Genesis{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[1]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -203,7 +250,7 @@ func (x *Genesis) String() string {
|
||||
func (*Genesis) ProtoMessage() {}
|
||||
|
||||
func (x *Genesis) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[1]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -216,7 +263,7 @@ func (x *Genesis) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Genesis.ProtoReflect.Descriptor instead.
|
||||
func (*Genesis) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{1}
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Genesis) GetGenesisTime() *timestamppb.Timestamp {
|
||||
@@ -252,7 +299,7 @@ type Version struct {
|
||||
func (x *Version) Reset() {
|
||||
*x = Version{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[2]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -265,7 +312,7 @@ func (x *Version) String() string {
|
||||
func (*Version) ProtoMessage() {}
|
||||
|
||||
func (x *Version) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[2]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -278,7 +325,7 @@ func (x *Version) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Version.ProtoReflect.Descriptor instead.
|
||||
func (*Version) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{2}
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *Version) GetVersion() string {
|
||||
@@ -306,7 +353,7 @@ type ImplementedServices struct {
|
||||
func (x *ImplementedServices) Reset() {
|
||||
*x = ImplementedServices{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[3]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -319,7 +366,7 @@ func (x *ImplementedServices) String() string {
|
||||
func (*ImplementedServices) ProtoMessage() {}
|
||||
|
||||
func (x *ImplementedServices) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[3]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -332,7 +379,7 @@ func (x *ImplementedServices) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use ImplementedServices.ProtoReflect.Descriptor instead.
|
||||
func (*ImplementedServices) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{3}
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *ImplementedServices) GetServices() []string {
|
||||
@@ -353,7 +400,7 @@ type PeerRequest struct {
|
||||
func (x *PeerRequest) Reset() {
|
||||
*x = PeerRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[4]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -366,7 +413,7 @@ func (x *PeerRequest) String() string {
|
||||
func (*PeerRequest) ProtoMessage() {}
|
||||
|
||||
func (x *PeerRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[4]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -379,7 +426,7 @@ func (x *PeerRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use PeerRequest.ProtoReflect.Descriptor instead.
|
||||
func (*PeerRequest) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{4}
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *PeerRequest) GetPeerId() string {
|
||||
@@ -400,7 +447,7 @@ type Peers struct {
|
||||
func (x *Peers) Reset() {
|
||||
*x = Peers{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[5]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -413,7 +460,7 @@ func (x *Peers) String() string {
|
||||
func (*Peers) ProtoMessage() {}
|
||||
|
||||
func (x *Peers) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[5]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -426,7 +473,7 @@ func (x *Peers) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Peers.ProtoReflect.Descriptor instead.
|
||||
func (*Peers) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{5}
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *Peers) GetPeers() []*Peer {
|
||||
@@ -451,7 +498,7 @@ type Peer struct {
|
||||
func (x *Peer) Reset() {
|
||||
*x = Peer{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[6]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -464,7 +511,7 @@ func (x *Peer) String() string {
|
||||
func (*Peer) ProtoMessage() {}
|
||||
|
||||
func (x *Peer) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[6]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[7]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -477,7 +524,7 @@ func (x *Peer) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Peer.ProtoReflect.Descriptor instead.
|
||||
func (*Peer) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{6}
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *Peer) GetAddress() string {
|
||||
@@ -528,7 +575,7 @@ type HostData struct {
|
||||
func (x *HostData) Reset() {
|
||||
*x = HostData{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[7]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -541,7 +588,7 @@ func (x *HostData) String() string {
|
||||
func (*HostData) ProtoMessage() {}
|
||||
|
||||
func (x *HostData) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[7]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[8]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -554,7 +601,7 @@ func (x *HostData) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use HostData.ProtoReflect.Descriptor instead.
|
||||
func (*HostData) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{7}
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
func (x *HostData) GetAddresses() []string {
|
||||
@@ -592,7 +639,7 @@ type ETH1ConnectionStatus struct {
|
||||
func (x *ETH1ConnectionStatus) Reset() {
|
||||
*x = ETH1ConnectionStatus{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[8]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[9]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -605,7 +652,7 @@ func (x *ETH1ConnectionStatus) String() string {
|
||||
func (*ETH1ConnectionStatus) ProtoMessage() {}
|
||||
|
||||
func (x *ETH1ConnectionStatus) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[8]
|
||||
mi := &file_proto_prysm_v1alpha1_node_proto_msgTypes[9]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -618,7 +665,7 @@ func (x *ETH1ConnectionStatus) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use ETH1ConnectionStatus.ProtoReflect.Descriptor instead.
|
||||
func (*ETH1ConnectionStatus) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{8}
|
||||
return file_proto_prysm_v1alpha1_node_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *ETH1ConnectionStatus) GetCurrentAddress() string {
|
||||
@@ -663,143 +710,154 @@ var file_proto_prysm_v1alpha1_node_proto_rawDesc = []byte{
|
||||
0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x74, 0x68, 0x2f,
|
||||
0x65, 0x78, 0x74, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x22, 0x26, 0x0a, 0x0a, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12,
|
||||
0x18, 0x0a, 0x07, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
|
||||
0x52, 0x07, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x22, 0xc2, 0x01, 0x0a, 0x07, 0x47, 0x65,
|
||||
0x6e, 0x65, 0x73, 0x69, 0x73, 0x12, 0x3d, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73,
|
||||
0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f,
|
||||
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69,
|
||||
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73,
|
||||
0x54, 0x69, 0x6d, 0x65, 0x12, 0x38, 0x0a, 0x18, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f,
|
||||
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x16, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x43,
|
||||
0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3e,
|
||||
0x0a, 0x17, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61,
|
||||
0x74, 0x6f, 0x72, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42,
|
||||
0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x15, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73,
|
||||
0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0x3f,
|
||||
0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73,
|
||||
0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22,
|
||||
0x31, 0x0a, 0x13, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x65, 0x64, 0x53, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x73, 0x22, 0x26, 0x0a, 0x0b, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x64, 0x22, 0x3a, 0x0a, 0x05, 0x50, 0x65,
|
||||
0x65, 0x72, 0x73, 0x12, 0x31, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03,
|
||||
0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74,
|
||||
0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52,
|
||||
0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x22, 0xe2, 0x01, 0x0a, 0x04, 0x50, 0x65, 0x65, 0x72, 0x12,
|
||||
0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x42, 0x0a, 0x09, 0x64, 0x69, 0x72,
|
||||
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c,
|
||||
0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x52, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x51, 0x0a,
|
||||
0x10, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74,
|
||||
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65,
|
||||
0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e,
|
||||
0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52,
|
||||
0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65,
|
||||
0x12, 0x17, 0x0a, 0x07, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x72,
|
||||
0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x72, 0x22, 0x53, 0x0a, 0x08, 0x48,
|
||||
0x6f, 0x73, 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65,
|
||||
0x73, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x61, 0x64, 0x64, 0x72,
|
||||
0x65, 0x73, 0x73, 0x65, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x69, 0x64,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x64, 0x12, 0x10,
|
||||
0x0a, 0x03, 0x65, 0x6e, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x72,
|
||||
0x22, 0xc4, 0x01, 0x0a, 0x14, 0x45, 0x54, 0x48, 0x31, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x75, 0x72,
|
||||
0x72, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65,
|
||||
0x73, 0x73, 0x12, 0x38, 0x0a, 0x18, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f,
|
||||
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x16, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e,
|
||||
0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x1c, 0x0a, 0x09,
|
||||
0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52,
|
||||
0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x63, 0x6f,
|
||||
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18,
|
||||
0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2a, 0x37, 0x0a, 0x0d, 0x50, 0x65, 0x65, 0x72, 0x44,
|
||||
0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e,
|
||||
0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x42, 0x4f, 0x55, 0x4e, 0x44,
|
||||
0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x55, 0x54, 0x42, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x02,
|
||||
0x2a, 0x55, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74,
|
||||
0x61, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43,
|
||||
0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x4e, 0x4e,
|
||||
0x45, 0x43, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x4e,
|
||||
0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x4f, 0x4e, 0x4e, 0x45,
|
||||
0x43, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x03, 0x32, 0x93, 0x07, 0x0a, 0x04, 0x4e, 0x6f, 0x64, 0x65,
|
||||
0x12, 0x6e, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x75,
|
||||
0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65,
|
||||
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61,
|
||||
0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x22, 0x82, 0xd3,
|
||||
0xe4, 0x93, 0x02, 0x1c, 0x12, 0x1a, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70,
|
||||
0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67,
|
||||
0x12, 0x68, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x12, 0x16,
|
||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
|
||||
0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47,
|
||||
0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x12, 0x1a,
|
||||
0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f,
|
||||
0x64, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x12, 0x68, 0x0a, 0x0a, 0x47, 0x65,
|
||||
0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
|
||||
0x1a, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e,
|
||||
0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x12, 0x1a, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76,
|
||||
0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x76, 0x65, 0x72,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x12, 0x82, 0x01, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6d, 0x70,
|
||||
0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
|
||||
0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x2a, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||
0x2e, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76,
|
||||
0x69, 0x63, 0x65, 0x73, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x12, 0x1b, 0x2f, 0x65,
|
||||
0x6f, 0x22, 0x36, 0x0a, 0x0d, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x74,
|
||||
0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63,
|
||||
0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x26, 0x0a, 0x0a, 0x53, 0x79, 0x6e,
|
||||
0x63, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x79, 0x6e, 0x63, 0x69,
|
||||
0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e,
|
||||
0x67, 0x22, 0xc2, 0x01, 0x0a, 0x07, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x12, 0x3d, 0x0a,
|
||||
0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52,
|
||||
0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x38, 0x0a, 0x18,
|
||||
0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74,
|
||||
0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x16,
|
||||
0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x41,
|
||||
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3e, 0x0a, 0x17, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69,
|
||||
0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x5f, 0x72, 0x6f, 0x6f,
|
||||
0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52,
|
||||
0x15, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f,
|
||||
0x72, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0x3f, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6d,
|
||||
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d,
|
||||
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x31, 0x0a, 0x13, 0x49, 0x6d, 0x70, 0x6c, 0x65,
|
||||
0x6d, 0x65, 0x6e, 0x74, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09,
|
||||
0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x22, 0x26, 0x0a, 0x0b, 0x50, 0x65,
|
||||
0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x65, 0x65,
|
||||
0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x65, 0x65, 0x72,
|
||||
0x49, 0x64, 0x22, 0x3a, 0x0a, 0x05, 0x50, 0x65, 0x65, 0x72, 0x73, 0x12, 0x31, 0x0a, 0x05, 0x70,
|
||||
0x65, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x74, 0x68,
|
||||
0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68,
|
||||
0x61, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x22, 0xe2,
|
||||
0x01, 0x0a, 0x04, 0x50, 0x65, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65,
|
||||
0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73,
|
||||
0x73, 0x12, 0x42, 0x0a, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x65,
|
||||
0x72, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x64, 0x69, 0x72, 0x65,
|
||||
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x51, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32,
|
||||
0x26, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76,
|
||||
0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x65, 0x65, 0x72,
|
||||
0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49,
|
||||
0x64, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
|
||||
0x65, 0x6e, 0x72, 0x22, 0x53, 0x0a, 0x08, 0x48, 0x6f, 0x73, 0x74, 0x44, 0x61, 0x74, 0x61, 0x12,
|
||||
0x1c, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03,
|
||||
0x28, 0x09, 0x52, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x12, 0x17, 0x0a,
|
||||
0x07, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
|
||||
0x70, 0x65, 0x65, 0x72, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x72, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x72, 0x22, 0xc4, 0x01, 0x0a, 0x14, 0x45, 0x54, 0x48,
|
||||
0x31, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75,
|
||||
0x73, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x64, 0x64,
|
||||
0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x75, 0x72, 0x72,
|
||||
0x65, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x38, 0x0a, 0x18, 0x63, 0x75,
|
||||
0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x16, 0x63, 0x75,
|
||||
0x72, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45,
|
||||
0x72, 0x72, 0x6f, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65,
|
||||
0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
|
||||
0x65, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x63,
|
||||
0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2a,
|
||||
0x37, 0x0a, 0x0d, 0x50, 0x65, 0x65, 0x72, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a,
|
||||
0x07, 0x49, 0x4e, 0x42, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x4f, 0x55,
|
||||
0x54, 0x42, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x02, 0x2a, 0x55, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x6e,
|
||||
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x44,
|
||||
0x49, 0x53, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x11, 0x0a,
|
||||
0x0d, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x01,
|
||||
0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12,
|
||||
0x0e, 0x0a, 0x0a, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x49, 0x4e, 0x47, 0x10, 0x03, 0x32,
|
||||
0x81, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x6e, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x53,
|
||||
0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
|
||||
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74,
|
||||
0x79, 0x1a, 0x21, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68,
|
||||
0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74,
|
||||
0x61, 0x74, 0x75, 0x73, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x12, 0x1a, 0x2f, 0x65,
|
||||
0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65,
|
||||
0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x62, 0x0a, 0x07, 0x47, 0x65, 0x74,
|
||||
0x48, 0x6f, 0x73, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1f, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c,
|
||||
0x70, 0x68, 0x61, 0x31, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x44, 0x61, 0x74, 0x61, 0x22, 0x1e, 0x82,
|
||||
0xd3, 0xe4, 0x93, 0x02, 0x18, 0x12, 0x16, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c,
|
||||
0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x70, 0x32, 0x70, 0x12, 0x6b, 0x0a,
|
||||
0x07, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x12, 0x22, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x2f, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x68, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x47,
|
||||
0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1e,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31,
|
||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x22, 0x22,
|
||||
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x12, 0x1a, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61,
|
||||
0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73,
|
||||
0x69, 0x73, 0x12, 0x68, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1e, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72,
|
||||
0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||
0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c,
|
||||
0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02,
|
||||
0x19, 0x12, 0x17, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||
0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x70, 0x65, 0x65, 0x72, 0x12, 0x63, 0x0a, 0x09, 0x4c, 0x69,
|
||||
0x73, 0x74, 0x50, 0x65, 0x65, 0x72, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a,
|
||||
0x1c, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76,
|
||||
0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x22, 0x20, 0x82,
|
||||
0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x12, 0x18, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c,
|
||||
0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x70, 0x65, 0x65, 0x72, 0x73, 0x12,
|
||||
0x8b, 0x01, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x45, 0x54, 0x48, 0x31, 0x43, 0x6f, 0x6e, 0x6e, 0x65,
|
||||
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f,
|
||||
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d,
|
||||
0x70, 0x74, 0x79, 0x1a, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x45, 0x54, 0x48, 0x31,
|
||||
0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
|
||||
0x22, 0x2b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x25, 0x12, 0x23, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76,
|
||||
0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x65, 0x74, 0x68,
|
||||
0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x94, 0x01,
|
||||
0x0a, 0x19, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65,
|
||||
0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x09, 0x4e, 0x6f, 0x64,
|
||||
0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
|
||||
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63, 0x6c, 0x61,
|
||||
0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||
0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e,
|
||||
0x45, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x15, 0x45,
|
||||
0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x31, 0x61, 0x6c,
|
||||
0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c,
|
||||
0x12, 0x1a, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f,
|
||||
0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x6c, 0x0a, 0x09,
|
||||
0x47, 0x65, 0x74, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x24, 0x2e, 0x65, 0x74, 0x68, 0x65,
|
||||
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61,
|
||||
0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||
0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x21, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x12,
|
||||
0x19, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e,
|
||||
0x6f, 0x64, 0x65, 0x2f, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x82, 0x01, 0x0a, 0x17, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x65, 0x64, 0x53, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x2a,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31,
|
||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74,
|
||||
0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93,
|
||||
0x02, 0x1d, 0x12, 0x1b, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61,
|
||||
0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12,
|
||||
0x62, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70,
|
||||
0x74, 0x79, 0x1a, 0x1f, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74,
|
||||
0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x44,
|
||||
0x61, 0x74, 0x61, 0x22, 0x1e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x12, 0x16, 0x2f, 0x65, 0x74,
|
||||
0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f,
|
||||
0x70, 0x32, 0x70, 0x12, 0x6b, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x50, 0x65, 0x65, 0x72, 0x12, 0x22,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31,
|
||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74,
|
||||
0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x22,
|
||||
0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x12, 0x17, 0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31,
|
||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x70, 0x65, 0x65, 0x72,
|
||||
0x12, 0x63, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x65, 0x72, 0x73, 0x12, 0x16, 0x2e,
|
||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
||||
0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1c, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x65,
|
||||
0x65, 0x72, 0x73, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x12, 0x18, 0x2f, 0x65, 0x74,
|
||||
0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f,
|
||||
0x70, 0x65, 0x65, 0x72, 0x73, 0x12, 0x8b, 0x01, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x45, 0x54, 0x48,
|
||||
0x31, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75,
|
||||
0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x2b, 0x2e, 0x65, 0x74, 0x68, 0x65,
|
||||
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61,
|
||||
0x31, 0x2e, 0x45, 0x54, 0x48, 0x31, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x2b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x25, 0x12, 0x23,
|
||||
0x2f, 0x65, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6e, 0x6f,
|
||||
0x64, 0x65, 0x2f, 0x65, 0x74, 0x68, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x42, 0x94, 0x01, 0x0a, 0x19, 0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65,
|
||||
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61,
|
||||
0x31, 0x42, 0x09, 0x4e, 0x6f, 0x64, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a,
|
||||
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d,
|
||||
0x61, 0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76,
|
||||
0x35, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31,
|
||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x15, 0x45, 0x74, 0x68,
|
||||
0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68,
|
||||
0x61, 0x31, 0xca, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74,
|
||||
0x68, 0x5c, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -815,45 +873,48 @@ func file_proto_prysm_v1alpha1_node_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_proto_prysm_v1alpha1_node_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_proto_prysm_v1alpha1_node_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||
var file_proto_prysm_v1alpha1_node_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
||||
var file_proto_prysm_v1alpha1_node_proto_goTypes = []interface{}{
|
||||
(PeerDirection)(0), // 0: ethereum.eth.v1alpha1.PeerDirection
|
||||
(ConnectionState)(0), // 1: ethereum.eth.v1alpha1.ConnectionState
|
||||
(*SyncStatus)(nil), // 2: ethereum.eth.v1alpha1.SyncStatus
|
||||
(*Genesis)(nil), // 3: ethereum.eth.v1alpha1.Genesis
|
||||
(*Version)(nil), // 4: ethereum.eth.v1alpha1.Version
|
||||
(*ImplementedServices)(nil), // 5: ethereum.eth.v1alpha1.ImplementedServices
|
||||
(*PeerRequest)(nil), // 6: ethereum.eth.v1alpha1.PeerRequest
|
||||
(*Peers)(nil), // 7: ethereum.eth.v1alpha1.Peers
|
||||
(*Peer)(nil), // 8: ethereum.eth.v1alpha1.Peer
|
||||
(*HostData)(nil), // 9: ethereum.eth.v1alpha1.HostData
|
||||
(*ETH1ConnectionStatus)(nil), // 10: ethereum.eth.v1alpha1.ETH1ConnectionStatus
|
||||
(*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp
|
||||
(*emptypb.Empty)(nil), // 12: google.protobuf.Empty
|
||||
(*HealthRequest)(nil), // 2: ethereum.eth.v1alpha1.HealthRequest
|
||||
(*SyncStatus)(nil), // 3: ethereum.eth.v1alpha1.SyncStatus
|
||||
(*Genesis)(nil), // 4: ethereum.eth.v1alpha1.Genesis
|
||||
(*Version)(nil), // 5: ethereum.eth.v1alpha1.Version
|
||||
(*ImplementedServices)(nil), // 6: ethereum.eth.v1alpha1.ImplementedServices
|
||||
(*PeerRequest)(nil), // 7: ethereum.eth.v1alpha1.PeerRequest
|
||||
(*Peers)(nil), // 8: ethereum.eth.v1alpha1.Peers
|
||||
(*Peer)(nil), // 9: ethereum.eth.v1alpha1.Peer
|
||||
(*HostData)(nil), // 10: ethereum.eth.v1alpha1.HostData
|
||||
(*ETH1ConnectionStatus)(nil), // 11: ethereum.eth.v1alpha1.ETH1ConnectionStatus
|
||||
(*timestamppb.Timestamp)(nil), // 12: google.protobuf.Timestamp
|
||||
(*emptypb.Empty)(nil), // 13: google.protobuf.Empty
|
||||
}
|
||||
var file_proto_prysm_v1alpha1_node_proto_depIdxs = []int32{
|
||||
11, // 0: ethereum.eth.v1alpha1.Genesis.genesis_time:type_name -> google.protobuf.Timestamp
|
||||
8, // 1: ethereum.eth.v1alpha1.Peers.peers:type_name -> ethereum.eth.v1alpha1.Peer
|
||||
12, // 0: ethereum.eth.v1alpha1.Genesis.genesis_time:type_name -> google.protobuf.Timestamp
|
||||
9, // 1: ethereum.eth.v1alpha1.Peers.peers:type_name -> ethereum.eth.v1alpha1.Peer
|
||||
0, // 2: ethereum.eth.v1alpha1.Peer.direction:type_name -> ethereum.eth.v1alpha1.PeerDirection
|
||||
1, // 3: ethereum.eth.v1alpha1.Peer.connection_state:type_name -> ethereum.eth.v1alpha1.ConnectionState
|
||||
12, // 4: ethereum.eth.v1alpha1.Node.GetSyncStatus:input_type -> google.protobuf.Empty
|
||||
12, // 5: ethereum.eth.v1alpha1.Node.GetGenesis:input_type -> google.protobuf.Empty
|
||||
12, // 6: ethereum.eth.v1alpha1.Node.GetVersion:input_type -> google.protobuf.Empty
|
||||
12, // 7: ethereum.eth.v1alpha1.Node.ListImplementedServices:input_type -> google.protobuf.Empty
|
||||
12, // 8: ethereum.eth.v1alpha1.Node.GetHost:input_type -> google.protobuf.Empty
|
||||
6, // 9: ethereum.eth.v1alpha1.Node.GetPeer:input_type -> ethereum.eth.v1alpha1.PeerRequest
|
||||
12, // 10: ethereum.eth.v1alpha1.Node.ListPeers:input_type -> google.protobuf.Empty
|
||||
12, // 11: ethereum.eth.v1alpha1.Node.GetETH1ConnectionStatus:input_type -> google.protobuf.Empty
|
||||
2, // 12: ethereum.eth.v1alpha1.Node.GetSyncStatus:output_type -> ethereum.eth.v1alpha1.SyncStatus
|
||||
3, // 13: ethereum.eth.v1alpha1.Node.GetGenesis:output_type -> ethereum.eth.v1alpha1.Genesis
|
||||
4, // 14: ethereum.eth.v1alpha1.Node.GetVersion:output_type -> ethereum.eth.v1alpha1.Version
|
||||
5, // 15: ethereum.eth.v1alpha1.Node.ListImplementedServices:output_type -> ethereum.eth.v1alpha1.ImplementedServices
|
||||
9, // 16: ethereum.eth.v1alpha1.Node.GetHost:output_type -> ethereum.eth.v1alpha1.HostData
|
||||
8, // 17: ethereum.eth.v1alpha1.Node.GetPeer:output_type -> ethereum.eth.v1alpha1.Peer
|
||||
7, // 18: ethereum.eth.v1alpha1.Node.ListPeers:output_type -> ethereum.eth.v1alpha1.Peers
|
||||
10, // 19: ethereum.eth.v1alpha1.Node.GetETH1ConnectionStatus:output_type -> ethereum.eth.v1alpha1.ETH1ConnectionStatus
|
||||
12, // [12:20] is the sub-list for method output_type
|
||||
4, // [4:12] is the sub-list for method input_type
|
||||
13, // 4: ethereum.eth.v1alpha1.Node.GetSyncStatus:input_type -> google.protobuf.Empty
|
||||
13, // 5: ethereum.eth.v1alpha1.Node.GetGenesis:input_type -> google.protobuf.Empty
|
||||
13, // 6: ethereum.eth.v1alpha1.Node.GetVersion:input_type -> google.protobuf.Empty
|
||||
2, // 7: ethereum.eth.v1alpha1.Node.GetHealth:input_type -> ethereum.eth.v1alpha1.HealthRequest
|
||||
13, // 8: ethereum.eth.v1alpha1.Node.ListImplementedServices:input_type -> google.protobuf.Empty
|
||||
13, // 9: ethereum.eth.v1alpha1.Node.GetHost:input_type -> google.protobuf.Empty
|
||||
7, // 10: ethereum.eth.v1alpha1.Node.GetPeer:input_type -> ethereum.eth.v1alpha1.PeerRequest
|
||||
13, // 11: ethereum.eth.v1alpha1.Node.ListPeers:input_type -> google.protobuf.Empty
|
||||
13, // 12: ethereum.eth.v1alpha1.Node.GetETH1ConnectionStatus:input_type -> google.protobuf.Empty
|
||||
3, // 13: ethereum.eth.v1alpha1.Node.GetSyncStatus:output_type -> ethereum.eth.v1alpha1.SyncStatus
|
||||
4, // 14: ethereum.eth.v1alpha1.Node.GetGenesis:output_type -> ethereum.eth.v1alpha1.Genesis
|
||||
5, // 15: ethereum.eth.v1alpha1.Node.GetVersion:output_type -> ethereum.eth.v1alpha1.Version
|
||||
13, // 16: ethereum.eth.v1alpha1.Node.GetHealth:output_type -> google.protobuf.Empty
|
||||
6, // 17: ethereum.eth.v1alpha1.Node.ListImplementedServices:output_type -> ethereum.eth.v1alpha1.ImplementedServices
|
||||
10, // 18: ethereum.eth.v1alpha1.Node.GetHost:output_type -> ethereum.eth.v1alpha1.HostData
|
||||
9, // 19: ethereum.eth.v1alpha1.Node.GetPeer:output_type -> ethereum.eth.v1alpha1.Peer
|
||||
8, // 20: ethereum.eth.v1alpha1.Node.ListPeers:output_type -> ethereum.eth.v1alpha1.Peers
|
||||
11, // 21: ethereum.eth.v1alpha1.Node.GetETH1ConnectionStatus:output_type -> ethereum.eth.v1alpha1.ETH1ConnectionStatus
|
||||
13, // [13:22] is the sub-list for method output_type
|
||||
4, // [4:13] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
@@ -866,7 +927,7 @@ func file_proto_prysm_v1alpha1_node_proto_init() {
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_proto_prysm_v1alpha1_node_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SyncStatus); i {
|
||||
switch v := v.(*HealthRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@@ -878,7 +939,7 @@ func file_proto_prysm_v1alpha1_node_proto_init() {
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_node_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Genesis); i {
|
||||
switch v := v.(*SyncStatus); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@@ -890,7 +951,7 @@ func file_proto_prysm_v1alpha1_node_proto_init() {
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_node_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Version); i {
|
||||
switch v := v.(*Genesis); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@@ -902,7 +963,7 @@ func file_proto_prysm_v1alpha1_node_proto_init() {
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_node_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ImplementedServices); i {
|
||||
switch v := v.(*Version); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@@ -914,7 +975,7 @@ func file_proto_prysm_v1alpha1_node_proto_init() {
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_node_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*PeerRequest); i {
|
||||
switch v := v.(*ImplementedServices); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@@ -926,7 +987,7 @@ func file_proto_prysm_v1alpha1_node_proto_init() {
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_node_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Peers); i {
|
||||
switch v := v.(*PeerRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@@ -938,7 +999,7 @@ func file_proto_prysm_v1alpha1_node_proto_init() {
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_node_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Peer); i {
|
||||
switch v := v.(*Peers); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@@ -950,7 +1011,7 @@ func file_proto_prysm_v1alpha1_node_proto_init() {
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_node_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*HostData); i {
|
||||
switch v := v.(*Peer); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@@ -962,6 +1023,18 @@ func file_proto_prysm_v1alpha1_node_proto_init() {
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_node_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*HostData); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_node_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ETH1ConnectionStatus); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@@ -980,7 +1053,7 @@ func file_proto_prysm_v1alpha1_node_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_prysm_v1alpha1_node_proto_rawDesc,
|
||||
NumEnums: 2,
|
||||
NumMessages: 9,
|
||||
NumMessages: 10,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
@@ -1010,6 +1083,7 @@ type NodeClient interface {
|
||||
GetSyncStatus(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*SyncStatus, error)
|
||||
GetGenesis(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Genesis, error)
|
||||
GetVersion(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Version, error)
|
||||
GetHealth(ctx context.Context, in *HealthRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
ListImplementedServices(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ImplementedServices, error)
|
||||
GetHost(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*HostData, error)
|
||||
GetPeer(ctx context.Context, in *PeerRequest, opts ...grpc.CallOption) (*Peer, error)
|
||||
@@ -1052,6 +1126,15 @@ func (c *nodeClient) GetVersion(ctx context.Context, in *emptypb.Empty, opts ...
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *nodeClient) GetHealth(ctx context.Context, in *HealthRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, "/ethereum.eth.v1alpha1.Node/GetHealth", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *nodeClient) ListImplementedServices(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ImplementedServices, error) {
|
||||
out := new(ImplementedServices)
|
||||
err := c.cc.Invoke(ctx, "/ethereum.eth.v1alpha1.Node/ListImplementedServices", in, out, opts...)
|
||||
@@ -1102,6 +1185,7 @@ type NodeServer interface {
|
||||
GetSyncStatus(context.Context, *emptypb.Empty) (*SyncStatus, error)
|
||||
GetGenesis(context.Context, *emptypb.Empty) (*Genesis, error)
|
||||
GetVersion(context.Context, *emptypb.Empty) (*Version, error)
|
||||
GetHealth(context.Context, *HealthRequest) (*emptypb.Empty, error)
|
||||
ListImplementedServices(context.Context, *emptypb.Empty) (*ImplementedServices, error)
|
||||
GetHost(context.Context, *emptypb.Empty) (*HostData, error)
|
||||
GetPeer(context.Context, *PeerRequest) (*Peer, error)
|
||||
@@ -1122,6 +1206,9 @@ func (*UnimplementedNodeServer) GetGenesis(context.Context, *emptypb.Empty) (*Ge
|
||||
func (*UnimplementedNodeServer) GetVersion(context.Context, *emptypb.Empty) (*Version, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetVersion not implemented")
|
||||
}
|
||||
func (*UnimplementedNodeServer) GetHealth(context.Context, *HealthRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetHealth not implemented")
|
||||
}
|
||||
func (*UnimplementedNodeServer) ListImplementedServices(context.Context, *emptypb.Empty) (*ImplementedServices, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ListImplementedServices not implemented")
|
||||
}
|
||||
@@ -1196,6 +1283,24 @@ func _Node_GetVersion_Handler(srv interface{}, ctx context.Context, dec func(int
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Node_GetHealth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(HealthRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(NodeServer).GetHealth(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/ethereum.eth.v1alpha1.Node/GetHealth",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NodeServer).GetHealth(ctx, req.(*HealthRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Node_ListImplementedServices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(emptypb.Empty)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -1302,6 +1407,10 @@ var _Node_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetVersion",
|
||||
Handler: _Node_GetVersion_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetHealth",
|
||||
Handler: _Node_GetHealth_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListImplementedServices",
|
||||
Handler: _Node_ListImplementedServices_Handler,
|
||||
|
||||
@@ -89,6 +89,42 @@ func local_request_Node_GetVersion_0(ctx context.Context, marshaler runtime.Mars
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Node_GetHealth_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Node_GetHealth_0(ctx context.Context, marshaler runtime.Marshaler, client NodeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq HealthRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Node_GetHealth_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.GetHealth(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Node_GetHealth_0(ctx context.Context, marshaler runtime.Marshaler, server NodeServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq HealthRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Node_GetHealth_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.GetHealth(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Node_ListImplementedServices_0(ctx context.Context, marshaler runtime.Marshaler, client NodeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq emptypb.Empty
|
||||
var metadata runtime.ServerMetadata
|
||||
@@ -272,6 +308,29 @@ func RegisterNodeHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Node_GetHealth_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/ethereum.eth.v1alpha1.Node/GetHealth")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Node_GetHealth_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Node_GetHealth_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Node_ListImplementedServices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -488,6 +547,26 @@ func RegisterNodeHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Node_GetHealth_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/ethereum.eth.v1alpha1.Node/GetHealth")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Node_GetHealth_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Node_GetHealth_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Node_ListImplementedServices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -598,6 +677,8 @@ var (
|
||||
|
||||
pattern_Node_GetVersion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"eth", "v1alpha1", "node", "version"}, ""))
|
||||
|
||||
pattern_Node_GetHealth_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"eth", "v1alpha1", "node", "health"}, ""))
|
||||
|
||||
pattern_Node_ListImplementedServices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"eth", "v1alpha1", "node", "services"}, ""))
|
||||
|
||||
pattern_Node_GetHost_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"eth", "v1alpha1", "node", "p2p"}, ""))
|
||||
@@ -616,6 +697,8 @@ var (
|
||||
|
||||
forward_Node_GetVersion_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Node_GetHealth_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Node_ListImplementedServices_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Node_GetHost_0 = runtime.ForwardResponseMessage
|
||||
|
||||
@@ -54,6 +54,13 @@ service Node {
|
||||
};
|
||||
}
|
||||
|
||||
// Retrieve the current health of the node.
|
||||
rpc GetHealth(HealthRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
get: "/eth/v1alpha1/node/health"
|
||||
};
|
||||
}
|
||||
|
||||
// Retrieve the list of services implemented and enabled by this node.
|
||||
//
|
||||
// Any service not present in this list may return UNIMPLEMENTED or
|
||||
@@ -94,6 +101,10 @@ service Node {
|
||||
}
|
||||
}
|
||||
|
||||
message HealthRequest {
|
||||
uint64 syncing_status = 1;
|
||||
}
|
||||
|
||||
// Information about the current network sync status of the node.
|
||||
message SyncStatus {
|
||||
// Whether or not the node is currently syncing.
|
||||
|
||||
2
proto/testing/test.pb.go
generated
2
proto/testing/test.pb.go
generated
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc v4.23.3
|
||||
// protoc v4.25.1
|
||||
// source: proto/testing/test.proto
|
||||
|
||||
package testing
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
@@ -13,6 +13,8 @@ go_library(
|
||||
importpath = "github.com/prysmaticlabs/prysm/v5/testing/validator-mock",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//api/client/beacon:go_default_library",
|
||||
"//api/client/event:go_default_library",
|
||||
"//consensus-types/validator:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//validator/client/iface:go_default_library",
|
||||
|
||||
7
testing/validator-mock/node_client_mock.go
generated
7
testing/validator-mock/node_client_mock.go
generated
@@ -13,6 +13,7 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v5/api/client/beacon"
|
||||
eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
@@ -22,6 +23,7 @@ import (
|
||||
type MockNodeClient struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockNodeClientMockRecorder
|
||||
healthTracker *beacon.NodeHealthTracker
|
||||
}
|
||||
|
||||
// MockNodeClientMockRecorder is the mock recorder for MockNodeClient.
|
||||
@@ -33,6 +35,7 @@ type MockNodeClientMockRecorder struct {
|
||||
func NewMockNodeClient(ctrl *gomock.Controller) *MockNodeClient {
|
||||
mock := &MockNodeClient{ctrl: ctrl}
|
||||
mock.recorder = &MockNodeClientMockRecorder{mock}
|
||||
mock.healthTracker = beacon.NewNodeHealthTracker(mock)
|
||||
return mock
|
||||
}
|
||||
|
||||
@@ -114,3 +117,7 @@ func (mr *MockNodeClientMockRecorder) ListPeers(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPeers", reflect.TypeOf((*MockNodeClient)(nil).ListPeers), arg0, arg1)
|
||||
}
|
||||
|
||||
func (m *MockNodeClient) HealthTracker() *beacon.NodeHealthTracker {
|
||||
return m.healthTracker
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user