Fix CMD Config and modify --historical-slasher-node (#6730)

* Fix CMD config overwriting
* Rename and change historical slasher node
* Merge branch 'master' of github.com:prysmaticlabs/prysm into fix-cmd-config
* Fix
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Add storage warning
* Merge branch 'fix-cmd-config' of github.com:prysmaticlabs/prysm into fix-cmd-config
* Remove period
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Add default values test
* Merge branch 'fix-cmd-config' of github.com:prysmaticlabs/prysm into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Gaz
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Fix inits
* Merge branch 'fix-cmd-config' of github.com:prysmaticlabs/prysm into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Fix
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
* Merge branch 'master' of github.com:prysmaticlabs/prysm into fix-cmd-config
* Fix
* Merge refs/heads/master into fix-cmd-config
* Merge refs/heads/master into fix-cmd-config
This commit is contained in:
Ivan Martinez 2020-08-02 18:09:10 -04:00 committed by GitHub
parent 22e2278812
commit 7903ec0b12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 17 deletions

View File

@ -137,6 +137,6 @@ var (
// HistoricalSlasherNode is a set of beacon node flags required for performing historical detection with a slasher.
HistoricalSlasherNode = &cli.BoolFlag{
Name: "historical-slasher-node",
Usage: "Enables required flags for serving historical data to a slasher client",
Usage: "Enables required flags for serving historical data to a slasher client. Results in additional storage usage",
}
)

View File

@ -100,13 +100,20 @@ func NewBeaconNode(cliCtx *cli.Context) (*BeaconNode, error) {
params.LoadChainConfigFile(chainConfigFileName)
}
if cliCtx.IsSet(flags.HistoricalSlasherNode.Name) {
if cliCtx.Bool(flags.HistoricalSlasherNode.Name) {
c := params.BeaconConfig()
c.SlotsPerArchivedPoint = params.BeaconConfig().SlotsPerEpoch
// Save a state every 4 epochs.
c.SlotsPerArchivedPoint = params.BeaconConfig().SlotsPerEpoch * 4
params.OverrideBeaconConfig(c)
cmdConfig := cmd.Get()
// Allow up to 4096 attestations at a time to be requested from the beacon nde.
cmdConfig.MaxRPCPageSize = int(params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().MaxAttestations)
cmd.Init(cmdConfig)
log.Warnf(
"Setting %d slots per archive point and %d max RPC page size for historical slasher usage. This requires additional storage",
c.SlotsPerArchivedPoint,
cmdConfig.MaxRPCPageSize,
)
}
if cliCtx.IsSet(flags.SlotsPerArchivedPoint.Name) {

View File

@ -36,6 +36,7 @@ go_test(
],
embed = [":go_default_library"],
deps = [
"//shared/params:go_default_library",
"//shared/testutil/assert:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_pkg_errors//:go_default_library",

View File

@ -33,7 +33,7 @@ func Init(c *Flags) {
// InitWithReset sets the global config and returns function that is used to reset configuration.
func InitWithReset(c *Flags) func() {
resetFunc := func() {
Init(&Flags{})
Init(nil)
}
Init(c)
return resetFunc
@ -43,12 +43,10 @@ func InitWithReset(c *Flags) func() {
// on what flags are enabled for the beacon-chain client.
func ConfigureBeaconChain(ctx *cli.Context) {
cfg := newConfig(ctx)
maxPageSize := params.BeaconConfig().DefaultPageSize
if ctx.IsSet(RPCMaxPageSizeFlag.Name) {
maxPageSize = ctx.Int(RPCMaxPageSizeFlag.Name)
log.Warnf("Starting beacon chain with max RPC page size of %d", maxPageSize)
cfg.MaxRPCPageSize = ctx.Int(RPCMaxPageSizeFlag.Name)
log.Warnf("Starting beacon chain with max RPC page size of %d", cfg.MaxRPCPageSize)
}
cfg.MaxRPCPageSize = maxPageSize
Init(cfg)
}
@ -56,12 +54,10 @@ func ConfigureBeaconChain(ctx *cli.Context) {
// on what flags are enabled for the slasher client.
func ConfigureSlasher(ctx *cli.Context) {
cfg := newConfig(ctx)
maxPageSize := params.BeaconConfig().DefaultPageSize
if ctx.IsSet(RPCMaxPageSizeFlag.Name) {
maxPageSize = ctx.Int(RPCMaxPageSizeFlag.Name)
log.Warnf("Starting slasher with max RPC page size of %d", maxPageSize)
cfg.MaxRPCPageSize = ctx.Int(RPCMaxPageSizeFlag.Name)
log.Warnf("Starting slasher with max RPC page size of %d", cfg.MaxRPCPageSize)
}
cfg.MaxRPCPageSize = maxPageSize
Init(cfg)
}
@ -73,7 +69,7 @@ func ConfigureValidator(ctx *cli.Context) {
}
func newConfig(ctx *cli.Context) *Flags {
cfg := &Flags{}
cfg := Get()
if ctx.Bool(MinimalConfigFlag.Name) {
log.Warn("Using minimal config")
cfg.MinimalConfig = true

View File

@ -4,19 +4,34 @@ import (
"flag"
"testing"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/urfave/cli/v2"
)
func TestInitFeatureConfig(t *testing.T) {
func TestOverrideConfig(t *testing.T) {
cfg := &Flags{
MinimalConfig: true,
}
Init(cfg)
reset := InitWithReset(cfg)
defer reset()
c := Get()
assert.Equal(t, true, c.MinimalConfig)
}
func TestDefaultConfig(t *testing.T) {
cfg := &Flags{
MaxRPCPageSize: params.BeaconConfig().DefaultPageSize,
}
c := Get()
assert.DeepEqual(t, c, cfg)
reset := InitWithReset(cfg)
defer reset()
c = Get()
assert.DeepEqual(t, c, cfg)
}
func TestConfigureBeaconConfig(t *testing.T) {
app := cli.App{}
set := flag.NewFlagSet("test", 0)

View File

@ -64,7 +64,7 @@ func NewSlasherNode(cliCtx *cli.Context) (*SlasherNode, error) {
return nil, err
}
if cliCtx.IsSet(flags.EnableHistoricalDetectionFlag.Name) {
if cliCtx.Bool(flags.EnableHistoricalDetectionFlag.Name) {
// Set the max RPC size to 4096 as configured by --historical-slasher-node for optimal historical detection.
cmdConfig := cmd.Get()
cmdConfig.MaxRPCPageSize = int(params.BeaconConfig().SlotsPerEpoch * params.BeaconConfig().MaxAttestations)
@ -230,7 +230,7 @@ func (s *SlasherNode) registerDetectionService() error {
ChainFetcher: bs,
AttesterSlashingsFeed: s.attesterSlashingsFeed,
ProposerSlashingsFeed: s.proposerSlashingsFeed,
HistoricalDetection: s.cliCtx.IsSet(flags.EnableHistoricalDetectionFlag.Name),
HistoricalDetection: s.cliCtx.Bool(flags.EnableHistoricalDetectionFlag.Name),
})
return s.services.RegisterService(ds)
}