Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ce487ee
Initial commit of adding kad-dht/discovery
Eric-Warehime Aug 22, 2023
eac5f77
Add licenses
Eric-Warehime Aug 23, 2023
1f91286
Fix circular import in tests
Eric-Warehime Aug 23, 2023
eacd32b
Update bootstrap
Eric-Warehime Aug 28, 2023
b879a9d
partition test
Eric-Warehime Aug 28, 2023
26376d1
Add capabilities advertisement
Eric-Warehime Aug 28, 2023
998ad9e
Run initial advertisement immediately
Eric-Warehime Aug 28, 2023
4cb649c
Integrate capabilities retrieval
Eric-Warehime Aug 28, 2023
fb0b53d
Fix lint
Eric-Warehime Aug 28, 2023
dd79fb4
Refactor catchpoint storing capability
Eric-Warehime Aug 30, 2023
0f75566
Remove circular import
Eric-Warehime Aug 31, 2023
d8dfb52
Add test
Eric-Warehime Aug 31, 2023
0780dd5
Merge remote-tracking branch 'upstream/master' into introduce-dht
Eric-Warehime Aug 31, 2023
4071d55
Make tidy
Eric-Warehime Aug 31, 2023
a440359
Make generate
Eric-Warehime Aug 31, 2023
b0ac19b
Merge remote-tracking branch 'upstream/master' into introduce-dht
Eric-Warehime Aug 31, 2023
0e67a0b
p2p: peerstore backed phonebook (#5710)
shiqizng Aug 31, 2023
55f6430
docker: fix typo in README.md (#5707)
eltociear Aug 31, 2023
ade30a8
scripts(configure_dev): conditional tap homebrew (#5573)
emg110 Aug 31, 2023
3c77a7f
p2p: Return non-loopback multiaddr from Address() if available (#5716)
iansuvak Sep 1, 2023
b212f94
Feature: Disable EnableBlockServiceFallbackToArchiver by default. (#5…
gmalouf Sep 1, 2023
ba92ba3
merklearray: simplify single-leaf proofs (#5703)
zeldovich Sep 1, 2023
caf472a
p2p: Make p2p listen address configurable via config.NetAddress (#5721)
iansuvak Sep 1, 2023
4780a87
chore: fix misspelled filename (#5717)
bbroder-algo Sep 1, 2023
c4dfc1b
goal: Add export and import options for genesis files during network …
algochoi Sep 1, 2023
02b99bb
Simulate: Return application initial states accessed during simulatio…
ahangsu Sep 1, 2023
91c5b1c
Convert to addressTTL
Eric-Warehime Sep 1, 2023
c1bc2b6
Refactor catchpoint tracking logic into config
Eric-Warehime Sep 1, 2023
3e26bab
Add TracksCatchpoints
Eric-Warehime Sep 1, 2023
9bccbf2
Add partitiontest
Eric-Warehime Sep 5, 2023
0c6fd25
Add force catchpoint tracking comment to localTemplate
Eric-Warehime Sep 5, 2023
031f10f
Rename default values CatchpointTracking
Eric-Warehime Sep 5, 2023
9bc7474
Merge branch 'refactor-catchpoint-storing-config' into introduce-dht
Eric-Warehime Sep 5, 2023
3ddf71a
Fix listenAddr refactoring
Eric-Warehime Sep 5, 2023
11d0e67
Don't close ledger in node.Stop
Eric-Warehime Sep 5, 2023
eba2f75
Remove unused test
Eric-Warehime Sep 5, 2023
e5a8aec
Add tests, filter out self in capability peers
Eric-Warehime Sep 5, 2023
89ef9ab
Move forceCatchpointFileGenerationTrackingMode to internal logic
Eric-Warehime Sep 5, 2023
fa24be2
Merge branch 'refactor-catchpoint-storing-config' into introduce-dht
Eric-Warehime Sep 5, 2023
9481a1f
Add invalid addr dht bootstrap test
Eric-Warehime Sep 5, 2023
ee634b4
Avoid name conflict
Eric-Warehime Sep 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion catchup/universalFetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func TestUGetBlockHTTP(t *testing.T) {

blockServiceConfig := config.GetDefaultLocal()
blockServiceConfig.EnableBlockService = true
blockServiceConfig.EnableBlockServiceFallbackToArchiver = false

net := &httpTestPeerSource{}
ls := rpcs.MakeBlockService(logging.Base(), blockServiceConfig, ledger, net, "test genesisID")
Expand Down
98 changes: 96 additions & 2 deletions cmd/goal/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/algorand/go-algorand/cmd/util/datadir"
"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/gen"
"github.com/algorand/go-algorand/netdeploy"
"github.com/algorand/go-algorand/util"
)
Expand All @@ -40,26 +41,46 @@ var noImportKeys bool
var noClean bool
var devModeOverride bool
var startOnCreation bool
var pregenDir string

func init() {
networkCmd.AddCommand(networkCreateCmd)
networkCmd.PersistentFlags().StringVarP(&networkRootDir, "rootdir", "r", "", "Root directory for the private network directories")
networkCmd.MarkPersistentFlagRequired("rootdir")

networkCreateCmd.Flags().StringVarP(&networkName, "network", "n", "", "Specify the name to use for the private network")
networkCreateCmd.Flags().StringVarP(&networkTemplateFile, "template", "t", "", "Specify the path to the template file for the network")
networkCreateCmd.Flags().BoolVarP(&noImportKeys, "noimportkeys", "K", false, "Do not import root keys when creating the network (by default will import)")
networkCreateCmd.Flags().BoolVar(&noClean, "noclean", false, "Prevents auto-cleanup on error - for diagnosing problems")
networkCreateCmd.Flags().BoolVar(&devModeOverride, "devMode", false, "Forces the configuration to enable DevMode, returns an error if the template is not compatible with DevMode.")
networkCreateCmd.Flags().BoolVarP(&startOnCreation, "start", "s", false, "Automatically start the network after creating it.")
networkCreateCmd.Flags().StringVarP(&pregenDir, "pregendir", "p", "", "Specify the path to the directory with pregenerated genesis.json, root and partkeys to import into the network directory. By default, the genesis.json and keys will be generated on start. This should only be used on private networks.")
networkCreateCmd.MarkFlagRequired("rootdir")

networkCmd.AddCommand(networkStartCmd)
networkStartCmd.Flags().StringVarP(&startNode, "node", "n", "", "Specify the name of a specific node to start")
networkStartCmd.MarkFlagRequired("rootdir")

networkCmd.AddCommand(networkStartCmd)
networkCmd.AddCommand(networkRestartCmd)
networkRestartCmd.MarkFlagRequired("rootdir")

networkCmd.AddCommand(networkStopCmd)
networkStopCmd.MarkFlagRequired("rootdir")

networkCmd.AddCommand(networkStatusCmd)
networkStatusCmd.MarkFlagRequired("rootdir")

networkCmd.AddCommand(networkDeleteCmd)
networkDeleteCmd.MarkFlagRequired("rootdir")

networkCmd.AddCommand(networkPregenCmd)
networkPregenCmd.Flags().StringVarP(&networkTemplateFile, "template", "t", "", "Specify the path to the template file for the network")
networkPregenCmd.Flags().StringVarP(&pregenDir, "pregendir", "p", "", "Specify the path to the directory to export genesis.json, root and partkey files. This should only be used on private networks.")
networkPregenCmd.MarkFlagRequired("pregendir")
// Hide rootdir flag as it is unused and will error if used with this command.
networkPregenCmd.SetHelpFunc(func(command *cobra.Command, strings []string) {
_ = command.Flags().MarkHidden("rootdir")
command.Parent().HelpFunc()(command, strings)
})
}

var networkCmd = &cobra.Command{
Expand Down Expand Up @@ -112,6 +133,18 @@ var networkCreateCmd = &cobra.Command{
reportErrorf(infoNetworkAlreadyExists, networkRootDir)
}

// If pregendir is specified, copy files over
if pregenDir != "" {
pregenDir, err = filepath.Abs(pregenDir)
if err != nil {
panic(err)
}
err = util.CopyFolder(pregenDir, networkRootDir)
if err != nil {
panic(err)
}
}

binDir, err := util.ExeDir()
if err != nil {
panic(err)
Expand Down Expand Up @@ -246,3 +279,64 @@ var networkDeleteCmd = &cobra.Command{
reportInfof(infoNetworkDeleted, networkRootDir)
},
}

var networkPregenCmd = &cobra.Command{
Use: "pregen",
Short: "Pregenerates the genesis.json, root and participation keys for a wallet",
Args: validateNoPosArgsFn,
Run: func(cmd *cobra.Command, _ []string) {
var err error
if networkRootDir != "" {
reportErrorf("This command does not take a network directory as an argument. Use --pregendir flag instead.")
}

pregenDir, err = filepath.Abs(pregenDir)
if err != nil {
panic(err)
}

var templateReader io.Reader

if networkTemplateFile == "" {
templateReader = strings.NewReader(defaultNetworkTemplate)
} else {
networkTemplateFile, err = filepath.Abs(networkTemplateFile)
if err != nil {
panic(err)
}
file, osErr := os.Open(networkTemplateFile)
if osErr != nil {
reportErrorf(errorCreateNetwork, osErr)
}

defer file.Close()
templateReader = file
}

// Make sure target directory does not exist or is empty
if util.FileExists(pregenDir) && !util.IsEmpty(pregenDir) {
reportErrorf(infoNetworkAlreadyExists, pregenDir)
}

var template netdeploy.NetworkTemplate
err = netdeploy.LoadTemplateFromReader(templateReader, &template)
if err != nil {
reportErrorf("Error in loading template: %v\n", err)
}

dataDir := datadir.MaybeSingleDataDir()
var consensus config.ConsensusProtocols
if dataDir != "" {
// try to load the consensus from there. If there is none, we can just use the built in one.
consensus, _ = config.PreloadConfigurableConsensusProtocols(dataDir)
}
if err = template.Validate(); err != nil {
reportErrorf("Error in template validation: %v\n", err)
}

err = gen.GenerateGenesisFiles(template.Genesis, config.Consensus.Merge(consensus), pregenDir, os.Stdout)
if err != nil {
reportErrorf("Cannot write genesis files: %s", err)
}
},
}
15 changes: 15 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ const MaxGenesisIDLen = 128
// MaxEvalDeltaTotalLogSize is the maximum size of the sum of all log sizes in a single eval delta.
const MaxEvalDeltaTotalLogSize = 1024

// CatchpointTrackingModeUntracked defines the CatchpointTracking mode that does _not_ track catchpoints
const CatchpointTrackingModeUntracked = -1

// CatchpointTrackingModeAutomatic defines the CatchpointTracking mode that automatically determines catchpoint tracking
// and storage based on the Archival property and CatchpointInterval.
const CatchpointTrackingModeAutomatic = 0

// CatchpointTrackingModeTracked defines the CatchpointTracking mode that tracks catchpoint
// as long as CatchpointInterval > 0
const CatchpointTrackingModeTracked = 1

// CatchpointTrackingModeStored defines the CatchpointTracking mode that tracks and stores catchpoints
// as long as CatchpointInterval > 0
const CatchpointTrackingModeStored = 2

// LoadConfigFromDisk returns a Local config structure based on merging the defaults
// with settings loaded from the config file from the custom dir. If the custom file
// cannot be loaded, the default config is returned (with the error from loading the
Expand Down
126 changes: 126 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,3 +803,129 @@ func TestResolveLogPaths(t *testing.T) {
require.Equal(t, "mycoolLogDir/node.log", log)
require.Equal(t, "myCoolLogArchive/node.archive.log", archive)
}

func TestStoresCatchpoints(t *testing.T) {
partitiontest.PartitionTest(t)

var tests = []struct {
name string
catchpointTracking int64
catchpointInterval uint64
archival bool
expected bool
}{
{
name: "-1 w/ no catchpoint interval expects false",
catchpointTracking: CatchpointTrackingModeUntracked,
catchpointInterval: 0,
expected: false,
},
{
name: "-1 expects false",
catchpointTracking: CatchpointTrackingModeUntracked,
catchpointInterval: GetDefaultLocal().CatchpointInterval,
archival: GetDefaultLocal().Archival,
expected: false,
},
{
name: "0 expects false",
catchpointTracking: CatchpointTrackingModeAutomatic,
catchpointInterval: GetDefaultLocal().CatchpointInterval,
archival: GetDefaultLocal().Archival,
expected: false,
},
{
name: "0 w/ archival expects true",
catchpointTracking: CatchpointTrackingModeAutomatic,
catchpointInterval: GetDefaultLocal().CatchpointInterval,
archival: true,
expected: true,
},
{
name: "0 w/ archival & catchpointInterval=0 expects false",
catchpointTracking: CatchpointTrackingModeAutomatic,
catchpointInterval: 0,
archival: true,
expected: false,
},
{
name: "1 expects false",
catchpointTracking: CatchpointTrackingModeTracked,
catchpointInterval: GetDefaultLocal().CatchpointInterval,
archival: GetDefaultLocal().Archival,
expected: false,
},
{
name: "1 w/ archival expects true",
catchpointTracking: CatchpointTrackingModeTracked,
catchpointInterval: GetDefaultLocal().CatchpointInterval,
archival: true,
expected: true,
},
{
name: "1 w/ archival & catchpointInterval=0 expects false",
catchpointTracking: CatchpointTrackingModeTracked,
catchpointInterval: 0,
archival: true,
expected: false,
},
{
name: "2 w/ catchpointInterval=0 expects false",
catchpointTracking: CatchpointTrackingModeStored,
catchpointInterval: 0,
archival: GetDefaultLocal().Archival,
expected: false,
},
{
name: "2 expects true",
catchpointTracking: CatchpointTrackingModeStored,
catchpointInterval: GetDefaultLocal().CatchpointInterval,
archival: GetDefaultLocal().Archival,
expected: true,
},
{
name: "99 expects false",
catchpointTracking: 99,
catchpointInterval: GetDefaultLocal().CatchpointInterval,
archival: GetDefaultLocal().Archival,
expected: false,
},
{
name: "99 w/ catchpointInterval=0 expects false",
catchpointTracking: 99,
catchpointInterval: 0,
archival: GetDefaultLocal().Archival,
expected: false,
},
{
name: "27 expects false",
catchpointTracking: 27,
catchpointInterval: GetDefaultLocal().CatchpointInterval,
archival: GetDefaultLocal().Archival,
expected: false,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
cfg := GetDefaultLocal()
cfg.CatchpointTracking = test.catchpointTracking
cfg.CatchpointInterval = test.catchpointInterval
cfg.Archival = test.archival
require.Equal(t, test.expected, cfg.StoresCatchpoints())
if cfg.StoresCatchpoints() {
require.Equal(t, true, cfg.TracksCatchpoints())
}
})
}
}

func TestTracksCatchpointsWithoutStoring(t *testing.T) {
partitiontest.PartitionTest(t)

cfg := GetDefaultLocal()
cfg.CatchpointTracking = CatchpointTrackingModeTracked
cfg.CatchpointInterval = 10000
cfg.Archival = false
require.Equal(t, true, cfg.TracksCatchpoints())
require.Equal(t, false, cfg.StoresCatchpoints())
}
38 changes: 36 additions & 2 deletions config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ type Local struct {
// A value of 1 means "track catchpoints as long as CatchpointInterval > 0".
// A value of 2 means "track catchpoints and always generate catchpoint files as long as CatchpointInterval > 0".
// A value of 0 means automatic, which is the default value. In this mode, a non archival node would not track the catchpoints, and an archival node would track the catchpoints as long as CatchpointInterval > 0.
// Other values of CatchpointTracking would give a warning in the log file, and would behave as if the default value was provided.
// Other values of CatchpointTracking would behave as if the default value was provided.
CatchpointTracking int64 `version[11]:"0"`

// LedgerSynchronousMode defines the synchronous mode used by the ledger database. The supported options are:
Expand Down Expand Up @@ -440,7 +440,7 @@ type Local struct {
// an archiver or return StatusNotFound (404) when in does not have the requested round, and
// BlockServiceCustomFallbackEndpoints is empty.
// The archiver is randomly selected, if none is available, will return StatusNotFound (404).
EnableBlockServiceFallbackToArchiver bool `version[16]:"true"`
EnableBlockServiceFallbackToArchiver bool `version[16]:"true" version[31]:"false"`

// CatchupBlockValidateMode is a development and testing configuration used by the catchup service.
// It can be used to omit certain validations to speed up the catchup process, or to apply extra validations which are redundant in normal operation.
Expand Down Expand Up @@ -581,6 +581,9 @@ type Local struct {

// DisableAPIAuth turns off authentication for public (non-admin) API endpoints.
DisableAPIAuth bool `version[30]:"false"`

// EnableDHT will turn on the hash table for use with capabilities advertisement
EnableDHTProviders bool `version[30]:"false"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v31

}

// DNSBootstrapArray returns an array of one or more DNS Bootstrap identifiers
Expand Down Expand Up @@ -862,3 +865,34 @@ func (cfg *Local) AdjustConnectionLimits(requiredFDs, maxFDs uint64) bool {

return true
}

// StoresCatchpoints returns true if the node is configured to store catchpoints
func (cfg *Local) StoresCatchpoints() bool {
if cfg.CatchpointInterval <= 0 {
return false
}
switch cfg.CatchpointTracking {
case CatchpointTrackingModeUntracked:
// No catchpoints.
default:
fallthrough
case CatchpointTrackingModeAutomatic, CatchpointTrackingModeTracked:
if cfg.Archival {
return true
}
Comment thread
Eric-Warehime marked this conversation as resolved.
case CatchpointTrackingModeStored:
return true
}
return false
}

// TracksCatchpoints returns true if the node is configured to track catchpoints
func (cfg *Local) TracksCatchpoints() bool {
if cfg.StoresCatchpoints() {
return true
}
if cfg.CatchpointTracking == CatchpointTrackingModeTracked && cfg.CatchpointInterval > 0 {
return true
}
return false
}
3 changes: 2 additions & 1 deletion config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ var defaultLocal = Local{
EnableAgreementTimeMetrics: false,
EnableAssembleStats: false,
EnableBlockService: false,
EnableBlockServiceFallbackToArchiver: true,
EnableBlockServiceFallbackToArchiver: false,
EnableCatchupFromArchiveServers: false,
EnableDHTProviders: false,
EnableDeveloperAPI: false,
EnableExperimentalAPI: false,
EnableFollowMode: false,
Expand Down
Loading