mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-02-02 09:05:08 -05:00
Compare commits
2 Commits
graffiti-i
...
go-fmt
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bc715914e | ||
|
|
390acc4f30 |
@@ -67,7 +67,6 @@ func getSubscriptionStatusFromDB(t *testing.T, db *Store) bool {
|
||||
return subscribed
|
||||
}
|
||||
|
||||
|
||||
func TestUpdateCustodyInfo(t *testing.T) {
|
||||
ctx := t.Context()
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ go_library(
|
||||
"deposit.go",
|
||||
"engine_client.go",
|
||||
"errors.go",
|
||||
"graffiti_info.go",
|
||||
"log.go",
|
||||
"log_processing.go",
|
||||
"metrics.go",
|
||||
@@ -90,7 +89,6 @@ go_test(
|
||||
"engine_client_fuzz_test.go",
|
||||
"engine_client_test.go",
|
||||
"execution_chain_test.go",
|
||||
"graffiti_info_test.go",
|
||||
"init_test.go",
|
||||
"log_processing_test.go",
|
||||
"mock_test.go",
|
||||
|
||||
@@ -61,17 +61,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
// ClientVersionV1 represents the response from engine_getClientVersionV1.
|
||||
type ClientVersionV1 struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Commit string `json:"commit"`
|
||||
}
|
||||
|
||||
const (
|
||||
// GetClientVersionMethod is the engine_getClientVersionV1 method for JSON-RPC.
|
||||
GetClientVersionMethod = "engine_getClientVersionV1"
|
||||
// NewPayloadMethod v1 request string for JSON-RPC.
|
||||
NewPayloadMethod = "engine_newPayloadV1"
|
||||
// NewPayloadMethodV2 v2 request string for JSON-RPC.
|
||||
@@ -360,27 +350,6 @@ func (s *Service) ExchangeCapabilities(ctx context.Context) ([]string, error) {
|
||||
return elSupportedEndpointsSlice, nil
|
||||
}
|
||||
|
||||
// GetClientVersion calls engine_getClientVersionV1 to retrieve EL client information.
|
||||
func (s *Service) GetClientVersion(ctx context.Context) ([]ClientVersionV1, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "powchain.engine-api-client.GetClientVersion")
|
||||
defer span.End()
|
||||
|
||||
// Per spec, we send our own client info as the parameter
|
||||
clVersion := ClientVersionV1{
|
||||
Code: CLCode,
|
||||
Name: "Prysm",
|
||||
Version: version.SemanticVersion(),
|
||||
Commit: version.GetCommitPrefix(),
|
||||
}
|
||||
|
||||
var result []ClientVersionV1
|
||||
err := s.rpcClient.CallContext(ctx, &result, GetClientVersionMethod, clVersion)
|
||||
if err != nil {
|
||||
return nil, handleRPCError(err)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetTerminalBlockHash returns the valid terminal block hash based on total difficulty.
|
||||
//
|
||||
// Spec code:
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
package execution
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v7/runtime/version"
|
||||
)
|
||||
|
||||
const (
|
||||
// CLCode is the two-letter client code for Prysm.
|
||||
CLCode = "PR"
|
||||
)
|
||||
|
||||
// GraffitiInfo holds version information for generating block graffiti.
|
||||
// It is thread-safe and can be updated by the execution service and read by the validator server.
|
||||
type GraffitiInfo struct {
|
||||
mu sync.RWMutex
|
||||
elCode string // From engine_getClientVersionV1
|
||||
elCommit string // From engine_getClientVersionV1
|
||||
logOnce sync.Once
|
||||
}
|
||||
|
||||
// NewGraffitiInfo creates a new GraffitiInfo.
|
||||
func NewGraffitiInfo() *GraffitiInfo {
|
||||
return &GraffitiInfo{}
|
||||
}
|
||||
|
||||
// UpdateFromEngine updates the EL client information.
|
||||
func (g *GraffitiInfo) UpdateFromEngine(code, commit string) {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
g.elCode = code
|
||||
g.elCommit = commit
|
||||
}
|
||||
|
||||
// GenerateGraffiti generates graffiti using the flexible standard
|
||||
// with the provided user graffiti from the validator client request.
|
||||
// It packs as much client info as space allows, followed by user graffiti (no space separator).
|
||||
//
|
||||
// Available Space | Format
|
||||
// ≥12 bytes | EL(2)+commit(4)+CL(2)+commit(4)+user e.g. "GEabcdPRxxxxSushi"
|
||||
// 8-11 bytes | EL(2)+commit(2)+CL(2)+commit(2)+user e.g. "GEabPRxxSushi"
|
||||
// 4-7 bytes | EL(2)+CL(2)+user e.g. "GEPRSushi"
|
||||
// 2-3 bytes | code(2)+user e.g. "GESushi" or "PRSushi"
|
||||
// <2 bytes | user only e.g. "Sushi"
|
||||
func (g *GraffitiInfo) GenerateGraffiti(userGraffiti []byte) [32]byte {
|
||||
g.mu.RLock()
|
||||
defer g.mu.RUnlock()
|
||||
|
||||
var result [32]byte
|
||||
userStr := string(userGraffiti)
|
||||
// Trim trailing null bytes
|
||||
for len(userStr) > 0 && userStr[len(userStr)-1] == 0 {
|
||||
userStr = userStr[:len(userStr)-1]
|
||||
}
|
||||
|
||||
available := 32 - len(userStr)
|
||||
|
||||
g.logOnce.Do(func() {
|
||||
logGraffitiInfo(userStr, available)
|
||||
})
|
||||
|
||||
clCommit := version.GetCommitPrefix()
|
||||
clCommit4 := truncateCommit(clCommit, 4)
|
||||
clCommit2 := truncateCommit(clCommit, 2)
|
||||
|
||||
// If no EL info, clear EL commits but still include CL info
|
||||
var elCommit4, elCommit2 string
|
||||
if g.elCode != "" {
|
||||
elCommit4 = truncateCommit(g.elCommit, 4)
|
||||
elCommit2 = truncateCommit(g.elCommit, 2)
|
||||
}
|
||||
|
||||
var graffiti string
|
||||
switch {
|
||||
case available >= 12:
|
||||
// Full: EL(2)+commit(4)+CL(2)+commit(4)+user
|
||||
graffiti = g.elCode + elCommit4 + CLCode + clCommit4 + userStr
|
||||
case available >= 8:
|
||||
// Reduced commits: EL(2)+commit(2)+CL(2)+commit(2)+user
|
||||
graffiti = g.elCode + elCommit2 + CLCode + clCommit2 + userStr
|
||||
case available >= 4:
|
||||
// Codes only: EL(2)+CL(2)+user
|
||||
graffiti = g.elCode + CLCode + userStr
|
||||
case available >= 2:
|
||||
// EL code only (or CL code if no EL): code(2)+user
|
||||
if g.elCode != "" {
|
||||
graffiti = g.elCode + userStr
|
||||
} else {
|
||||
graffiti = CLCode + userStr
|
||||
}
|
||||
default:
|
||||
// User graffiti only
|
||||
graffiti = userStr
|
||||
}
|
||||
|
||||
copy(result[:], graffiti)
|
||||
return result
|
||||
}
|
||||
|
||||
// logGraffitiInfo logs the graffiti format that will be used based on available space.
|
||||
func logGraffitiInfo(userStr string, available int) {
|
||||
userLen := len(userStr)
|
||||
fields := log.WithField("userGraffiti", userStr).WithField("userGraffitiLength", userLen)
|
||||
|
||||
switch {
|
||||
case available >= 12:
|
||||
fields.Info("Graffiti: full client version format (EL code + 4-char commit + CL code + 4-char commit)")
|
||||
case available >= 8:
|
||||
fields.Warn("Graffiti: user graffiti reduces client version to 2-char commits")
|
||||
case available >= 4:
|
||||
fields.Warn("Graffiti: user graffiti reduces client version to codes only (no commits)")
|
||||
case available >= 2:
|
||||
fields.Warn("Graffiti: user graffiti reduces client version to single code only")
|
||||
default:
|
||||
fields.Warn("Graffiti: user graffiti consumes all 32 bytes, no client version info will be included")
|
||||
}
|
||||
}
|
||||
|
||||
// truncateCommit returns the first n characters of the commit string.
|
||||
func truncateCommit(commit string, n int) string {
|
||||
if len(commit) <= n {
|
||||
return commit
|
||||
}
|
||||
return commit[:n]
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
package execution
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v7/testing/require"
|
||||
)
|
||||
|
||||
func TestGraffitiInfo_GenerateGraffiti(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
elCode string
|
||||
elCommit string
|
||||
userGraffiti []byte
|
||||
wantPrefix string
|
||||
wantSuffix string // for checking user graffiti is appended
|
||||
}{
|
||||
// No EL info cases (CL info "PR" + commit still included when space allows)
|
||||
{
|
||||
name: "No EL - empty user graffiti",
|
||||
elCode: "",
|
||||
elCommit: "",
|
||||
userGraffiti: []byte{},
|
||||
wantPrefix: "PR", // CL code + commit
|
||||
},
|
||||
{
|
||||
name: "No EL - short user graffiti",
|
||||
elCode: "",
|
||||
elCommit: "",
|
||||
userGraffiti: []byte("my validator"),
|
||||
wantPrefix: "PR", // CL code + commit + user
|
||||
wantSuffix: "my validator",
|
||||
},
|
||||
{
|
||||
name: "No EL - 28 char user graffiti (4 bytes available)",
|
||||
elCode: "",
|
||||
elCommit: "",
|
||||
userGraffiti: []byte("1234567890123456789012345678"), // 28 chars, 4 bytes available = codes only
|
||||
wantPrefix: "PR", // CL code (no EL, so just PR)
|
||||
},
|
||||
{
|
||||
name: "No EL - 30 char user graffiti (2 bytes available)",
|
||||
elCode: "",
|
||||
elCommit: "",
|
||||
userGraffiti: []byte("123456789012345678901234567890"), // 30 chars, 2 bytes available = fits PR
|
||||
wantPrefix: "PR", // CL code (2 bytes) fits exactly
|
||||
},
|
||||
{
|
||||
name: "No EL - 31 char user graffiti (1 byte available)",
|
||||
elCode: "",
|
||||
elCommit: "",
|
||||
userGraffiti: []byte("1234567890123456789012345678901"), // 31 chars, 1 byte available = not enough for code
|
||||
wantPrefix: "1234567890123456789012345678901", // User only
|
||||
},
|
||||
{
|
||||
name: "No EL - 32 char user graffiti (0 bytes available)",
|
||||
elCode: "",
|
||||
elCommit: "",
|
||||
userGraffiti: []byte("12345678901234567890123456789012"),
|
||||
wantPrefix: "12345678901234567890123456789012", // User only
|
||||
},
|
||||
// With EL info - flexible standard format cases
|
||||
{
|
||||
name: "With EL - full format (empty user graffiti)",
|
||||
elCode: "GE",
|
||||
elCommit: "abcd1234",
|
||||
userGraffiti: []byte{},
|
||||
wantPrefix: "GEabcdPR", // EL(2)+commit(4)+CL(2)+commit(4)
|
||||
},
|
||||
{
|
||||
name: "With EL - full format (short user graffiti)",
|
||||
elCode: "GE",
|
||||
elCommit: "abcd1234",
|
||||
userGraffiti: []byte("Bob"),
|
||||
wantPrefix: "GEabcdPR", // EL(2)+commit(4)+CL(2)+commit(4)
|
||||
wantSuffix: "Bob", // no space before user graffiti
|
||||
},
|
||||
{
|
||||
name: "With EL - full format (20 char user, 12 bytes available)",
|
||||
elCode: "GE",
|
||||
elCommit: "abcd1234",
|
||||
userGraffiti: []byte("12345678901234567890"), // 20 chars, leaves 12 bytes = full format
|
||||
wantPrefix: "GEabcdPR", // Full format fits (12 bytes)
|
||||
},
|
||||
{
|
||||
name: "With EL - reduced commits (24 char user, 8 bytes available)",
|
||||
elCode: "GE",
|
||||
elCommit: "abcd1234",
|
||||
userGraffiti: []byte("123456789012345678901234"), // 24 chars, leaves 8 bytes = reduced format
|
||||
wantPrefix: "GEabPR", // Reduced format (8 bytes)
|
||||
},
|
||||
{
|
||||
name: "With EL - codes only (28 char user, 4 bytes available)",
|
||||
elCode: "GE",
|
||||
elCommit: "abcd1234",
|
||||
userGraffiti: []byte("1234567890123456789012345678"), // 28 chars, leaves 4 bytes = codes only
|
||||
wantPrefix: "GEPR", // Codes only (4 bytes)
|
||||
},
|
||||
{
|
||||
name: "With EL - EL code only (30 char user, 2 bytes available)",
|
||||
elCode: "GE",
|
||||
elCommit: "abcd1234",
|
||||
userGraffiti: []byte("123456789012345678901234567890"), // 30 chars, leaves 2 bytes = EL code only
|
||||
wantPrefix: "GE", // EL code (2 bytes)
|
||||
},
|
||||
{
|
||||
name: "With EL - user only (31 char user, 1 byte available)",
|
||||
elCode: "GE",
|
||||
elCommit: "abcd1234",
|
||||
userGraffiti: []byte("1234567890123456789012345678901"), // 31 chars, leaves 1 byte = not enough for code
|
||||
wantPrefix: "1234567890123456789012345678901", // User only
|
||||
},
|
||||
{
|
||||
name: "With EL - user only (32 char user, 0 bytes available)",
|
||||
elCode: "GE",
|
||||
elCommit: "abcd1234",
|
||||
userGraffiti: []byte("12345678901234567890123456789012"),
|
||||
wantPrefix: "12345678901234567890123456789012",
|
||||
},
|
||||
// Null byte handling
|
||||
{
|
||||
name: "Null bytes - input with trailing nulls",
|
||||
elCode: "GE",
|
||||
elCommit: "abcd1234",
|
||||
userGraffiti: append([]byte("test"), 0, 0, 0),
|
||||
wantPrefix: "GEabcdPR",
|
||||
wantSuffix: "test",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
g := NewGraffitiInfo()
|
||||
if tt.elCode != "" {
|
||||
g.UpdateFromEngine(tt.elCode, tt.elCommit)
|
||||
}
|
||||
|
||||
result := g.GenerateGraffiti(tt.userGraffiti)
|
||||
resultStr := string(result[:])
|
||||
|
||||
// Check prefix
|
||||
require.Equal(t, true, len(resultStr) >= len(tt.wantPrefix), "Result too short for prefix check")
|
||||
require.Equal(t, tt.wantPrefix, resultStr[:len(tt.wantPrefix)], "Prefix mismatch")
|
||||
|
||||
// Check suffix if specified
|
||||
if tt.wantSuffix != "" {
|
||||
trimmed := trimNullBytes(resultStr)
|
||||
require.Equal(t, true, len(trimmed) >= len(tt.wantSuffix), "Result too short for suffix check")
|
||||
require.Equal(t, tt.wantSuffix, trimmed[len(trimmed)-len(tt.wantSuffix):], "Suffix mismatch")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGraffitiInfo_UpdateFromEngine(t *testing.T) {
|
||||
g := NewGraffitiInfo()
|
||||
|
||||
// Initially no EL info - should still have CL info (PR + commit)
|
||||
result := g.GenerateGraffiti([]byte{})
|
||||
resultStr := string(result[:])
|
||||
require.Equal(t, "PR", resultStr[:2], "Expected CL info before update")
|
||||
|
||||
// Update with EL info
|
||||
g.UpdateFromEngine("GE", "1234abcd")
|
||||
|
||||
result = g.GenerateGraffiti([]byte{})
|
||||
resultStr = string(result[:])
|
||||
require.Equal(t, "GE1234PR", resultStr[:8], "Expected EL+CL info after update")
|
||||
}
|
||||
|
||||
func TestTruncateCommit(t *testing.T) {
|
||||
tests := []struct {
|
||||
commit string
|
||||
n int
|
||||
want string
|
||||
}{
|
||||
{"abcd1234", 4, "abcd"},
|
||||
{"ab", 4, "ab"},
|
||||
{"", 4, ""},
|
||||
{"abcdef", 2, "ab"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
got := truncateCommit(tt.commit, tt.n)
|
||||
require.Equal(t, tt.want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func trimNullBytes(s string) string {
|
||||
for len(s) > 0 && s[len(s)-1] == 0 {
|
||||
s = s[:len(s)-1]
|
||||
}
|
||||
return s
|
||||
}
|
||||
@@ -124,11 +124,3 @@ func WithVerifierWaiter(v *verification.InitializerWaiter) Option {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithGraffitiInfo sets the GraffitiInfo for client version tracking.
|
||||
func WithGraffitiInfo(g *GraffitiInfo) Option {
|
||||
return func(s *Service) error {
|
||||
s.graffitiInfo = g
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,6 @@ type Service struct {
|
||||
verifierWaiter *verification.InitializerWaiter
|
||||
blobVerifier verification.NewBlobVerifier
|
||||
capabilityCache *capabilityCache
|
||||
graffitiInfo *GraffitiInfo
|
||||
}
|
||||
|
||||
// NewService sets up a new instance with an ethclient when given a web3 endpoint as a string in the config.
|
||||
@@ -319,28 +318,6 @@ func (s *Service) updateConnectedETH1(state bool) {
|
||||
s.updateBeaconNodeStats()
|
||||
}
|
||||
|
||||
// GraffitiInfo returns the GraffitiInfo struct for graffiti generation.
|
||||
func (s *Service) GraffitiInfo() *GraffitiInfo {
|
||||
return s.graffitiInfo
|
||||
}
|
||||
|
||||
// updateGraffitiInfo fetches EL client version and updates the graffiti info.
|
||||
func (s *Service) updateGraffitiInfo() {
|
||||
if s.graffitiInfo == nil {
|
||||
return
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(s.ctx, time.Second)
|
||||
defer cancel()
|
||||
versions, err := s.GetClientVersion(ctx)
|
||||
if err != nil {
|
||||
log.WithError(err).Debug("Could not get execution client version for graffiti")
|
||||
return
|
||||
}
|
||||
if len(versions) >= 1 {
|
||||
s.graffitiInfo.UpdateFromEngine(versions[0].Code, versions[0].Commit)
|
||||
}
|
||||
}
|
||||
|
||||
// refers to the latest eth1 block which follows the condition: eth1_timestamp +
|
||||
// SECONDS_PER_ETH1_BLOCK * ETH1_FOLLOW_DISTANCE <= current_unix_time
|
||||
func (s *Service) followedBlockHeight(ctx context.Context) (uint64, error) {
|
||||
@@ -621,12 +598,6 @@ func (s *Service) run(done <-chan struct{}) {
|
||||
chainstartTicker := time.NewTicker(logPeriod)
|
||||
defer chainstartTicker.Stop()
|
||||
|
||||
// Update graffiti info 4 times per epoch (~96 seconds with 12s slots and 32 slots/epoch)
|
||||
graffitiTicker := time.NewTicker(96 * time.Second)
|
||||
defer graffitiTicker.Stop()
|
||||
// Initial update
|
||||
s.updateGraffitiInfo()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-done:
|
||||
@@ -651,8 +622,6 @@ func (s *Service) run(done <-chan struct{}) {
|
||||
continue
|
||||
}
|
||||
s.logTillChainStart(context.Background())
|
||||
case <-graffitiTicker.C:
|
||||
s.updateGraffitiInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,9 +775,6 @@ func (b *BeaconNode) registerPOWChainService() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Create GraffitiInfo for client version tracking in block graffiti
|
||||
graffitiInfo := execution.NewGraffitiInfo()
|
||||
|
||||
// skipcq: CRT-D0001
|
||||
opts := append(
|
||||
b.serviceFlagOpts.executionChainFlagOpts,
|
||||
@@ -790,7 +787,6 @@ func (b *BeaconNode) registerPOWChainService() error {
|
||||
execution.WithFinalizedStateAtStartup(b.finalizedStateAtStartUp),
|
||||
execution.WithJwtId(b.cliCtx.String(flags.JwtId.Name)),
|
||||
execution.WithVerifierWaiter(b.verifyInitWaiter),
|
||||
execution.WithGraffitiInfo(graffitiInfo),
|
||||
)
|
||||
web3Service, err := execution.NewService(b.ctx, opts...)
|
||||
if err != nil {
|
||||
@@ -997,7 +993,6 @@ func (b *BeaconNode) registerRPCService(router *http.ServeMux) error {
|
||||
TrackedValidatorsCache: b.trackedValidatorsCache,
|
||||
PayloadIDCache: b.payloadIDCache,
|
||||
LCStore: b.lcStore,
|
||||
GraffitiInfo: web3Service.GraffitiInfo(),
|
||||
})
|
||||
|
||||
return b.services.RegisterService(rpcService)
|
||||
|
||||
@@ -26,8 +26,8 @@ import (
|
||||
"github.com/OffchainLabs/prysm/v7/beacon-chain/operations/voluntaryexits/mock"
|
||||
p2pMock "github.com/OffchainLabs/prysm/v7/beacon-chain/p2p/testing"
|
||||
"github.com/OffchainLabs/prysm/v7/beacon-chain/rpc/core"
|
||||
mockSync "github.com/OffchainLabs/prysm/v7/beacon-chain/sync/initial-sync/testing"
|
||||
state_native "github.com/OffchainLabs/prysm/v7/beacon-chain/state/state-native"
|
||||
mockSync "github.com/OffchainLabs/prysm/v7/beacon-chain/sync/initial-sync/testing"
|
||||
"github.com/OffchainLabs/prysm/v7/config/params"
|
||||
"github.com/OffchainLabs/prysm/v7/consensus-types/primitives"
|
||||
"github.com/OffchainLabs/prysm/v7/crypto/bls"
|
||||
|
||||
@@ -89,13 +89,7 @@ func (vs *Server) GetBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) (
|
||||
}
|
||||
// Set slot, graffiti, randao reveal, and parent root.
|
||||
sBlk.SetSlot(req.Slot)
|
||||
// Generate graffiti with client version info using flexible standard
|
||||
if vs.GraffitiInfo != nil {
|
||||
graffiti := vs.GraffitiInfo.GenerateGraffiti(req.Graffiti)
|
||||
sBlk.SetGraffiti(graffiti[:])
|
||||
} else {
|
||||
sBlk.SetGraffiti(req.Graffiti)
|
||||
}
|
||||
sBlk.SetGraffiti(req.Graffiti)
|
||||
sBlk.SetRandaoReveal(req.RandaoReveal)
|
||||
sBlk.SetParentRoot(parentRoot[:])
|
||||
|
||||
|
||||
@@ -83,7 +83,6 @@ type Server struct {
|
||||
ClockWaiter startup.ClockWaiter
|
||||
CoreService *core.Service
|
||||
AttestationStateFetcher blockchain.AttestationStateFetcher
|
||||
GraffitiInfo *execution.GraffitiInfo
|
||||
}
|
||||
|
||||
// Deprecated: The gRPC API will remain the default and fully supported through v8 (expected in 2026) but will be eventually removed in favor of REST API.
|
||||
|
||||
@@ -125,7 +125,6 @@ type Config struct {
|
||||
TrackedValidatorsCache *cache.TrackedValidatorsCache
|
||||
PayloadIDCache *cache.PayloadIDCache
|
||||
LCStore *lightClient.Store
|
||||
GraffitiInfo *execution.GraffitiInfo
|
||||
}
|
||||
|
||||
// NewService instantiates a new RPC service instance that will
|
||||
@@ -257,7 +256,6 @@ func NewService(ctx context.Context, cfg *Config) *Service {
|
||||
TrackedValidatorsCache: s.cfg.TrackedValidatorsCache,
|
||||
PayloadIDCache: s.cfg.PayloadIDCache,
|
||||
AttestationStateFetcher: s.cfg.AttestationReceiver,
|
||||
GraffitiInfo: s.cfg.GraffitiInfo,
|
||||
}
|
||||
s.validatorServer = validatorServer
|
||||
nodeServer := &nodev1alpha1.Server{
|
||||
|
||||
@@ -1027,10 +1027,10 @@ func TestGetVerifyingStateEdgeCases(t *testing.T) {
|
||||
sc: signatureCache,
|
||||
sr: &mockStateByRooter{sbr: sbrErrorIfCalled(t)}, // Should not be called
|
||||
hsp: &mockHeadStateProvider{
|
||||
headRoot: parentRoot[:], // Same as parent
|
||||
headSlot: 32, // Epoch 1
|
||||
headState: fuluState.Copy(), // HeadState (not ReadOnly) for ProcessSlots
|
||||
headStateReadOnly: nil, // Should not use ReadOnly path
|
||||
headRoot: parentRoot[:], // Same as parent
|
||||
headSlot: 32, // Epoch 1
|
||||
headState: fuluState.Copy(), // HeadState (not ReadOnly) for ProcessSlots
|
||||
headStateReadOnly: nil, // Should not use ReadOnly path
|
||||
},
|
||||
fc: &mockForkchoicer{
|
||||
// Return same root for both to simulate same chain
|
||||
@@ -1045,8 +1045,8 @@ func TestGetVerifyingStateEdgeCases(t *testing.T) {
|
||||
// Wrap to detect HeadState call
|
||||
originalHsp := initializer.shared.hsp.(*mockHeadStateProvider)
|
||||
wrappedHsp := &mockHeadStateProvider{
|
||||
headRoot: originalHsp.headRoot,
|
||||
headSlot: originalHsp.headSlot,
|
||||
headRoot: originalHsp.headRoot,
|
||||
headSlot: originalHsp.headSlot,
|
||||
headState: originalHsp.headState,
|
||||
}
|
||||
initializer.shared.hsp = &headStateCallTracker{
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
### Added
|
||||
|
||||
- Graffiti implementation based on the design doc.
|
||||
2
changelog/tt_run-gofmt.md
Normal file
2
changelog/tt_run-gofmt.md
Normal file
@@ -0,0 +1,2 @@
|
||||
### Ignored
|
||||
- Run go fmt
|
||||
@@ -26,21 +26,21 @@ func TestLifecycle(t *testing.T) {
|
||||
port := 1000 + rand.Intn(1000)
|
||||
prometheusService := NewService(t.Context(), fmt.Sprintf(":%d", port), nil)
|
||||
prometheusService.Start()
|
||||
// Actively wait until the service responds on /metrics (faster and less flaky than a fixed sleep)
|
||||
deadline := time.Now().Add(3 * time.Second)
|
||||
for {
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatalf("metrics endpoint not ready within timeout")
|
||||
}
|
||||
resp, err := http.Get(fmt.Sprintf("http://localhost:%d/metrics", port))
|
||||
if err == nil {
|
||||
_ = resp.Body.Close()
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
break
|
||||
}
|
||||
}
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
// Actively wait until the service responds on /metrics (faster and less flaky than a fixed sleep)
|
||||
deadline := time.Now().Add(3 * time.Second)
|
||||
for {
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatalf("metrics endpoint not ready within timeout")
|
||||
}
|
||||
resp, err := http.Get(fmt.Sprintf("http://localhost:%d/metrics", port))
|
||||
if err == nil {
|
||||
_ = resp.Body.Close()
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
break
|
||||
}
|
||||
}
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
|
||||
// Query the service to ensure it really started.
|
||||
resp, err := http.Get(fmt.Sprintf("http://localhost:%d/metrics", port))
|
||||
@@ -49,18 +49,18 @@ func TestLifecycle(t *testing.T) {
|
||||
|
||||
err = prometheusService.Stop()
|
||||
require.NoError(t, err)
|
||||
// Actively wait until the service stops responding on /metrics
|
||||
deadline = time.Now().Add(3 * time.Second)
|
||||
for {
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatalf("metrics endpoint still reachable after timeout")
|
||||
}
|
||||
_, err = http.Get(fmt.Sprintf("http://localhost:%d/metrics", port))
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
// Actively wait until the service stops responding on /metrics
|
||||
deadline = time.Now().Add(3 * time.Second)
|
||||
for {
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatalf("metrics endpoint still reachable after timeout")
|
||||
}
|
||||
_, err = http.Get(fmt.Sprintf("http://localhost:%d/metrics", port))
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
|
||||
// Query the service to ensure it really stopped.
|
||||
_, err = http.Get(fmt.Sprintf("http://localhost:%d/metrics", port))
|
||||
|
||||
@@ -47,13 +47,3 @@ func BuildData() string {
|
||||
}
|
||||
return fmt.Sprintf("Prysm/%s/%s", gitTag, gitCommit)
|
||||
}
|
||||
|
||||
// GetCommitPrefix returns the first 4 characters of the git commit.
|
||||
// This is used for graffiti generation per the client identification spec.
|
||||
// Note: BuildData() must be called before this (happens at startup via Version()).
|
||||
func GetCommitPrefix() string {
|
||||
if len(gitCommit) < 4 {
|
||||
return gitCommit
|
||||
}
|
||||
return gitCommit[:4]
|
||||
}
|
||||
|
||||
@@ -225,9 +225,9 @@ func (r *testRunner) testDepositsAndTx(ctx context.Context, g *errgroup.Group,
|
||||
if err := helpers.ComponentsStarted(ctx, []e2etypes.ComponentRunner{r.depositor}); err != nil {
|
||||
return errors.Wrap(err, "testDepositsAndTx unable to run, depositor did not Start")
|
||||
}
|
||||
go func() {
|
||||
if r.config.TestDeposits {
|
||||
log.Info("Running deposit tests")
|
||||
go func() {
|
||||
if r.config.TestDeposits {
|
||||
log.Info("Running deposit tests")
|
||||
// The validators with an index < minGenesisActiveCount all have deposits already from the chain start.
|
||||
// Skip all of those chain start validators by seeking to minGenesisActiveCount in the validator list
|
||||
// for further deposit testing.
|
||||
@@ -238,12 +238,12 @@ func (r *testRunner) testDepositsAndTx(ctx context.Context, g *errgroup.Group,
|
||||
r.t.Error(errors.Wrap(err, "depositor.SendAndMine failed"))
|
||||
}
|
||||
}
|
||||
}
|
||||
// Only generate background transactions when relevant for the test.
|
||||
if r.config.TestDeposits || r.config.TestFeature || r.config.UseBuilder {
|
||||
r.testTxGeneration(ctx, g, keystorePath, []e2etypes.ComponentRunner{})
|
||||
}
|
||||
}()
|
||||
}
|
||||
// Only generate background transactions when relevant for the test.
|
||||
if r.config.TestDeposits || r.config.TestFeature || r.config.UseBuilder {
|
||||
r.testTxGeneration(ctx, g, keystorePath, []e2etypes.ComponentRunner{})
|
||||
}
|
||||
}()
|
||||
if r.config.TestDeposits {
|
||||
return depositCheckValidator.Start(ctx)
|
||||
}
|
||||
|
||||
@@ -260,27 +260,17 @@ func verifyGraffitiInBlocks(_ *e2etypes.EvaluationContext, conns ...*grpc.Client
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var found bool
|
||||
var e bool
|
||||
slot := blk.Block().Slot()
|
||||
graffitiInBlock := blk.Block().Body().Graffiti()
|
||||
// Trim trailing null bytes from graffiti.
|
||||
// Example: "GEabcdPRxxxxSushi\x00\x00\x00..." becomes "GEabcdPRxxxxSushi"
|
||||
graffitiTrimmed := bytes.TrimRight(graffitiInBlock[:], "\x00")
|
||||
for _, graffiti := range helpers.Graffiti {
|
||||
// Check suffix match since graffiti now has EL/CL version prefixes.
|
||||
// bytes.HasSuffix returns true if the first arg ends with the second arg.
|
||||
// Examples:
|
||||
// bytes.HasSuffix([]byte("GEabcdPRxxxxSushi"), []byte("Sushi")) → true
|
||||
// bytes.HasSuffix([]byte("PRxxxxRamen"), []byte("Ramen")) → true
|
||||
// bytes.HasSuffix([]byte("Sushi"), []byte("Sushi")) → true (exact match)
|
||||
// bytes.HasSuffix([]byte("SushiXXX"), []byte("Sushi")) → false (not at end)
|
||||
if bytes.HasSuffix(graffitiTrimmed, []byte(graffiti)) {
|
||||
found = true
|
||||
if bytes.Equal(bytesutil.PadTo([]byte(graffiti), 32), graffitiInBlock[:]) {
|
||||
e = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found && slot != 0 {
|
||||
return fmt.Errorf("block at slot %d has graffiti %q which does not end with any expected graffiti", slot, string(graffitiTrimmed))
|
||||
if !e && slot != 0 {
|
||||
return errors.New("could not get graffiti from the list")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ func TestEndToEnd_MinimalConfig(t *testing.T) {
|
||||
r := e2eMinimal(t, cfg,
|
||||
types.WithCheckpointSync(),
|
||||
types.WithEpochs(10),
|
||||
types.WithExitEpoch(4), // Minimum due to ShardCommitteePeriod=4
|
||||
types.WithLargeBlobs(), // Use large blob transactions for BPO testing
|
||||
types.WithExitEpoch(4), // Minimum due to ShardCommitteePeriod=4
|
||||
types.WithLargeBlobs(), // Use large blob transactions for BPO testing
|
||||
)
|
||||
r.run()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user