Skip to content

Commit f42b326

Browse files
authored
Update block's commitment size (#12470)
1 parent 042b851 commit f42b326

File tree

15 files changed

+630
-624
lines changed

15 files changed

+630
-624
lines changed

beacon-chain/db/kv/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ go_library(
3939
"//beacon-chain/state/genesis:go_default_library",
4040
"//beacon-chain/state/state-native:go_default_library",
4141
"//config/features:go_default_library",
42+
"//config/fieldparams:go_default_library",
4243
"//config/params:go_default_library",
4344
"//consensus-types/blocks:go_default_library",
4445
"//consensus-types/interfaces:go_default_library",

beacon-chain/db/kv/blob.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"sort"
88

99
"github.com/pkg/errors"
10+
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
1011
"github.com/prysmaticlabs/prysm/v4/config/params"
1112
types "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
1213
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
@@ -71,8 +72,8 @@ func (s *Store) verifySideCars(scs []*ethpb.BlobSidecar) error {
7172
if len(scs) == 0 {
7273
return errors.New("nil or empty blob sidecars")
7374
}
74-
if uint64(len(scs)) > params.BeaconConfig().MaxBlobsPerBlock {
75-
return fmt.Errorf("too many sidecars: %d > %d", len(scs), params.BeaconConfig().MaxBlobsPerBlock)
75+
if uint64(len(scs)) > fieldparams.MaxBlobsPerBlock {
76+
return fmt.Errorf("too many sidecars: %d > %d", len(scs), fieldparams.MaxBlobsPerBlock)
7677
}
7778

7879
sl := scs[0].Slot

beacon-chain/db/kv/blob_test.go

+21-20
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/pkg/errors"
10+
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
1011
"github.com/prysmaticlabs/prysm/v4/config/params"
1112
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
1213
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
@@ -63,18 +64,18 @@ func TestStore_BlobSidecars(t *testing.T) {
6364
})
6465
t.Run("save and retrieve by root (max)", func(t *testing.T) {
6566
db := setupDB(t)
66-
scs := generateBlobSidecars(t, params.BeaconConfig().MaxBlobsPerBlock)
67+
scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
6768
require.NoError(t, db.SaveBlobSidecar(ctx, scs))
68-
require.Equal(t, int(params.BeaconConfig().MaxBlobsPerBlock), len(scs))
69+
require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs))
6970
got, err := db.BlobSidecarsByRoot(ctx, bytesutil.ToBytes32(scs[0].BlockRoot))
7071
require.NoError(t, err)
7172
require.NoError(t, equalBlobSlices(scs, got))
7273
})
7374
t.Run("save and retrieve valid subset by root", func(t *testing.T) {
7475
db := setupDB(t)
75-
scs := generateBlobSidecars(t, params.BeaconConfig().MaxBlobsPerBlock)
76+
scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
7677
require.NoError(t, db.SaveBlobSidecar(ctx, scs))
77-
require.Equal(t, int(params.BeaconConfig().MaxBlobsPerBlock), len(scs))
78+
require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs))
7879

7980
// we'll request indices 0 and 3, so make a slice with those indices for comparison
8081
expect := make([]*ethpb.BlobSidecar, 2)
@@ -89,9 +90,9 @@ func TestStore_BlobSidecars(t *testing.T) {
8990
})
9091
t.Run("error for invalid index when retrieving by root", func(t *testing.T) {
9192
db := setupDB(t)
92-
scs := generateBlobSidecars(t, params.BeaconConfig().MaxBlobsPerBlock)
93+
scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
9394
require.NoError(t, db.SaveBlobSidecar(ctx, scs))
94-
require.Equal(t, int(params.BeaconConfig().MaxBlobsPerBlock), len(scs))
95+
require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs))
9596

