Skip to content

Commit

Permalink
param rename
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed May 15, 2024
1 parent 435e0e0 commit 3603b27
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion block/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestInitialState(t *testing.T) {
p2pClient, err := p2p.NewClient(config.P2PConfig{
ListenAddress: config.DefaultListenAddress,
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
}, privKey, "TestChain", pubsubServer, logger)
assert.NoError(err)
assert.NotNil(p2pClient)
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func fullNodeConfig() config.NodeConfig {
},
P2PConfig: config.P2PConfig{
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
ListenAddress: config.DefaultListenAddress,
BootstrapNodes: "",
},
Expand Down
2 changes: 1 addition & 1 deletion config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func DefaultConfig(home, chainId string) *NodeConfig {
},
P2PConfig: P2PConfig{
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
ListenAddress: DefaultListenAddress,
BootstrapNodes: "",
},
Expand Down
12 changes: 6 additions & 6 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const (
)

const (
FlagP2PListenAddress = "dymint.p2p_config.listen_address"
FlagP2PBootstrapNodes = "dymint.p2p_config.bootstrap_nodes"
FlagP2PGossipCacheSize = "dymint.p2p_config.gossip_cache_size"
FlagP2PBootstrapTime = "dymint.p2p_config.bootstrap_time"
FlagP2PListenAddress = "dymint.p2p_config.listen_address"
FlagP2PBootstrapNodes = "dymint.p2p_config.bootstrap_nodes"
FlagP2PGossipCacheSize = "dymint.p2p_config.gossip_cache_size"
FlagP2PBootstrapRetryTime = "dymint.p2p_config.bootstrap_retry_time"
)

// AddNodeFlags adds Dymint specific configuration options to cobra Command.
Expand Down Expand Up @@ -64,7 +64,7 @@ func AddNodeFlags(cmd *cobra.Command) {

cmd.Flags().String(FlagP2PListenAddress, def.P2PConfig.ListenAddress, "P2P listen address")
cmd.Flags().String(FlagP2PBootstrapNodes, def.P2PConfig.BootstrapNodes, "P2P bootstrap nodes")
cmd.Flags().Duration(FlagP2PBootstrapTime, def.P2PConfig.BootstrapTime, "P2P bootstrap time")
cmd.Flags().Duration(FlagP2PBootstrapRetryTime, def.P2PConfig.BootstrapRetryTime, "P2P bootstrap time")
cmd.Flags().Uint64(FlagP2PGossipCacheSize, uint64(def.P2PConfig.GossipedBlocksCacheSize), "P2P Gossiped blocks cache size")

}
Expand Down Expand Up @@ -124,7 +124,7 @@ func BindDymintFlags(cmd *cobra.Command, v *viper.Viper) error {
if err := v.BindPFlag("p2p_gossiped_blocks_cache_size", cmd.Flags().Lookup(FlagP2PGossipCacheSize)); err != nil {
return err
}
if err := v.BindPFlag("p2p_bootstrap_time", cmd.Flags().Lookup(FlagP2PBootstrapTime)); err != nil {
if err := v.BindPFlag("p2p_bootstrap_retry_time", cmd.Flags().Lookup(FlagP2PBootstrapRetryTime)); err != nil {
return err
}
if err := v.BindPFlag("p2p_bootstrap_nodes", cmd.Flags().Lookup(FlagP2PBootstrapNodes)); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions config/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ type P2PConfig struct {
//Size of the Gossipsub router cache
GossipedBlocksCacheSize int `mapstructure:"p2p_gossiped_blocks_cache_size"`
//Time interval a node tries to bootstrap again, in case no nodes connected
BootstrapTime time.Duration `mapstructure:"p2p_bootstrap_time"`
BootstrapRetryTime time.Duration `mapstructure:"p2p_bootstrap_retry_time"`
}

// Validate P2PConfig
func (c P2PConfig) Validate() error {
if c.GossipedBlocksCacheSize < 0 {
return fmt.Errorf("gossipsub cache size cannot be negative")
}
if c.BootstrapTime <= 0 {
if c.BootstrapRetryTime <= 0 {
return fmt.Errorf("bootstrap time must be positive")
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ p2p_bootstrap_nodes = "{{ .P2PConfig.BootstrapNodes }}"
p2p_gossiped_blocks_cache_size = {{ .P2PConfig.GossipedBlocksCacheSize }}
# time interval to check if no p2p nodes are connected to bootstrap again
p2p_bootstrap_time = "{{ .P2PConfig.BootstrapTime }}"
p2p_bootstrap_retry_time = "{{ .P2PConfig.BootstrapRetryTime }}"
#celestia config example:
# da_config = "{\"base_url\":\"http:\/\/127.0.0.1:26658\",\"timeout\":5000000000,\"gas_prices\":0.1,\"auth_token\":\"TOKEN\",\"backoff\":{\"initial_delay\":6000000000,\"max_delay\":6000000000,\"growth_factor\":2},\"retry_attempts\":4,\"retry_delay\":3000000000}"
Expand Down
2 changes: 1 addition & 1 deletion node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestMempoolDirectly(t *testing.T) {
P2PConfig: config.P2PConfig{
ListenAddress: config.DefaultListenAddress,
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
BootstrapNodes: "",
},
RPC: config.RPCConfig{},
Expand Down
2 changes: 1 addition & 1 deletion p2p/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func (c *Client) gossipedBlockReceived(msg *GossipMessage) {
}

func (c *Client) bootstrapLoop(ctx context.Context) {
ticker := time.NewTicker(c.conf.BootstrapTime)
ticker := time.NewTicker(c.conf.BootstrapRetryTime)
defer ticker.Stop()
for {
select {
Expand Down
4 changes: 2 additions & 2 deletions p2p/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestClientStartup(t *testing.T) {
client, err := p2p.NewClient(config.P2PConfig{
ListenAddress: config.DefaultListenAddress,
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
}, privKey, "TestChain", pubsubServer, log.TestingLogger())
assert := assert.New(t)
assert.NoError(err)
Expand Down Expand Up @@ -180,7 +180,7 @@ func TestSeedStringParsing(t *testing.T) {
logger := &testutil.MockLogger{}
client, err := p2p.NewClient(config.P2PConfig{
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
}, privKey, "TestNetwork", pubsubServer, logger)
require.NoError(err)
require.NotNil(client)
Expand Down
10 changes: 5 additions & 5 deletions rpc/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestGenesisChunked(t *testing.T) {
ListenAddress: config.DefaultListenAddress,
BootstrapNodes: "",
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
},
RPC: config.RPCConfig{},
BlockManagerConfig: config.BlockManagerConfig{
Expand Down Expand Up @@ -707,7 +707,7 @@ func TestValidatorSetHandling(t *testing.T) {
ListenAddress: config.DefaultListenAddress,
BootstrapNodes: "",
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
},
BlockManagerConfig: config.BlockManagerConfig{
BlockTime: 10 * time.Millisecond,
Expand Down Expand Up @@ -864,7 +864,7 @@ func getRPCInternal(t *testing.T, sequencer bool) (*tmmocks.MockApplication, *cl
ListenAddress: config.DefaultListenAddress,
BootstrapNodes: "",
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
},
RPC: config.RPCConfig{},
MempoolConfig: *tmcfg.DefaultMempoolConfig(),
Expand Down Expand Up @@ -975,7 +975,7 @@ func TestMempool2Nodes(t *testing.T) {
ListenAddress: "/ip4/127.0.0.1/tcp/9001",
BootstrapNodes: "",
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
},
BlockManagerConfig: config.BlockManagerConfig{
BlockTime: 100 * time.Millisecond,
Expand Down Expand Up @@ -1004,7 +1004,7 @@ func TestMempool2Nodes(t *testing.T) {
P2PConfig: config.P2PConfig{
ListenAddress: "/ip4/127.0.0.1/tcp/9002",
BootstrapNodes: "/ip4/127.0.0.1/tcp/9001/p2p/" + id1.String(),
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
GossipedBlocksCacheSize: 50,
},
MempoolConfig: *tmcfg.DefaultMempoolConfig(),
Expand Down
2 changes: 1 addition & 1 deletion rpc/json/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func getRPC(t *testing.T) (*tmmocks.MockApplication, *client.Client) {
P2PConfig: config.P2PConfig{
ListenAddress: config.DefaultListenAddress,
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
},
}
node, err := node.NewNode(
Expand Down
2 changes: 1 addition & 1 deletion testutil/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func GetManagerWithProposerKey(conf config.BlockManagerConfig, proposerKey crypt
p2pKey, _, _ := crypto.GenerateEd25519Key(rand.Reader)
p2pClient, err := p2p.NewClient(config.P2PConfig{
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
}, p2pKey, "TestChain", pubsubServer, logger)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion testutil/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func StartTestNetwork(ctx context.Context, t *testing.T, n int, conf map[int]Hos
client, err := p2p.NewClient(config.P2PConfig{
BootstrapNodes: seeds[i],
GossipedBlocksCacheSize: 50,
BootstrapTime: 30 * time.Second,
BootstrapRetryTime: 30 * time.Second,
ListenAddress: config.DefaultListenAddress,
},
mnet.Hosts()[i].Peerstore().PrivKey(mnet.Hosts()[i].ID()),
Expand Down

0 comments on commit 3603b27

Please sign in to comment.