Skip to content

Commit

Permalink
transaction sync (#2718)
Browse files Browse the repository at this point in the history
## Summary

This PR implements the transaction sync 2.0.

More details can be found in the design document and the feature presentation .

## Test Plan

Unit tests, e2e tests and performance tests were executed against this branch successfully.

## Reviewer notes

This PR is pretty large. Consider reviewing it in browsers other than Safari.
  • Loading branch information
tsachiherman authored Oct 4, 2021
1 parent f17f73e commit 69aace5
Show file tree
Hide file tree
Showing 193 changed files with 70,163 additions and 506 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GOLDFLAGS := $(GOLDFLAGS_BASE) \
UNIT_TEST_SOURCES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && go list ./... | grep -v /go-algorand/test/ ))
ALGOD_API_PACKAGES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && cd daemon/algod/api; go list ./... ))

MSGP_GENERATE := ./protocol ./protocol/test ./crypto ./crypto/compactcert ./data/basics ./data/transactions ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./node ./ledger ./ledger/ledgercore ./compactcert
MSGP_GENERATE := ./protocol ./protocol/test ./crypto ./crypto/compactcert ./data/basics ./data/transactions ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./node ./ledger ./ledger/ledgercore ./compactcert ./txnsync ./data/pooldata

default: build

Expand Down
6 changes: 5 additions & 1 deletion catchup/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,11 @@ func (p *testUnicastPeer) Version() string {
return p.version
}