9697
got, err := db.BlobSidecarsByRoot(ctx, bytesutil.ToBytes32(scs[0].BlockRoot), uint64(len(scs)))
9798
require.ErrorIs(t, err, ErrNotFound)
@@ -108,18 +109,18 @@ func TestStore_BlobSidecars(t *testing.T) {
108109
})
109110
t.Run("save and retrieve by slot (max)", func(t *testing.T) {
110111
db := setupDB(t)
111-
scs := generateBlobSidecars(t, params.BeaconConfig().MaxBlobsPerBlock)
112+
scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
112113
require.NoError(t, db.SaveBlobSidecar(ctx, scs))
113-
require.Equal(t, int(params.BeaconConfig().MaxBlobsPerBlock), len(scs))
114+
require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs))
114115
got, err := db.BlobSidecarsBySlot(ctx, scs[0].Slot)
115116
require.NoError(t, err)
116117
require.NoError(t, equalBlobSlices(scs, got))
117118
})
118119
t.Run("save and retrieve valid subset by slot", func(t *testing.T) {
119120
db := setupDB(t)
120-
scs := generateBlobSidecars(t, params.BeaconConfig().MaxBlobsPerBlock)
121+
scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
121122
require.NoError(t, db.SaveBlobSidecar(ctx, scs))
122-
require.Equal(t, int(params.BeaconConfig().MaxBlobsPerBlock), len(scs))
123+
require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs))
123124

124125
// we'll request indices 0 and 3, so make a slice with those indices for comparison
125126
expect := make([]*ethpb.BlobSidecar, 2)
@@ -135,19 +136,19 @@ func TestStore_BlobSidecars(t *testing.T) {
135136
})
136137
t.Run("error for invalid index when retrieving by slot", func(t *testing.T) {
137138
db := setupDB(t)
138-
scs := generateBlobSidecars(t, params.BeaconConfig().MaxBlobsPerBlock)
139+
scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
139140
require.NoError(t, db.SaveBlobSidecar(ctx, scs))
140-
require.Equal(t, int(params.BeaconConfig().MaxBlobsPerBlock), len(scs))
141+
require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs))
141142

