Set default fleet to shards.test

This commit is contained in:
Andrea Maria Piana 2023-12-07 13:45:53 +00:00
parent 92f0479a0c
commit 546f0b9d5c
4 changed files with 44 additions and 17 deletions

View File

@ -1410,7 +1410,7 @@ func TestSetFleet(t *testing.T) {
t.FailNow() t.FailNow()
} }
// Check is using the right fleet // Check is using the right fleet
require.Equal(t, b.config.ClusterConfig.WakuNodes, defaultWakuNodes[statusTestFleet]) require.Equal(t, b.config.ClusterConfig.WakuNodes, DefaultWakuNodes[statusTestFleet])
require.NoError(t, b.Logout()) require.NoError(t, b.Logout())
} }

View File

@ -20,6 +20,7 @@ const pathEIP1581 = "m/43'/60'/1581'"
const pathDefaultChat = pathEIP1581 + "/0'/0" const pathDefaultChat = pathEIP1581 + "/0'/0"
const pathDefaultWallet = pathWalletRoot + "/0" const pathDefaultWallet = pathWalletRoot + "/0"
const defaultMnemonicLength = 12 const defaultMnemonicLength = 12
const shardsTestClusterID = 16
const walletAccountDefaultName = "Ethereum account" const walletAccountDefaultName = "Ethereum account"
const keystoreRelativePath = "keystore" const keystoreRelativePath = "keystore"
const defaultKeycardPairingDataFile = "/ethereum/mainnet_rpc/keycard/pairings.json" const defaultKeycardPairingDataFile = "/ethereum/mainnet_rpc/keycard/pairings.json"
@ -34,7 +35,7 @@ const (
shardsTest = "shards.test" shardsTest = "shards.test"
) )
var defaultWakuNodes = map[string][]string{ var DefaultWakuNodes = map[string][]string{
statusProdFleet: []string{"enrtree://AL65EKLJAUXKKPG43HVTML5EFFWEZ7L4LOKTLZCLJASG4DSESQZEC@prod.status.nodes.status.im"}, statusProdFleet: []string{"enrtree://AL65EKLJAUXKKPG43HVTML5EFFWEZ7L4LOKTLZCLJASG4DSESQZEC@prod.status.nodes.status.im"},
statusTestFleet: []string{"enrtree://AIO6LUM3IVWCU2KCPBBI6FEH2W42IGK3ASCZHZGG5TIXUR56OGQUO@test.status.nodes.status.im"}, statusTestFleet: []string{"enrtree://AIO6LUM3IVWCU2KCPBBI6FEH2W42IGK3ASCZHZGG5TIXUR56OGQUO@test.status.nodes.status.im"},
wakuv2ProdFleet: []string{"enrtree://ANEDLO25QVUGJOUTQFRYKWX6P4Z4GKVESBMHML7DZ6YK4LGS5FC5O@prod.wakuv2.nodes.status.im"}, wakuv2ProdFleet: []string{"enrtree://ANEDLO25QVUGJOUTQFRYKWX6P4Z4GKVESBMHML7DZ6YK4LGS5FC5O@prod.wakuv2.nodes.status.im"},
@ -42,6 +43,8 @@ var defaultWakuNodes = map[string][]string{
shardsTest: []string{"enrtree://AMOJVZX4V6EXP7NTJPMAYJYST2QP6AJXYW76IU6VGJS7UVSNDYZG4@boot.test.shards.nodes.status.im"}, shardsTest: []string{"enrtree://AMOJVZX4V6EXP7NTJPMAYJYST2QP6AJXYW76IU6VGJS7UVSNDYZG4@boot.test.shards.nodes.status.im"},
} }
var DefaultFleet = shardsTest
func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*settings.Settings, error) { func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*settings.Settings, error) {
chatKeyString := derivedAddresses[pathDefaultChat].PublicKey chatKeyString := derivedAddresses[pathDefaultChat].PublicKey
@ -106,17 +109,32 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
} }
func SetDefaultFleet(nodeConfig *params.NodeConfig) error { func SetDefaultFleet(nodeConfig *params.NodeConfig) error {
return SetFleet(statusProdFleet, nodeConfig) return SetFleet(DefaultFleet, nodeConfig)
} }
func SetFleet(fleet string, nodeConfig *params.NodeConfig) error { func SetFleet(fleet string, nodeConfig *params.NodeConfig) error {
nodeConfig.WakuV2Config = params.WakuV2Config{
Enabled: true,
EnableDiscV5: true,
DiscoveryLimit: 20,
Host: "0.0.0.0",
AutoUpdate: true,
PeerExchange: true,
}
clusterConfig, err := params.LoadClusterConfigFromFleet(fleet) clusterConfig, err := params.LoadClusterConfigFromFleet(fleet)
if err != nil { if err != nil {
return err return err
} }
nodeConfig.ClusterConfig = *clusterConfig nodeConfig.ClusterConfig = *clusterConfig
nodeConfig.ClusterConfig.WakuNodes = defaultWakuNodes[fleet] nodeConfig.ClusterConfig.Fleet = fleet
nodeConfig.ClusterConfig.DiscV5BootstrapNodes = defaultWakuNodes[fleet] nodeConfig.ClusterConfig.WakuNodes = DefaultWakuNodes[fleet]
nodeConfig.ClusterConfig.DiscV5BootstrapNodes = DefaultWakuNodes[fleet]
if fleet == shardsTest {
nodeConfig.ClusterConfig.ClusterID = shardsTestClusterID
nodeConfig.WakuV2Config.UseShardAsDefaultTopic = true
}
return nil return nil
} }
@ -207,22 +225,13 @@ func defaultNodeConfig(installationID string, request *requests.CreateAccount) (
nodeConfig.PermissionsConfig = params.PermissionsConfig{Enabled: true} nodeConfig.PermissionsConfig = params.PermissionsConfig{Enabled: true}
nodeConfig.MailserversConfig = params.MailserversConfig{Enabled: true} nodeConfig.MailserversConfig = params.MailserversConfig{Enabled: true}
nodeConfig.ListenAddr = ":0"
err := SetDefaultFleet(nodeConfig) err := SetDefaultFleet(nodeConfig)
if err != nil { if err != nil {
return nil, err return nil, err
} }
nodeConfig.ListenAddr = ":0"
nodeConfig.WakuV2Config = params.WakuV2Config{
Enabled: true,
EnableDiscV5: true,
DiscoveryLimit: 20,
Host: "0.0.0.0",
AutoUpdate: true,
PeerExchange: true,
}
if request.WakuV2LightClient { if request.WakuV2LightClient {
nodeConfig.WakuV2Config.LightClient = true nodeConfig.WakuV2Config.LightClient = true
} }

View File

@ -630,7 +630,7 @@ func (b *GethStatusBackend) loginAccount(request *requests.Login) error {
var fleet string var fleet string
fleetPtr := settings.Fleet fleetPtr := settings.Fleet
if fleetPtr == nil || *fleetPtr == "" { if fleetPtr == nil || *fleetPtr == "" {
fleet = statusProdFleet fleet = DefaultFleet
} else { } else {
fleet = *fleetPtr fleet = *fleetPtr
} }

View File

@ -992,6 +992,24 @@ func GetPasswordStrengthScore(paramsJSON string) string {
return string(data) return string(data)
} }
type FleetDescription struct {
DefaultFleet string `json:"defaultFleet"`
Fleets map[string][]string `json:"fleets"`
}
func Fleets() string {
fleets := FleetDescription{
DefaultFleet: api.DefaultFleet,
Fleets: api.DefaultWakuNodes,
}
data, err := json.Marshal(fleets)
if err != nil {
return makeJSONResponse(fmt.Errorf("Error marshalling to json: %v", err))
}
return string(data)
}
func SwitchFleet(fleet string, configJSON string) string { func SwitchFleet(fleet string, configJSON string) string {
var conf params.NodeConfig var conf params.NodeConfig
if configJSON != "" { if configJSON != "" {