mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
Fix Interop Mode (#8961)
This commit is contained in:
@@ -52,7 +52,7 @@ func configureSlotsPerArchivedPoint(cliCtx *cli.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func configureProofOfWork(cliCtx *cli.Context) {
|
||||
func configureEth1Config(cliCtx *cli.Context) {
|
||||
if cliCtx.IsSet(flags.ChainID.Name) {
|
||||
c := params.BeaconConfig()
|
||||
c.DepositChainID = cliCtx.Uint64(flags.ChainID.Name)
|
||||
@@ -82,3 +82,16 @@ func configureNetwork(cliCtx *cli.Context) {
|
||||
params.OverrideBeaconNetworkConfig(networkCfg)
|
||||
}
|
||||
}
|
||||
|
||||
func configureInteropConfig(cliCtx *cli.Context) {
|
||||
genStateIsSet := cliCtx.IsSet(flags.InteropGenesisStateFlag.Name)
|
||||
genTimeIsSet := cliCtx.IsSet(flags.InteropGenesisTimeFlag.Name)
|
||||
numValsIsSet := cliCtx.IsSet(flags.InteropNumValidatorsFlag.Name)
|
||||
votesIsSet := cliCtx.IsSet(flags.InteropMockEth1DataVotesFlag.Name)
|
||||
|
||||
if genStateIsSet || genTimeIsSet || numValsIsSet || votesIsSet {
|
||||
bCfg := params.BeaconConfig()
|
||||
bCfg.ConfigName = "interop"
|
||||
params.OverrideBeaconConfig(bCfg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestConfigureProofOfWork(t *testing.T) {
|
||||
require.NoError(t, set.Set(flags.DepositContractFlag.Name, "deposit"))
|
||||
cliCtx := cli.NewContext(&app, set, nil)
|
||||
|
||||
configureProofOfWork(cliCtx)
|
||||
configureEth1Config(cliCtx)
|
||||
|
||||
assert.Equal(t, uint64(100), params.BeaconConfig().DepositChainID)
|
||||
assert.Equal(t, uint64(200), params.BeaconConfig().DepositNetworkID)
|
||||
@@ -88,3 +88,74 @@ func TestConfigureNetwork(t *testing.T) {
|
||||
assert.DeepEqual(t, []string{"node1", "node2"}, params.BeaconNetworkConfig().BootstrapNodes)
|
||||
assert.Equal(t, uint64(100), params.BeaconNetworkConfig().ContractDeploymentBlock)
|
||||
}
|
||||
|
||||
func TestConfigureInterop(t *testing.T) {
|
||||
params.SetupTestConfigCleanup(t)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
flagSetter func() *cli.Context
|
||||
configName string
|
||||
}{
|
||||
{
|
||||
"nothing set",
|
||||
func() *cli.Context {
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
return cli.NewContext(&app, set, nil)
|
||||
},
|
||||
"mainnet",
|
||||
},
|
||||
{
|
||||
"mock votes set",
|
||||
func() *cli.Context {
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
set.Bool(flags.InteropMockEth1DataVotesFlag.Name, false, "")
|
||||
assert.NoError(t, set.Set(flags.InteropMockEth1DataVotesFlag.Name, "true"))
|
||||
return cli.NewContext(&app, set, nil)
|
||||
},
|
||||
"interop",
|
||||
},
|
||||
{
|
||||
"validators set",
|
||||
func() *cli.Context {
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
set.Uint64(flags.InteropNumValidatorsFlag.Name, 0, "")
|
||||
assert.NoError(t, set.Set(flags.InteropNumValidatorsFlag.Name, "20"))
|
||||
return cli.NewContext(&app, set, nil)
|
||||
},
|
||||
"interop",
|
||||
},
|
||||
{
|
||||
"genesis time set",
|
||||
func() *cli.Context {
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
set.Uint64(flags.InteropGenesisTimeFlag.Name, 0, "")
|
||||
assert.NoError(t, set.Set(flags.InteropGenesisTimeFlag.Name, "200"))
|
||||
return cli.NewContext(&app, set, nil)
|
||||
},
|
||||
"interop",
|
||||
},
|
||||
{
|
||||
"genesis state set",
|
||||
func() *cli.Context {
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
set.String(flags.InteropGenesisStateFlag.Name, "", "")
|
||||
assert.NoError(t, set.Set(flags.InteropGenesisStateFlag.Name, "/path/"))
|
||||
return cli.NewContext(&app, set, nil)
|
||||
},
|
||||
"interop",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
configureInteropConfig(tt.flagSetter())
|
||||
assert.DeepEqual(t, tt.configName, params.BeaconConfig().ConfigName)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,8 +89,9 @@ func New(cliCtx *cli.Context) (*BeaconNode, error) {
|
||||
configureChainConfig(cliCtx)
|
||||
configureHistoricalSlasher(cliCtx)
|
||||
configureSlotsPerArchivedPoint(cliCtx)
|
||||
configureProofOfWork(cliCtx)
|
||||
configureEth1Config(cliCtx)
|
||||
configureNetwork(cliCtx)
|
||||
configureInteropConfig(cliCtx)
|
||||
|
||||
registry := shared.NewServiceRegistry()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user