func (p *testUnicastPeer) Unicast(ctx context.Context, msg []byte, tag protocol.Tag) error {
func (p *testUnicastPeer) IsOutgoing() bool {
return false
}

func (p *testUnicastPeer) Unicast(ctx context.Context, msg []byte, tag protocol.Tag, callback network.UnicastWebsocketMessageStateCallback) error {
ps := p.gn.(*httpTestPeerSource)
var dispather network.MessageHandler
for _, v := range ps.dispatchHandlers {
Expand Down
5 changes: 4 additions & 1 deletion catchup/peerSelector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type mockUnicastPeer struct {
func (d *mockUnicastPeer) GetAddress() string {
return d.address
}
func (d *mockUnicastPeer) Unicast(ctx context.Context, data []byte, tag protocol.Tag) error {
func (d *mockUnicastPeer) Unicast(ctx context.Context, msg []byte, tag protocol.Tag, callback network.UnicastWebsocketMessageStateCallback) error {
return nil
}
func (d *mockUnicastPeer) Version() string {
Expand All @@ -62,6 +62,9 @@ func (d *mockUnicastPeer) Request(ctx context.Context, tag network.Tag, topics n
func (d *mockUnicastPeer) Respond(ctx context.Context, reqMsg network.IncomingMessage, topics network.Topics) (e error) {
return nil
}
func (d *mockUnicastPeer) IsOutgoing() bool {
return false
}

func TestPeerAddress(t *testing.T) {
partitiontest.PartitionTest(t)
Expand Down
25 changes: 23 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Local struct {
// Version tracks the current version of the defaults so we can migrate old -> new
// This is specifically important whenever we decide to change the default value
// for an existing parameter. This field tag must be updated any time we add a new version.
Version uint32 `version[0]:"0" version[1]:"1" version[2]:"2" version[3]:"3" version[4]:"4" version[5]:"5" version[6]:"6" version[7]:"7" version[8]:"8" version[9]:"9" version[10]:"10" version[11]:"11" version[12]:"12" version[13]:"13" version[14]:"14" version[15]:"15" version[16]:"16"`
Version uint32 `version[0]:"0" version[1]:"1" version[2]:"2" version[3]:"3" version[4]:"4" version[5]:"5" version[6]:"6" version[7]:"7" version[8]:"8" version[9]:"9" version[10]:"10" version[11]:"11" version[12]:"12" version[13]:"13" version[14]:"14" version[15]:"15" version[16]:"16" version[17]:"17"`

// environmental (may be overridden)
// When enabled, stores blocks indefinitally, otherwise, only the most recents blocks
Expand Down Expand Up @@ -97,7 +97,8 @@ type Local struct {

// IncomingConnectionsLimit specifies the max number of long-lived incoming
// connections. 0 means no connections allowed. -1 is unbounded.
IncomingConnectionsLimit int `version[0]:"-1" version[1]:"10000"`
// Estimating 5MB per incoming connection, 5MB*800 = 4GB
IncomingConnectionsLimit int `version[0]:"-1" version[1]:"10000" version[17]:"800"`

// BroadcastConnectionsLimit specifies the number of connections that
// will receive broadcast (gossip) messages from this node. If the
Expand Down Expand Up @@ -418,6 +419,26 @@ type Local struct {
// features like catchpoint catchup would be rendered completly non-operational, and many of the node inner
// working would be completly dis-functional.
DisableNetworking bool `version[16]:"false"`

// ForceFetchTransactions allows to explicitly configure a node to retrieve all the transactions
// into it's transaction pool, even if those would not be required as the node doesn't
// participate in the consensus or used to relay transactions.
ForceFetchTransactions bool `version[17]:"false"`

// EnableVerbosedTransactionSyncLogging enables the transaction sync to write extensive
// message exchange information to the log file. This option is disabled by default,
// so that the log files would not grow too rapidly.
EnableVerbosedTransactionSyncLogging bool `version[17]:"false"`

// TransactionSyncDataExchangeRate overrides the auto-calculated data exchange rate between each
// two peers. The unit of the data exchange rate is in bytes per second. Setting the value to
// zero implies allowing the transaction sync to dynamically calculate the value.
TransactionSyncDataExchangeRate uint64 `version[17]:"0"`

// TransactionSyncSignificantMessageThreshold define the threshold used for a transaction sync
// message before it can be used for calculating the data exchange rate. Setting this to zero
// would use the default values. The threshold is defined in units of bytes.
TransactionSyncSignificantMessageThreshold uint64 `version[17]:"0"`
}

// Filenames of config files within the configdir (e.g. ~/.algorand)
Expand Down
184 changes: 94 additions & 90 deletions config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,94 +20,98 @@
package config

var defaultLocal = Local{
Version: 16,
AccountUpdatesStatsInterval: 5000000000,
AccountsRebuildSynchronousMode: 1,
AnnounceParticipationKey: true,
Archival: false,
BaseLoggerDebugLevel: 4,
BlockServiceCustomFallbackEndpoints: "",
BroadcastConnectionsLimit: -1,
CadaverSizeTarget: 1073741824,
CatchpointFileHistoryLength: 365,
CatchpointInterval: 10000,
CatchpointTracking: 0,
CatchupBlockDownloadRetryAttempts: 1000,
CatchupBlockValidateMode: 0,
CatchupFailurePeerRefreshRate: 10,
CatchupGossipBlockFetchTimeoutSec: 4,
CatchupHTTPBlockFetchTimeoutSec: 4,
CatchupLedgerDownloadRetryAttempts: 50,
CatchupParallelBlocks: 16,
ConnectionsRateLimitingCount: 60,
ConnectionsRateLimitingWindowSeconds: 1,
DNSBootstrapID: "<network>.algorand.network",
DNSSecurityFlags: 1,
DeadlockDetection: 0,
DisableLocalhostConnectionRateLimit: true,
DisableNetworking: false,
DisableOutgoingConnectionThrottling: false,
EnableAccountUpdatesStats: false,
EnableAgreementReporting: false,
EnableAgreementTimeMetrics: false,
EnableAssembleStats: false,
EnableBlockService: false,
EnableBlockServiceFallbackToArchiver: true,
EnableCatchupFromArchiveServers: false,
EnableDeveloperAPI: false,
EnableGossipBlockService: true,
EnableIncomingMessageFilter: false,
EnableLedgerService: false,
EnableMetricReporting: false,
EnableOutgoingNetworkMessageFiltering: true,
EnablePingHandler: true,
EnableProcessBlockStats: false,
EnableProfiler: false,
EnableRequestLogger: false,
EnableTopAccountsReporting: false,
EndpointAddress: "127.0.0.1:0",
FallbackDNSResolverAddress: "",
ForceRelayMessages: false,
GossipFanout: 4,
IncomingConnectionsLimit: 10000,
IncomingMessageFilterBucketCount: 5,
IncomingMessageFilterBucketSize: 512,
IsIndexerActive: false,
LedgerSynchronousMode: 2,
LogArchiveMaxAge: "",
LogArchiveName: "node.archive.log",
LogSizeLimit: 1073741824,
MaxCatchpointDownloadDuration: 7200000000000,
MaxConnectionsPerIP: 30,
MinCatchpointFileDownloadBytesPerSecond: 20480,
NetAddress: "",
NetworkMessageTraceServer: "",
NetworkProtocolVersion: "",
NodeExporterListenAddress: ":9100",
NodeExporterPath: "./node_exporter",
OptimizeAccountsDatabaseOnStartup: false,
OutgoingMessageFilterBucketCount: 3,
OutgoingMessageFilterBucketSize: 128,
ParticipationKeysRefreshInterval: 60000000000,
PeerConnectionsUpdateInterval: 3600,
PeerPingPeriodSeconds: 0,
PriorityPeers: map[string]bool{},
PublicAddress: "",
ReconnectTime: 60000000000,
ReservedFDs: 256,
RestReadTimeoutSeconds: 15,
RestWriteTimeoutSeconds: 120,
RunHosted: false,
SuggestedFeeBlockHistory: 3,
SuggestedFeeSlidingWindowSize: 50,
TLSCertFile: "",
TLSKeyFile: "",
TelemetryToLog: true,
TxPoolExponentialIncreaseFactor: 2,
TxPoolSize: 15000,
TxSyncIntervalSeconds: 60,
TxSyncServeResponseSize: 1000000,
TxSyncTimeoutSeconds: 30,
UseXForwardedForAddressField: "",
VerifiedTranscationsCacheSize: 30000,
Version: 17,
AccountUpdatesStatsInterval: 5000000000,
AccountsRebuildSynchronousMode: 1,
AnnounceParticipationKey: true,
Archival: false,
BaseLoggerDebugLevel: 4,
BlockServiceCustomFallbackEndpoints: "",
BroadcastConnectionsLimit: -1,
CadaverSizeTarget: 1073741824,
CatchpointFileHistoryLength: 365,
CatchpointInterval: 10000,
CatchpointTracking: 0,
CatchupBlockDownloadRetryAttempts: 1000,
CatchupBlockValidateMode: 0,
CatchupFailurePeerRefreshRate: 10,
CatchupGossipBlockFetchTimeoutSec: 4,
CatchupHTTPBlockFetchTimeoutSec: 4,
CatchupLedgerDownloadRetryAttempts: 50,
CatchupParallelBlocks: 16,
ConnectionsRateLimitingCount: 60,
ConnectionsRateLimitingWindowSeconds: 1,
DNSBootstrapID: "<network>.algorand.network",
DNSSecurityFlags: 1,
DeadlockDetection: 0,
DisableLocalhostConnectionRateLimit: true,
DisableNetworking: false,
DisableOutgoingConnectionThrottling: false,
EnableAccountUpdatesStats: false,
EnableAgreementReporting: false,
EnableAgreementTimeMetrics: false,
EnableAssembleStats: false,
EnableBlockService: false,
EnableBlockServiceFallbackToArchiver: true,
EnableCatchupFromArchiveServers: false,
EnableDeveloperAPI: false,
EnableGossipBlockService: true,
EnableIncomingMessageFilter: false,
EnableLedgerService: false,
EnableMetricReporting: false,
EnableOutgoingNetworkMessageFiltering: true,
EnablePingHandler: true,
EnableProcessBlockStats: false,
EnableProfiler: false,
EnableRequestLogger: false,
EnableTopAccountsReporting: false,
EnableVerbosedTransactionSyncLogging: false,
EndpointAddress: "127.0.0.1:0",
FallbackDNSResolverAddress: "",
ForceFetchTransactions: false,
ForceRelayMessages: false,
GossipFanout: 4,
IncomingConnectionsLimit: 800,
IncomingMessageFilterBucketCount: 5,
IncomingMessageFilterBucketSize: 512,
IsIndexerActive: false,
LedgerSynchronousMode: 2,
LogArchiveMaxAge: "",
LogArchiveName: "node.archive.log",
LogSizeLimit: 1073741824,
MaxCatchpointDownloadDuration: 7200000000000,
MaxConnectionsPerIP: 30,
MinCatchpointFileDownloadBytesPerSecond: 20480,
NetAddress: "",
NetworkMessageTraceServer: "",
NetworkProtocolVersion: "",
NodeExporterListenAddress: ":9100",
NodeExporterPath: "./node_exporter",
OptimizeAccountsDatabaseOnStartup: false,
OutgoingMessageFilterBucketCount: 3,
OutgoingMessageFilterBucketSize: 128,
ParticipationKeysRefreshInterval: 60000000000,
PeerConnectionsUpdateInterval: 3600,
PeerPingPeriodSeconds: 0,
PriorityPeers: map[string]bool{},
PublicAddress: "",
ReconnectTime: 60000000000,
ReservedFDs: 256,
RestReadTimeoutSeconds: 15,
RestWriteTimeoutSeconds: 120,
RunHosted: false,
SuggestedFeeBlockHistory: 3,
SuggestedFeeSlidingWindowSize: 50,
TLSCertFile: "",
TLSKeyFile: "",
TelemetryToLog: true,
TransactionSyncDataExchangeRate: 0,
TransactionSyncSignificantMessageThreshold: 0,
TxPoolExponentialIncreaseFactor: 2,
TxPoolSize: 15000,
TxSyncIntervalSeconds: 60,
TxSyncServeResponseSize: 1000000,
TxSyncTimeoutSeconds: 30,
UseXForwardedForAddressField: "",
VerifiedTranscationsCacheSize: 30000,
}
2 changes: 1 addition & 1 deletion crypto/compactcert/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,5 @@ func numReveals(signedWeight uint64, provenWeight uint64, secKQ uint64, bound ui
}

func (p Params) numReveals(signedWeight uint64) (uint64, error) {
return numReveals(signedWeight, p.ProvenWeight, p.SecKQ, maxReveals)
return numReveals(signedWeight, p.ProvenWeight, p.SecKQ, MaxReveals)
}
24 changes: 12 additions & 12 deletions crypto/compactcert/msgp_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions crypto/compactcert/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,25 @@ type Reveal struct {
Part Participant `codec:"p"`
}

// maxReveals is a bound on allocation and on numReveals to limit log computation
const maxReveals = 1024
const maxProofDigests = 20 * maxReveals
// MaxReveals is a bound on allocation and on numReveals to limit log computation
const MaxReveals = 1024

// MaxProofDigests is a bound on allocation on number of proofs
const MaxProofDigests = 20 * MaxReveals

// Cert represents a compact certificate.
type Cert struct {
_struct struct{} `codec:",omitempty,omitemptyarray"`

SigCommit crypto.Digest `codec:"c"`
SignedWeight uint64 `codec:"w"`
SigProofs []crypto.Digest `codec:"S,allocbound=maxProofDigests"`
PartProofs []crypto.Digest `codec:"P,allocbound=maxProofDigests"`
SigProofs []crypto.Digest `codec:"S,allocbound=MaxProofDigests"`
PartProofs []crypto.Digest `codec:"P,allocbound=MaxProofDigests"`

// Reveals is a sparse map from the position being revealed
// to the corresponding elements from the sigs and participants
// arrays.
Reveals map[uint64]Reveal `codec:"r,allocbound=maxReveals"`
Reveals map[uint64]Reveal `codec:"r,allocbound=MaxReveals"`
}

// SortUint64 implements sorting by uint64 keys for
Expand Down
Loading

0 comments on commit 69aace5

Please sign in to comment.