Skip to content

Commit

Permalink
Merge pull request #6208 from Algo-devops-service/relbeta4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
algojohnlee authored Dec 20, 2024
2 parents d1fbc97 + 89109d8 commit e77a367
Show file tree
Hide file tree
Showing 212 changed files with 13,948 additions and 1,701 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: "ReviewDog workflow"
env:
GOLANGCI_LINT_VERSION: "v1.62.0"
on:
push:
branches:
Expand All @@ -17,15 +19,15 @@ jobs:
- name: Make libsodium.a
run: sudo mv /usr/bin/go /usr/bin/go.bak && make crypto/libs/linux/amd64/lib/libsodium.a && sudo mv /usr/bin/go.bak /usr/bin/go
- name: reviewdog-golangci-lint
uses: reviewdog/action-golangci-lint@v2.6.2
uses: reviewdog/action-golangci-lint@v2.7.0
with:
go_version_file: go.mod
golangci_lint_version: "v1.62.0"
golangci_lint_version: ${{ env.GOLANGCI_LINT_VERSION }}
golangci_lint_flags: "-c .golangci.yml --allow-parallel-runners"
reporter: "github-pr-check"
tool_name: "Lint Errors"
level: "error"
fail_on_error: true
fail_level: any
filter_mode: "nofilter"
# Non-Blocking Warnings Section
reviewdog-warnings:
Expand Down Expand Up @@ -56,20 +58,20 @@ jobs:
uses: actions/[email protected]
with:
path: cicdtmp/golangci-lint/golangci-lint-cgo
key: cicd-golangci-lint-cgo-v0.0.2-${{ env.GO_VERSION }}
key: cicd-golangci-lint-cgo-v0.0.3-${{ env.GO_VERSION }}-${{ env.GOLANGCI_LINT_VERSION }}

- name: Build custom golangci-lint with CGO_ENABLED
if: steps.cache-golangci-lint.outputs.cache-hit != 'true'
run: |
cd cicdtmp/golangci-lint
git clone https://github.com/golangci/golangci-lint.git .
git checkout tags/v1.62.0
git checkout tags/${GOLANGCI_LINT_VERSION}
CGO_ENABLED=true go build -trimpath -o golangci-lint-cgo ./cmd/golangci-lint
./golangci-lint-cgo --version
cd ../../
- name: Install reviewdog
run: |
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/v0.20.2/install.sh | sh -s -- v0.20.2
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/v0.20.3/install.sh | sh -s -- v0.20.3
reviewdog --version
- name: Build custom linters
run: |
Expand All @@ -92,9 +94,9 @@ jobs:
cat temp_golangci-lint-cgo.txt | reviewdog \
-f=golangci-lint \
-name="Lint Warnings" \
-reporter=github-check \
-reporter=github-pr-check \
-filter-mode=added \
-fail-on-error=true \
-fail-level=any \
-level=warning
- name: Slack Notification
env:
Expand All @@ -107,11 +109,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: shellcheck
uses: reviewdog/action-shellcheck@v1
uses: reviewdog/action-shellcheck@v1.28.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: "github-pr-check"
shellcheck_flags: "-e SC2034,SC2046,SC2053,SC2207,SC2145 -S warning"
fail_on_error: true
fail_level: any
path: |
test/scripts/e2e_subs
4 changes: 2 additions & 2 deletions .golangci-warnings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ linters:
- partitiontest

linters-settings:
gosec: # we are mostly only interested in G601
excludes: [G101, G103, G104, G107, G202, G301, G302, G303, G304, G306, G307, G404]
gosec: # Go 1.22 makes G601 irrelevant
excludes: [G101, G103, G104, G107, G115, G202, G301, G302, G303, G304, G306, G307, G404, G601]
custom:
partitiontest:
path: cmd/partitiontest_linter/plugin.so
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ $(GOPATH1)/bin/%:
test: build
$(GOTESTCOMMAND) $(GOTAGS) -race $(UNIT_TEST_SOURCES) -timeout 1h -coverprofile=coverage.txt -covermode=atomic

