mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
<!-- Thanks for sending a PR! Before submitting: 1. If this is your first PR, check out our contribution guide here https://docs.prylabs.network/docs/contribute/contribution-guidelines You will then need to sign our Contributor License Agreement (CLA), which will show up as a comment from a bot in this pull request after you open it. We cannot review code without a signed CLA. 2. Please file an associated tracking issue if this pull request is non-trivial and requires context for our team to understand. All features and most bug fixes should have an associated issue with a design discussed and decided upon. Small bug fixes and documentation improvements don't need issues. 3. New features and bug fixes must have tests. Documentation may need to be updated. If you're unsure what to update, send the PR, and we'll discuss in review. 4. Note that PRs updating dependencies and new Go versions are not accepted. Please file an issue instead. 5. A changelog entry is required for user facing issues. --> **What type of PR is this?** Feature **What does this PR do? Why is it needed?** | Feature | Semi-Supernode | Supernode | | ----------------------- | ------------------------- | ------------------------ | | **Custody Groups** | 64 | 128 | | **Data Columns** | 64 | 128 | | **Storage** | ~50% | ~100% | | **Blob Reconstruction** | Yes (via Reed-Solomon) | No reconstruction needed | | **Flag** | `--semi-supernode` | `--supernode` | | **Can serve all blobs** | Yes (with reconstruction) | Yes (directly) | **note** if your validator total effective balance results in more custody than the semi-supernode it will override those those requirements. cgc=64 from @nalepae Pro: - We are useful to the network - Less disconnection likelihood - Straight forward to implement Con: - We cannot revert to a full node - We have to serve incoming RPC requests corresponding to 64 columns Tested the following using this kurtosis setup ``` participants: # Super-nodes - el_type: geth el_image: ethpandaops/geth:master cl_type: prysm vc_image: gcr.io/offchainlabs/prysm/validator:latest cl_image: gcr.io/offchainlabs/prysm/beacon-chain:latest count: 2 cl_extra_params: - --supernode vc_extra_params: - --verbosity=debug # Full-nodes - el_type: geth el_image: ethpandaops/geth:master cl_type: prysm vc_image: gcr.io/offchainlabs/prysm/validator:latest cl_image: gcr.io/offchainlabs/prysm/beacon-chain:latest count: 2 validator_count: 1 cl_extra_params: - --semi-supernode vc_extra_params: - --verbosity=debug additional_services: - dora - spamoor spamoor_params: image: ethpandaops/spamoor:master max_mem: 4000 spammers: - scenario: eoatx config: throughput: 200 - scenario: blobs config: throughput: 20 network_params: fulu_fork_epoch: 0 withdrawal_type: "0x02" preset: mainnet global_log_level: debug ``` ``` curl -H "Accept: application/json" http://127.0.0.1:32961/eth/v1/node/identity {"data":{"peer_id":"16Uiu2HAm7xzhnGwea8gkcxRSC6fzUkvryP6d9HdWNkoeTkj6RSqw","enr":"enr:-Ni4QIH5u2NQz17_pTe9DcCfUyG8TidDJJjIeBpJRRm4ACQzGBpCJdyUP9eGZzwwZ2HS1TnB9ACxFMQ5LP5njnMDLm-GAZqZEXjih2F0dG5ldHOIAAAAAAAwAACDY2djQIRldGgykLZy_whwAAA4__________-CaWSCdjSCaXCErBAAE4NuZmSEAAAAAIRxdWljgjLIiXNlY3AyNTZrMaECulJrXpSOBmCsQWcGYzQsst7r3-Owlc9iZbEcJTDkB6qIc3luY25ldHMFg3RjcIIyyIN1ZHCCLuA","p2p_addresses":["/ip4/172.16.0.19/tcp/13000/p2p/16Uiu2HAm7xzhnGwea8gkcxRSC6fzUkvryP6d9HdWNkoeTkj6RSqw","/ip4/172.16.0.19/udp/13000/quic-v1/p2p/16Uiu2HAm7xzhnGwea8gkcxRSC6fzUkvryP6d9HdWNkoeTkj6RSqw"],"discovery_addresses":["/ip4/172.16.0.19/udp/12000/p2p/16Uiu2HAm7xzhnGwea8gkcxRSC6fzUkvryP6d9HdWNkoeTkj6RSqw"],"metadata":{"seq_number":"3","attnets":"0x0000000000300000","syncnets":"0x05","custody_group_count":"64"}}} ``` ``` curl -s http://127.0.0.1:32961/eth/v1/debug/beacon/data_column_sidecars/head | jq '.data | length' 64 ``` ``` curl -X 'GET' \ 'http://127.0.0.1:32961/eth/v1/beacon/blobs/head' \ -H 'accept: application/json' ``` **Which issues(s) does this PR fix?** Fixes # **Other notes for review** **Acknowledgements** - [x] I have read [CONTRIBUTING.md](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md). - [x] I have included a uniquely named [changelog fragment file](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md#maintaining-changelogmd). - [x] I have added a description to this PR with sufficient context for reviewers to understand this PR. --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com> Co-authored-by: james-prysm <jhe@offchainlabs.com> Co-authored-by: Manu NALEPA <enalepa@offchainlabs.com>
161 lines
5.2 KiB
Go
161 lines
5.2 KiB
Go
package peerdas
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/OffchainLabs/prysm/v7/config/params"
|
|
"github.com/OffchainLabs/prysm/v7/testing/require"
|
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
|
)
|
|
|
|
func TestSemiSupernodeCustody(t *testing.T) {
|
|
params.SetupTestConfigCleanup(t)
|
|
cfg := params.BeaconConfig()
|
|
cfg.NumberOfCustodyGroups = 128
|
|
cfg.NumberOfColumns = 128
|
|
params.OverrideBeaconConfig(cfg)
|
|
|
|
// Create a test node ID
|
|
nodeID := enode.ID([32]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32})
|
|
|
|
t.Run("semi-supernode custodies exactly 64 columns", func(t *testing.T) {
|
|
// Semi-supernode uses 64 custody groups (half of 128)
|
|
const semiSupernodeCustodyGroupCount = 64
|
|
|
|
// Get custody groups for semi-supernode
|
|
custodyGroups, err := CustodyGroups(nodeID, semiSupernodeCustodyGroupCount)
|
|
require.NoError(t, err)
|
|
require.Equal(t, semiSupernodeCustodyGroupCount, len(custodyGroups))
|
|
|
|
// Verify we get exactly 64 custody columns
|
|
custodyColumns, err := CustodyColumns(custodyGroups)
|
|
require.NoError(t, err)
|
|
require.Equal(t, semiSupernodeCustodyGroupCount, len(custodyColumns))
|
|
|
|
// Verify the columns are valid (within 0-127 range)
|
|
for columnIndex := range custodyColumns {
|
|
if columnIndex >= cfg.NumberOfColumns {
|
|
t.Fatalf("Invalid column index %d, should be less than %d", columnIndex, cfg.NumberOfColumns)
|
|
}
|
|
}
|
|
})
|
|
|
|
t.Run("64 columns is exactly the minimum for reconstruction", func(t *testing.T) {
|
|
minimumCount := MinimumColumnCountToReconstruct()
|
|
require.Equal(t, uint64(64), minimumCount)
|
|
})
|
|
|
|
t.Run("semi-supernode vs supernode custody", func(t *testing.T) {
|
|
// Semi-supernode (64 custody groups)
|
|
semiSupernodeGroups, err := CustodyGroups(nodeID, 64)
|
|
require.NoError(t, err)
|
|
semiSupernodeColumns, err := CustodyColumns(semiSupernodeGroups)
|
|
require.NoError(t, err)
|
|
|
|
// Supernode (128 custody groups = all groups)
|
|
supernodeGroups, err := CustodyGroups(nodeID, 128)
|
|
require.NoError(t, err)
|
|
supernodeColumns, err := CustodyColumns(supernodeGroups)
|
|
require.NoError(t, err)
|
|
|
|
// Verify semi-supernode has exactly half the columns of supernode
|
|
require.Equal(t, 64, len(semiSupernodeColumns))
|
|
require.Equal(t, 128, len(supernodeColumns))
|
|
require.Equal(t, len(supernodeColumns)/2, len(semiSupernodeColumns))
|
|
|
|
// Verify all semi-supernode columns are a subset of supernode columns
|
|
for columnIndex := range semiSupernodeColumns {
|
|
if !supernodeColumns[columnIndex] {
|
|
t.Fatalf("Semi-supernode column %d not found in supernode columns", columnIndex)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
func TestMinimumCustodyGroupCountToReconstruct(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
numberOfColumns uint64
|
|
numberOfGroups uint64
|
|
expectedResult uint64
|
|
}{
|
|
{
|
|
name: "Standard 1:1 ratio (128 columns, 128 groups)",
|
|
numberOfColumns: 128,
|
|
numberOfGroups: 128,
|
|
expectedResult: 64, // Need half of 128 groups
|
|
},
|
|
{
|
|
name: "2 columns per group (128 columns, 64 groups)",
|
|
numberOfColumns: 128,
|
|
numberOfGroups: 64,
|
|
expectedResult: 32, // Need 64 columns, which is 32 groups (64/2)
|
|
},
|
|
{
|
|
name: "4 columns per group (128 columns, 32 groups)",
|
|
numberOfColumns: 128,
|
|
numberOfGroups: 32,
|
|
expectedResult: 16, // Need 64 columns, which is 16 groups (64/4)
|
|
},
|
|
{
|
|
name: "Odd number requiring ceiling division (100 columns, 30 groups)",
|
|
numberOfColumns: 100,
|
|
numberOfGroups: 30,
|
|
expectedResult: 17, // Need 50 columns, 3 columns per group (100/30), ceiling(50/3) = 17
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
params.SetupTestConfigCleanup(t)
|
|
cfg := params.BeaconConfig()
|
|
cfg.NumberOfColumns = tt.numberOfColumns
|
|
cfg.NumberOfCustodyGroups = tt.numberOfGroups
|
|
params.OverrideBeaconConfig(cfg)
|
|
|
|
result, err := MinimumCustodyGroupCountToReconstruct()
|
|
require.NoError(t, err)
|
|
require.Equal(t, tt.expectedResult, result)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestMinimumCustodyGroupCountToReconstruct_ErrorCases(t *testing.T) {
|
|
t.Run("Returns error when NumberOfColumns is zero", func(t *testing.T) {
|
|
params.SetupTestConfigCleanup(t)
|
|
cfg := params.BeaconConfig()
|
|
cfg.NumberOfColumns = 0
|
|
cfg.NumberOfCustodyGroups = 128
|
|
params.OverrideBeaconConfig(cfg)
|
|
|
|
_, err := MinimumCustodyGroupCountToReconstruct()
|
|
require.NotNil(t, err)
|
|
require.Equal(t, true, err.Error() == "NumberOfColumns cannot be zero")
|
|
})
|
|
|
|
t.Run("Returns error when NumberOfCustodyGroups is zero", func(t *testing.T) {
|
|
params.SetupTestConfigCleanup(t)
|
|
cfg := params.BeaconConfig()
|
|
cfg.NumberOfColumns = 128
|
|
cfg.NumberOfCustodyGroups = 0
|
|
params.OverrideBeaconConfig(cfg)
|
|
|
|
_, err := MinimumCustodyGroupCountToReconstruct()
|
|
require.NotNil(t, err)
|
|
require.Equal(t, true, err.Error() == "NumberOfCustodyGroups cannot be zero")
|
|
})
|
|
|
|
t.Run("Returns error when NumberOfCustodyGroups exceeds NumberOfColumns", func(t *testing.T) {
|
|
params.SetupTestConfigCleanup(t)
|
|
cfg := params.BeaconConfig()
|
|
cfg.NumberOfColumns = 128
|
|
cfg.NumberOfCustodyGroups = 256
|
|
params.OverrideBeaconConfig(cfg)
|
|
|
|
_, err := MinimumCustodyGroupCountToReconstruct()
|
|
require.NotNil(t, err)
|
|
// Just check that we got an error about the configuration
|
|
require.Equal(t, true, len(err.Error()) > 0)
|
|
})
|
|
}
|