Skip to content

Commit

Permalink
Merge branch 'master' into relbeta3.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Algo-devops-service committed Sep 30, 2022
2 parents 3e02f51 + d389196 commit 82bf931
Show file tree
Hide file tree
Showing 56 changed files with 14,230 additions and 970 deletions.
455 changes: 229 additions & 226 deletions .circleci/config.yml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions agreement/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func (a ensureAction) do(ctx context.Context, s *Service) {
Hash: a.Certificate.Proposal.BlockDigest.String(),
Round: uint64(a.Certificate.Round),
ValidatedAt: a.Payload.validatedAt,
ReceivedAt: a.Payload.receivedAt,
PreValidated: true,
PropBufLen: uint64(len(s.demux.rawProposals)),
VoteBufLen: uint64(len(s.demux.rawVotes)),
Expand All @@ -250,6 +251,7 @@ func (a ensureAction) do(ctx context.Context, s *Service) {
Hash: a.Certificate.Proposal.BlockDigest.String(),
Round: uint64(a.Certificate.Round),
ValidatedAt: a.Payload.validatedAt,
ReceivedAt: a.Payload.receivedAt,
PreValidated: false,
PropBufLen: uint64(len(s.demux.rawProposals)),
VoteBufLen: uint64(len(s.demux.rawVotes)),
Expand Down
5 changes: 4 additions & 1 deletion agreement/demux.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ func (d *demux) next(s *Service, deadline time.Duration, fastDeadline time.Durat
proto, err := d.ledger.ConsensusVersion(ParamsRound(e.ConsensusRound()))
e = e.AttachConsensusVersion(ConsensusVersionView{Err: makeSerErr(err), Version: proto})

if e.t() == payloadVerified {
switch e.t() {
case payloadVerified:
e = e.(messageEvent).AttachValidatedAt(s.Clock.Since())
case payloadPresent:
e = e.(messageEvent).AttachReceivedAt(s.Clock.Since())
}
}()

Expand Down
5 changes: 5 additions & 0 deletions agreement/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -938,3 +938,8 @@ func (e messageEvent) AttachValidatedAt(d time.Duration) messageEvent {
e.Input.Proposal.validatedAt = d
return e
}

func (e messageEvent) AttachReceivedAt(d time.Duration) messageEvent {
e.Input.Proposal.receivedAt = d
return e
}
58 changes: 29 additions & 29 deletions agreement/msgp_gen.go

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

5 changes: 5 additions & 0 deletions agreement/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ type proposal struct {
// validated (and thus was ready to be delivered to the state
// machine), relative to the zero of that round.
validatedAt time.Duration

// receivedAt indicates the time at which this proposal was
// delivered to the agreement package (as a messageEvent),
// relative to the zero of that round.
receivedAt time.Duration
}

func makeProposal(ve ValidatedBlock, pf crypto.VrfProof, origPer period, origProp basics.Address) proposal {
Expand Down
4 changes: 2 additions & 2 deletions catchup/universalFetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ func (w *wsFetcherClient) requestBlock(ctx context.Context, round basics.Round)
return blockCertBytes, nil
}

// set max fetcher size to 5MB, this is enough to fit the block and certificate
const fetcherMaxBlockBytes = 5 << 20
// set max fetcher size to 10MB, this is enough to fit the block and certificate
const fetcherMaxBlockBytes = 10 << 20

var errNoBlockForRound = errors.New("No block available for given round")

Expand Down
29 changes: 21 additions & 8 deletions cmd/netgoal/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var templateToGenerate string
var relaysToGenerate int
var nodesToGenerate int
var nodeHostsToGenerate int
var nonPartnodesToGenerate int
var nonPartnodesHostsToGenerate int
var walletsToGenerate int
var nodeTemplatePath string
Expand All @@ -64,6 +65,7 @@ func init() {
generateCmd.Flags().IntVarP(&relaysToGenerate, "relays", "R", -1, "Relays to generate")
generateCmd.Flags().IntVarP(&nodeHostsToGenerate, "node-hosts", "N", -1, "Node-hosts to generate, default=nodes")
generateCmd.Flags().IntVarP(&nodesToGenerate, "nodes", "n", -1, "Nodes to generate")
generateCmd.Flags().IntVarP(&nonPartnodesToGenerate, "non-participating-nodes", "X", 0, "Non participating nodes to generate")
generateCmd.Flags().IntVarP(&nonPartnodesHostsToGenerate, "non-participating-nodes-hosts", "H", 0, "Non participating nodes hosts to generate")
generateCmd.Flags().StringVarP(&nodeTemplatePath, "node-template", "", "", "json for one node")
generateCmd.Flags().StringVarP(&nonParticipatingNodeTemplatePath, "non-participating-node-template", "", "", "json for non participating node")
Expand Down Expand Up @@ -147,7 +149,7 @@ template modes for -t:`,
if walletsToGenerate < 0 {
reportErrorf("must specify number of wallets with -w")
}
err = generateWalletGenesis(outputFilename, walletsToGenerate, nonPartnodesHostsToGenerate)
err = generateWalletGenesis(outputFilename, walletsToGenerate, nonPartnodesToGenerate)
case "net", "network", "goalnet":
if walletsToGenerate < 0 {
reportErrorf("must specify number of wallets with -w")
Expand All @@ -164,10 +166,10 @@ template modes for -t:`,
if templateType == "goalnet" {
err = generateNetworkGoalTemplate(outputFilename, walletsToGenerate, relaysToGenerate, nodesToGenerate, nonPartnodesHostsToGenerate)
} else {
err = generateNetworkTemplate(outputFilename, walletsToGenerate, relaysToGenerate, nodeHostsToGenerate, nodesToGenerate, nonPartnodesHostsToGenerate, baseNode, baseNonParticipatingNode, baseRelay)
err = generateNetworkTemplate(outputFilename, walletsToGenerate, relaysToGenerate, nodeHostsToGenerate, nodesToGenerate, nonPartnodesHostsToGenerate, nonPartnodesToGenerate, baseNode, baseNonParticipatingNode, baseRelay)
}
case "otwt":
err = generateNetworkTemplate(outputFilename, 1000, 10, 20, 100, 0, baseNode, baseNonParticipatingNode, baseRelay)
err = generateNetworkTemplate(outputFilename, 1000, 10, 20, 100, 0, 0, baseNode, baseNonParticipatingNode, baseRelay)
case "otwg":
err = generateWalletGenesis(outputFilename, 1000, 0)
case "ohwg":
Expand Down Expand Up @@ -308,7 +310,7 @@ func generateNetworkGoalTemplate(templateFilename string, wallets, relays, nodes
return saveGoalTemplateToDisk(template, templateFilename)
}

func generateNetworkTemplate(templateFilename string, wallets, relays, nodeHosts, nodes, npnHosts int, baseNode, baseNonPartNode, baseRelay remote.NodeConfig) error {
func generateNetworkTemplate(templateFilename string, wallets, relays, nodeHosts, nodes, npnHosts, npns int, baseNode, baseNonPartNode, baseRelay remote.NodeConfig) error {
network := remote.DeployedNetworkConfig{}

relayTemplates := unpackNodeConfig(baseRelay)
Expand Down Expand Up @@ -361,6 +363,7 @@ func generateNetworkTemplate(templateFilename string, wallets, relays, nodeHosts
}
}

npnHostIndexes := make([]int, 0, npnHosts)
for i := 0; i < npnHosts; i++ {
indexID := strconv.Itoa(i + 1)

Expand All @@ -373,8 +376,18 @@ func generateNetworkTemplate(templateFilename string, wallets, relays, nodeHosts
Name: "NPN" + indexID,
Nodes: []remote.NodeConfig{node},
}
npnHostIndexes = append(npnHostIndexes, len(network.Hosts))
network.Hosts = append(network.Hosts, host)
}
for i := npnHosts; i < npns; i++ {
hosti := npnHostIndexes[i%len(npnHostIndexes)]
name := "nonParticipatingNode" + strconv.Itoa(i+1)
node := pickNodeConfig(npnTemplates, name)
node.NodeNameMatchRegex = ""
node.FractionApply = 0.0
node.Name = name
network.Hosts[hosti].Nodes = append(network.Hosts[hosti].Nodes, node)
}

walletIndex := 0
for walletIndex < wallets {
Expand All @@ -400,9 +413,9 @@ func generateNetworkTemplate(templateFilename string, wallets, relays, nodeHosts
}

// one wallet per NPN host to concentrate stake
if npnHosts > 0 {
if npns > 0 {
walletIndex := 0
for walletIndex < npnHosts {
for walletIndex < npns {
for hosti := range network.Hosts {
for nodei, node := range network.Hosts[hosti].Nodes {
if node.Name[0:4] != "nonP" {
Expand All @@ -414,11 +427,11 @@ func generateNetworkTemplate(templateFilename string, wallets, relays, nodeHosts
}
network.Hosts[hosti].Nodes[nodei].Wallets = append(network.Hosts[hosti].Nodes[nodei].Wallets, wallet)
walletIndex++
if walletIndex >= npnHosts {
if walletIndex >= npns {
break
}
}
if walletIndex >= npnHosts {
if walletIndex >= npns {
break
}
}
Expand Down
11 changes: 5 additions & 6 deletions crypto/batchverifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const minBatchVerifierAlloc = 16
// Batch verifications errors
var (
ErrBatchVerificationFailed = errors.New("At least one signature didn't pass verification")
ErrZeroTransactionInBatch = errors.New("Could not validate empty signature set")
)

//export ed25519_randombytes_unsafe
Expand Down Expand Up @@ -104,19 +103,19 @@ func (b *BatchVerifier) expand() {
b.signatures = signatures
}

// GetNumberOfEnqueuedSignatures returns the number of signatures current enqueue onto the bacth verifier object
func (b *BatchVerifier) GetNumberOfEnqueuedSignatures() int {
// getNumberOfEnqueuedSignatures returns the number of signatures current enqueue onto the bacth verifier object
func (b *BatchVerifier) getNumberOfEnqueuedSignatures() int {
return len(b.messages)
}

// Verify verifies that all the signatures are valid. in that case nil is returned
// if the batch is zero an appropriate error is return.
func (b *BatchVerifier) Verify() error {
if b.GetNumberOfEnqueuedSignatures() == 0 {
return ErrZeroTransactionInBatch
if b.getNumberOfEnqueuedSignatures() == 0 {
return nil
}

var messages = make([][]byte, b.GetNumberOfEnqueuedSignatures())
var messages = make([][]byte, b.getNumberOfEnqueuedSignatures())
for i, m := range b.messages {
messages[i] = HashRep(m)
}
Expand Down
4 changes: 2 additions & 2 deletions crypto/batchverifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestBatchVerifierBulk(t *testing.T) {
sig := sigSecrets.Sign(msg)
bv.EnqueueSignature(sigSecrets.SignatureVerifier, msg, sig)
}
require.Equal(t, n, bv.GetNumberOfEnqueuedSignatures())
require.Equal(t, n, bv.getNumberOfEnqueuedSignatures())
require.NoError(t, bv.Verify())
}

Expand Down Expand Up @@ -122,5 +122,5 @@ func BenchmarkBatchVerifier(b *testing.B) {
func TestEmpty(t *testing.T) {
partitiontest.PartitionTest(t)
bv := MakeBatchVerifier()
require.Error(t, bv.Verify())
require.NoError(t, bv.Verify())
}
Loading

0 comments on commit 82bf931

Please sign in to comment.