Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incentives: Heartbeat transaction type #6149

Merged
merged 22 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion agreement/gossip/networkFull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func spinNetwork(t *testing.T, nodesCount int, cfg config.Local) ([]*networkImpl
break
}
}
log.Infof("network established, %d nodes connected in %s", nodesCount, time.Now().Sub(start).String())
log.Infof("network established, %d nodes connected in %s", nodesCount, time.Since(start).String())
return networkImpls, msgCounters
}

Expand Down
2 changes: 1 addition & 1 deletion catchup/universalFetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (uf *universalBlockFetcher) fetchBlock(ctx context.Context, round basics.Ro
} else {
return nil, nil, time.Duration(0), fmt.Errorf("fetchBlock: UniversalFetcher only supports HTTPPeer and UnicastPeer")
}
downloadDuration = time.Now().Sub(blockDownloadStartTime)
downloadDuration = time.Since(blockDownloadStartTime)
block, cert, err := processBlockBytes(fetchedBuf, round, address)
if err != nil {
return nil, nil, time.Duration(0), err
Expand Down
3 changes: 1 addition & 2 deletions cmd/goal/clerk.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@
}

reportInfof(infoTxPending, txid, stat.LastRound)
// WaitForRound waits until round "stat.LastRound+1" is committed
stat, err = client.WaitForRound(stat.LastRound)
stat, err = client.WaitForRound(stat.LastRound + 1)

Check warning on line 224 in cmd/goal/clerk.go

View check run for this annotation

Codecov / codecov/patch

cmd/goal/clerk.go#L224

Added line #L224 was not covered by tests
if err != nil {
return model.PendingTransactionResponse{}, fmt.Errorf(errorRequestFail, err)
}
Expand Down
11 changes: 6 additions & 5 deletions cmd/loadgenerator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,23 @@ func waitForRound(restClient client.RestClient, cfg config, spendingRound bool)
time.Sleep(1 * time.Second)
continue
}
if isSpendRound(cfg, nodeStatus.LastRound) == spendingRound {
lastRound := nodeStatus.LastRound
if isSpendRound(cfg, lastRound) == spendingRound {
// time to send transactions.
return
}
if spendingRound {
fmt.Printf("Last round %d, waiting for spending round %d\n", nodeStatus.LastRound, nextSpendRound(cfg, nodeStatus.LastRound))
fmt.Printf("Last round %d, waiting for spending round %d\n", lastRound, nextSpendRound(cfg, nodeStatus.LastRound))
}
for {
// wait for the next round.
nodeStatus, err = restClient.WaitForBlock(basics.Round(nodeStatus.LastRound))
err = restClient.WaitForRoundWithTimeout(lastRound + 1)
if err != nil {
fmt.Fprintf(os.Stderr, "unable to wait for next round node status : %v", err)
time.Sleep(1 * time.Second)
break
}
if isSpendRound(cfg, nodeStatus.LastRound) == spendingRound {
lastRound++
if isSpendRound(cfg, lastRound) == spendingRound {
// time to send transactions.
return
}
Expand Down
9 changes: 7 additions & 2 deletions config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ type ConsensusParams struct {
// occur, extra funds need to be put into the FeeSink. The bonus amount
// decays exponentially.
Bonus BonusPlan

// Heartbeat support
Heartbeat bool
}

// ProposerPayoutRules puts several related consensus parameters in one place. The same
Expand Down Expand Up @@ -1513,7 +1516,7 @@ func initConsensusProtocols() {
vFuture.LogicSigVersion = 11 // When moving this to a release, put a new higher LogicSigVersion here

vFuture.Payouts.Enabled = true
vFuture.Payouts.Percent = 75
vFuture.Payouts.Percent = 50
vFuture.Payouts.GoOnlineFee = 2_000_000 // 2 algos
vFuture.Payouts.MinBalance = 30_000_000_000 // 30,000 algos
vFuture.Payouts.MaxBalance = 70_000_000_000_000 // 70M algos
Expand All @@ -1524,7 +1527,9 @@ func initConsensusProtocols() {

vFuture.Bonus.BaseAmount = 10_000_000 // 10 Algos
// 2.9 sec rounds gives about 10.8M rounds per year.
vFuture.Bonus.DecayInterval = 250_000 // .99^(10.8/0.25) ~ .648. So 35% decay per year
vFuture.Bonus.DecayInterval = 1_000_000 // .99^(10.8M/1M) ~ .897. So ~10% decay per year

vFuture.Heartbeat = true

Consensus[protocol.ConsensusFuture] = vFuture

Expand Down
5 changes: 5 additions & 0 deletions config/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func TestConsensusParams(t *testing.T) {
if params.ApplyData && params.PaysetCommit == PaysetCommitUnsupported {
t.Errorf("Protocol %s: ApplyData with PaysetCommitUnsupported", proto)
}

// To figure out challenges, nodes must be able to lookup headers up to two GracePeriods back
if 2*params.Payouts.ChallengeGracePeriod > params.MaxTxnLife+params.DeeperBlockHeaderHistory {
t.Errorf("Protocol %s: Grace period is too long", proto)
}
}
}

Expand Down
236 changes: 236 additions & 0 deletions crypto/msgp_gen.go

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

Loading
Loading