mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-15 06:28:20 +00:00
Add SlotsPerArchivedPoint flag and a check (#5023)
* Flag * Service * Tests * Tests and comments * Lint * Add to usages Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
6a2955d43c
commit
054b15bc45
@ -97,4 +97,11 @@ var (
|
|||||||
Usage: "A slasher provider string endpoint. Can either be an grpc server endpoint.",
|
Usage: "A slasher provider string endpoint. Can either be an grpc server endpoint.",
|
||||||
Value: "127.0.0.1:5000",
|
Value: "127.0.0.1:5000",
|
||||||
}
|
}
|
||||||
|
// SlotsPerArchivedPoint specifies the number of slots between the archived points, to save beacon state in the cold
|
||||||
|
// section of DB.
|
||||||
|
SlotsPerArchivedPoint = cli.IntFlag{
|
||||||
|
Name: "slots-per-archive-point",
|
||||||
|
Usage: "The slot durations of when an archived state gets saved in the DB.",
|
||||||
|
Value: 128,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
@ -46,6 +46,7 @@ var appFlags = []cli.Flag{
|
|||||||
flags.ArchiveValidatorSetChangesFlag,
|
flags.ArchiveValidatorSetChangesFlag,
|
||||||
flags.ArchiveBlocksFlag,
|
flags.ArchiveBlocksFlag,
|
||||||
flags.ArchiveAttestationsFlag,
|
flags.ArchiveAttestationsFlag,
|
||||||
|
flags.SlotsPerArchivedPoint,
|
||||||
cmd.BootstrapNode,
|
cmd.BootstrapNode,
|
||||||
cmd.NoDiscovery,
|
cmd.NoDiscovery,
|
||||||
cmd.StaticPeers,
|
cmd.StaticPeers,
|
||||||
|
@ -18,6 +18,7 @@ go_library(
|
|||||||
"//beacon-chain/state:go_default_library",
|
"//beacon-chain/state:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/featureconfig:go_default_library",
|
"//shared/featureconfig:go_default_library",
|
||||||
|
"//shared/params:go_default_library",
|
||||||
"@com_github_pkg_errors//:go_default_library",
|
"@com_github_pkg_errors//:go_default_library",
|
||||||
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
|
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
|
||||||
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
|
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
|
||||||
@ -31,6 +32,7 @@ go_test(
|
|||||||
srcs = [
|
srcs = [
|
||||||
"epoch_boundary_root_test.go",
|
"epoch_boundary_root_test.go",
|
||||||
"replay_test.go",
|
"replay_test.go",
|
||||||
|
"service_test.go",
|
||||||
],
|
],
|
||||||
embed = [":go_default_library"],
|
embed = [":go_default_library"],
|
||||||
deps = [
|
deps = [
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
||||||
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
// State represents a management object that handles the internal
|
// State represents a management object that handles the internal
|
||||||
@ -22,3 +23,13 @@ func New(db db.NoHeadAccessDatabase) *State {
|
|||||||
epochBoundarySlotToRoot: make(map[uint64][32]byte),
|
epochBoundarySlotToRoot: make(map[uint64][32]byte),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This verifies the archive point frequency is valid. It checks the interval
|
||||||
|
// is a divisor of the number of slots per epoch. This ensures we have at least one
|
||||||
|
// archive point within range of our state root history when iterating
|
||||||
|
// backwards. It also ensures the archive points align with hot state summaries
|
||||||
|
// which makes it quicker to migrate hot to cold.
|
||||||
|
func verifySlotsPerArchivePoint(slotsPerArchivePoint uint64) bool {
|
||||||
|
return slotsPerArchivePoint > 0 &&
|
||||||
|
slotsPerArchivePoint%params.BeaconConfig().SlotsPerEpoch == 0
|
||||||
|
}
|
||||||
|
27
beacon-chain/state/stategen/service_test.go
Normal file
27
beacon-chain/state/stategen/service_test.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package stategen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_verifySlotsPerArchivePoint(t *testing.T) {
|
||||||
|
type tc struct {
|
||||||
|
input uint64
|
||||||
|
result bool
|
||||||
|
}
|
||||||
|
tests := []tc{
|
||||||
|
{0, false},
|
||||||
|
{1, false},
|
||||||
|
{params.BeaconConfig().SlotsPerEpoch, true},
|
||||||
|
{params.BeaconConfig().SlotsPerEpoch + 1, false},
|
||||||
|
{params.BeaconConfig().SlotsPerHistoricalRoot, true},
|
||||||
|
{params.BeaconConfig().SlotsPerHistoricalRoot + 1, false},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
if got := verifySlotsPerArchivePoint(tt.input); got != tt.result {
|
||||||
|
t.Errorf("verifySlotsPerArchivePoint(%d) = %v, want %v", tt.input, got, tt.result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -91,6 +91,7 @@ var appHelpFlagGroups = []flagGroup{
|
|||||||
flags.HTTPWeb3ProviderFlag,
|
flags.HTTPWeb3ProviderFlag,
|
||||||
flags.SetGCPercent,
|
flags.SetGCPercent,
|
||||||
flags.UnsafeSync,
|
flags.UnsafeSync,
|
||||||
|
flags.SlotsPerArchivedPoint,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user