142143
got, err := db.BlobSidecarsBySlot(ctx, scs[0].Slot, uint64(len(scs)))
143144
require.ErrorIs(t, err, ErrNotFound)
144145
require.Equal(t, 0, len(got))
145146
})
146147
t.Run("delete works", func(t *testing.T) {
147148
db := setupDB(t)
148-
scs := generateBlobSidecars(t, params.BeaconConfig().MaxBlobsPerBlock)
149+
scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
149150
require.NoError(t, db.SaveBlobSidecar(ctx, scs))
150-
require.Equal(t, int(params.BeaconConfig().MaxBlobsPerBlock), len(scs))
151+
require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs))
151152
got, err := db.BlobSidecarsByRoot(ctx, bytesutil.ToBytes32(scs[0].BlockRoot))
152153
require.NoError(t, err)
153154
require.NoError(t, equalBlobSlices(scs, got))
@@ -158,25 +159,25 @@ func TestStore_BlobSidecars(t *testing.T) {
158159
})
159160
t.Run("saving a blob with older slot", func(t *testing.T) {
160161
db := setupDB(t)
161-
scs := generateBlobSidecars(t, params.BeaconConfig().MaxBlobsPerBlock)
162+
scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
162163
require.NoError(t, db.SaveBlobSidecar(ctx, scs))
163-
require.Equal(t, int(params.BeaconConfig().MaxBlobsPerBlock), len(scs))
164+
require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs))
164165
got, err := db.BlobSidecarsByRoot(ctx, bytesutil.ToBytes32(scs[0].BlockRoot))
165166
require.NoError(t, err)
166167
require.NoError(t, equalBlobSlices(scs, got))
167168
require.ErrorContains(t, "but already have older blob with slot", db.SaveBlobSidecar(ctx, scs))
168169
})
169170
t.Run("saving a new blob for rotation", func(t *testing.T) {
170171
db := setupDB(t)
171-
scs := generateBlobSidecars(t, params.BeaconConfig().MaxBlobsPerBlock)
172+
scs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
172173
require.NoError(t, db.SaveBlobSidecar(ctx, scs))
173-
require.Equal(t, int(params.BeaconConfig().MaxBlobsPerBlock), len(scs))
174+
require.Equal(t, int(fieldparams.MaxBlobsPerBlock), len(scs))
174175
oldBlockRoot := scs[0].BlockRoot
175176
got, err := db.BlobSidecarsByRoot(ctx, bytesutil.ToBytes32(oldBlockRoot))
176177
require.NoError(t, err)
177178
require.NoError(t, equalBlobSlices(scs, got))
178179

179-
newScs := generateBlobSidecars(t, params.BeaconConfig().MaxBlobsPerBlock)
180+
newScs := generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock)
180181
newRetentionSlot := primitives.Slot(params.BeaconNetworkConfig().MinEpochsForBlobsSidecarsRequest.Mul(uint64(params.BeaconConfig().SlotsPerEpoch)))
181182
for _, sc := range newScs {
182183
sc.Slot = sc.Slot + newRetentionSlot
@@ -231,7 +232,7 @@ func TestStore_verifySideCars(t *testing.T) {
231232
error string
232233
}{
233234
{name: "empty", scs: []*ethpb.BlobSidecar{}, error: "nil or empty blob sidecars"},
234-
{name: "too many sidecars", scs: generateBlobSidecars(t, params.BeaconConfig().MaxBlobsPerBlock+1), error: "too many sidecars: 5 > 4"},
235+
{name: "too many sidecars", scs: generateBlobSidecars(t, fieldparams.MaxBlobsPerBlock+1), error: "too many sidecars: 5 > 4"},
235236
{name: "invalid slot", scs: []*ethpb.BlobSidecar{{Slot: 1}, {Slot: 2}}, error: "sidecar slot mismatch: 2 != 1"},
236237
{name: "invalid proposer index", scs: []*ethpb.BlobSidecar{{ProposerIndex: 1}, {ProposerIndex: 2}}, error: "sidecar proposer index mismatch: 2 != 1"},
237238
{name: "invalid root", scs: []*ethpb.BlobSidecar{{BlockRoot: []byte{1}}, {BlockRoot: []byte{2}}}, error: "sidecar root mismatch: 02 != 01"},

beacon-chain/rpc/eth/beacon/config_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func TestGetSpec(t *testing.T) {
141141
resp, err := server.GetSpec(context.Background(), &emptypb.Empty{})
142142
require.NoError(t, err)
143143

144-
assert.Equal(t, 112, len(resp.Data))
144+
assert.Equal(t, 111, len(resp.Data))
145145
for k, v := range resp.Data {
146146
switch k {
147147
case "CONFIG_NAME":
@@ -378,6 +378,8 @@ func TestGetSpec(t *testing.T) {
378378
assert.Equal(t, "2", v)
379379
case "REORG_WEIGHT_THRESHOLD":
380380
assert.Equal(t, "20", v)
381+
case "REORG_PARENT_WEIGHT_THRESHOLD":
382+
assert.Equal(t, "160", v)
381383
case "SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY":
382384
default:
383385
t.Errorf("Incorrect key: %s", k)

config/fieldparams/mainnet.go

+2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ const (
2626
SyncCommitteeAggregationBytesLength = 16 // SyncCommitteeAggregationBytesLength defines the length of sync committee aggregate bytes.
2727
SyncAggregateSyncCommitteeBytesLength = 64 // SyncAggregateSyncCommitteeBytesLength defines the length of sync committee bytes in a sync aggregate.
2828
MaxWithdrawalsPerPayload = 16 // MaxWithdrawalsPerPayloadLength defines the maximum number of withdrawals that can be included in a payload.
29+
MaxBlobsPerBlock = 4 // MaxBlobsPerBlock defines the maximum number of blobs with respect to consensus rule can be included in a block.
30+
MaxBlobCommitmentsPerBlock = 4096 // MaxBlobCommitmentsPerBlock defines the theoretical limit of blobs can be included in a block.
2931
BlobLength = 131072 // BlobLength defines the byte length of a blob.
3032
)

config/fieldparams/minimal.go

+2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ const (
2626
SyncCommitteeAggregationBytesLength = 1 // SyncCommitteeAggregationBytesLength defines the sync committee aggregate bytes.
2727
SyncAggregateSyncCommitteeBytesLength = 4 // SyncAggregateSyncCommitteeBytesLength defines the length of sync committee bytes in a sync aggregate.
2828
MaxWithdrawalsPerPayload = 4 // MaxWithdrawalsPerPayloadLength defines the maximum number of withdrawals that can be included in a payload.
29+
MaxBlobsPerBlock = 4 // MaxBlobsPerBlock defines the maximum number of blobs with respect to consensus rule can be included in a block.
30+
MaxBlobCommitmentsPerBlock = 16 // MaxBlobCommitmentsPerBlock defines the theoretical limit of blobs can be included in a block.
2931
BlobLength = 4 // BlobLength defines the byte length of a blob.
3032
)

config/params/config.go

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ type BeaconChainConfig struct {
105105
MaxWithdrawalsPerPayload uint64 `yaml:"MAX_WITHDRAWALS_PER_PAYLOAD" spec:"true"` // MaxWithdrawalsPerPayload defines the maximum number of withdrawals in a block.
106106
MaxBlsToExecutionChanges uint64 `yaml:"MAX_BLS_TO_EXECUTION_CHANGES" spec:"true"` // MaxBlsToExecutionChanges defines the maximum number of BLS-to-execution-change objects in a block.
107107
MaxValidatorsPerWithdrawalsSweep uint64 `yaml:"MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP" spec:"true"` // MaxValidatorsPerWithdrawalsSweep bounds the size of the sweep searching for withdrawals per slot.
108-
MaxBlobsPerBlock uint64 `yaml:"MAX_BLOBS_PER_BLOCK" spec:"true"` // MaxBlobsPerBlock defines the maximum number of blobs in a block.
109108

110109
// BLS domain values.
111110
DomainBeaconProposer [4]byte `yaml:"DOMAIN_BEACON_PROPOSER" spec:"true"` // DomainBeaconProposer defines the BLS signature domain for beacon proposal verification.

config/params/loader_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ import (
2020

2121
// Variables defined in the placeholderFields will not be tested in `TestLoadConfigFile`.
2222
// These are variables that we don't use in Prysm. (i.e. future hardfork, light client... etc)
23-
var placeholderFields = []string{"UPDATE_TIMEOUT", "DENEB_FORK_EPOCH", "DENEB_FORK_VERSION",
24-
"ATTESTATION_SUBNET_EXTRA_BITS", "RESP_TIMEOUT", "MAX_REQUEST_BLOCKS", "EPOCHS_PER_SUBNET_SUBSCRIPTION",
23+
var placeholderFields = []string{"UPDATE_TIMEOUT", "ATTESTATION_SUBNET_EXTRA_BITS", "RESP_TIMEOUT", "MAX_REQUEST_BLOCKS", "EPOCHS_PER_SUBNET_SUBSCRIPTION",
2524
"EIP6110_FORK_EPOCH", "MESSAGE_DOMAIN_INVALID_SNAPPY", "MIN_EPOCHS_FOR_BLOCK_REQUESTS", "MAXIMUM_GOSSIP_CLOCK_DISPARITY",
2625
"MESSAGE_DOMAIN_VALID_SNAPPY", "GOSSIP_MAX_SIZE", "SUBNETS_PER_NODE", "ATTESTATION_SUBNET_COUNT",
2726
"MAX_CHUNK_SIZE", "ATTESTATION_PROPAGATION_SLOT_RANGE", "ATTESTATION_SUBNET_PREFIX_BITS", "EIP6110_FORK_VERSION", "TTFB_TIMEOUT"}

config/params/mainnet_config.go

-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ var mainnetBeaconConfig = &BeaconChainConfig{
161161
MaxWithdrawalsPerPayload: 16,
162162
MaxBlsToExecutionChanges: 16,
163163
MaxValidatorsPerWithdrawalsSweep: 16384,
164-
MaxBlobsPerBlock: 4,
165164

166165
// BLS domain values.
167166
DomainBeaconProposer: bytesutil.Uint32ToBytes4(0x00000000),

0 commit comments

Comments
 (0)