testc:
echo $(UNIT_TEST_SOURCES) | xargs -P8 -n1 go test -c

benchcheck: build
$(GOTESTCOMMAND) $(GOTAGS) -race $(UNIT_TEST_SOURCES) -run ^NOTHING -bench Benchmark -benchtime 1x -timeout 1h

Expand Down
2 changes: 1 addition & 1 deletion agreement/agreementtest/simulate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package agreementtest
import (
"context"
"fmt"
"maps"
"math/rand"
"os"
"strconv"
Expand All @@ -27,7 +28,6 @@ import (

"github.com/algorand/go-deadlock"
"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"

"github.com/algorand/go-algorand/agreement"
"github.com/algorand/go-algorand/config"
Expand Down
2 changes: 1 addition & 1 deletion agreement/autopsy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"fmt"
"io"
"os"
"slices"

"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
"golang.org/x/exp/slices"
)

// An Autopsy is a trace of the ordered input events and output
Expand Down
2 changes: 1 addition & 1 deletion agreement/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package agreement
import (
"context"
"fmt"
"maps"
"math/rand"
"testing"

"github.com/algorand/go-deadlock"
"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"

"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/crypto"
Expand Down
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
8 changes: 7 additions & 1 deletion agreement/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ func (sel selector) CommitteeSize(proto config.ConsensusParams) uint64 {
// looking at online stake (and status and key material). It is exported so that
// AVM can provide opcodes that return the same data.
func BalanceRound(r basics.Round, cparams config.ConsensusParams) basics.Round {
return r.SubSaturate(basics.Round(2 * cparams.SeedRefreshInterval * cparams.SeedLookback))
return r.SubSaturate(BalanceLookback(cparams))
}

// BalanceLookback is how far back agreement looks when considering balances for
// voting stake.
func BalanceLookback(cparams config.ConsensusParams) basics.Round {
return basics.Round(2 * cparams.SeedRefreshInterval * cparams.SeedLookback)
}

func seedRound(r basics.Round, cparams config.ConsensusParams) basics.Round {
Expand Down
4 changes: 2 additions & 2 deletions catchup/catchpointService_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func (m *catchpointCatchupAccessorMock) Ledger() (l ledger.CatchupAccessorClient
}

// GetVerifyData returns the balances hash, spver hash and totals used by VerifyCatchpoint
func (m *catchpointCatchupAccessorMock) GetVerifyData(ctx context.Context) (balancesHash crypto.Digest, spverHash crypto.Digest, totals ledgercore.AccountTotals, err error) {
return crypto.Digest{}, crypto.Digest{}, ledgercore.AccountTotals{}, nil
func (m *catchpointCatchupAccessorMock) GetVerifyData(ctx context.Context) (balancesHash, spverHash, onlineAccountsHash, onlineRoundParamsHash crypto.Digest, totals ledgercore.AccountTotals, err error) {
return crypto.Digest{}, crypto.Digest{}, crypto.Digest{}, crypto.Digest{}, ledgercore.AccountTotals{}, nil
}

// TestCatchpointServicePeerRank ensures CatchpointService does not crash when a block fetched
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
5 changes: 3 additions & 2 deletions cmd/algokey/keyreg.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"encoding/base64"
"errors"
"fmt"
"maps"
"os"
"slices"
"strings"

"github.com/spf13/cobra"
"golang.org/x/exp/maps"

"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/account"
Expand Down Expand Up @@ -95,7 +96,7 @@ func init() {
"betanet": mustConvertB64ToDigest("mFgazF+2uRS1tMiL9dsj01hJGySEmPN28B/TjjvpVW0="),
"devnet": mustConvertB64ToDigest("sC3P7e2SdbqKJK0tbiCdK9tdSpbe6XeCGKdoNzmlj0E="),
}
validNetworkList = maps.Keys(validNetworks)
validNetworkList = slices.Collect(maps.Keys(validNetworks))
}

func mustConvertB64ToDigest(b64 string) (digest crypto.Digest) {
Expand Down
7 changes: 4 additions & 3 deletions cmd/catchpointdump/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,13 @@ func loadCatchpointIntoDatabase(ctx context.Context, catchupAccessor ledger.Catc
if err != nil {
return fileHeader, err
}
var balanceHash, spverHash crypto.Digest
balanceHash, spverHash, _, err = catchupAccessor.GetVerifyData(ctx)
var balanceHash, spverHash, onlineAccountsHash, onlineRoundParamsHash crypto.Digest
balanceHash, spverHash, onlineAccountsHash, onlineRoundParamsHash, _, err = catchupAccessor.GetVerifyData(ctx)
if err != nil {
return fileHeader, err
}
fmt.Printf("accounts digest=%s, spver digest=%s\n\n", balanceHash, spverHash)
fmt.Printf("accounts digest=%s, spver digest=%s, onlineaccounts digest=%s onlineroundparams digest=%s\n\n",
balanceHash, spverHash, onlineAccountsHash, onlineRoundParamsHash)
}
return fileHeader, nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/goal/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
"net/http"
"os"
"path/filepath"
"slices"
"sort"
"strings"
"time"

"github.com/spf13/cobra"
"golang.org/x/exp/slices"

"github.com/algorand/go-algorand/cmd/util/datadir"
"github.com/algorand/go-algorand/config"
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 @@ func waitForCommit(client libgoal.Client, txid string, transactionLastValidRound
}

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)
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
2 changes: 1 addition & 1 deletion cmd/opdoc/opdoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func create(file string) *os.File {
}

func main() {
const docVersion = uint64(10)
const docVersion = uint64(11)

opGroups := make(map[string][]string, len(logic.OpSpecs))
for grp, names := range logic.OpGroups {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tealdbg/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"io"
"log"
"slices"
"time"

"github.com/algorand/go-algorand/config"
Expand All @@ -28,7 +29,6 @@ import (
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/ledger/apply"
"github.com/algorand/go-algorand/protocol"
"golang.org/x/exp/slices"
)

func protoFromString(protoString string) (name string, proto config.ConsensusParams, err error) {
Expand Down
4 changes: 4 additions & 0 deletions cmd/tealdbg/localLedger.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ func (l *localLedger) LookupAgreement(rnd basics.Round, addr basics.Address) (ba
}, nil
}

func (l *localLedger) GetKnockOfflineCandidates(basics.Round, config.ConsensusParams) (map[basics.Address]basics.OnlineAccountData, error) {
return nil, nil
}

func (l *localLedger) OnlineCirculation(rnd basics.Round, voteRound basics.Round) (basics.MicroAlgos, error) {
// A constant is fine for tealdbg
return basics.Algos(1_000_000_000), nil // 1B
Expand Down
4 changes: 2 additions & 2 deletions components/mocks/mockCatchpointCatchupAccessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func (m *MockCatchpointCatchupAccessor) GetCatchupBlockRound(ctx context.Context
}

// GetVerifyData returns the balances hash, spver hash and totals used by VerifyCatchpoint
func (m *MockCatchpointCatchupAccessor) GetVerifyData(ctx context.Context) (balancesHash crypto.Digest, spverHash crypto.Digest, totals ledgercore.AccountTotals, err error) {
return crypto.Digest{}, crypto.Digest{}, ledgercore.AccountTotals{}, nil
func (m *MockCatchpointCatchupAccessor) GetVerifyData(ctx context.Context) (balancesHash, spverHash, onlineAccountsHash, onlineRoundParams crypto.Digest, totals ledgercore.AccountTotals, err error) {
return crypto.Digest{}, crypto.Digest{}, crypto.Digest{}, crypto.Digest{}, ledgercore.AccountTotals{}, nil
}

// VerifyCatchpoint verifies that the catchpoint is valid by reconstructing the label.
Expand Down
Loading

0 comments on commit e77a367

Please sign in to comment.