Skip to content

Commit

Permalink
Merge pull request #5997 from Algo-devops-service/relbeta3.24.0
Browse files Browse the repository at this point in the history
  • Loading branch information
algojohnlee committed May 10, 2024
2 parents 5604f7f + a307b45 commit 5466548
Show file tree
Hide file tree
Showing 198 changed files with 11,259 additions and 5,481 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/codegen_verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
jobs:
codegen_verification:
runs-on: ubuntu-20.04
services:
converter:
image: swaggerapi/swagger-converter@sha256:dcfd1c2537f5f271cb4ec942d08aa59ca41b9a24078040061a772afca7e548ae # v1.0.4
ports:
- 8080:8080
steps:
- name: Check out code
uses: actions/[email protected]
Expand All @@ -16,6 +21,8 @@ jobs:
- name: Uninstall existing go installation
run: sudo apt-get -y -q purge golang-go
- name: Run codegen_verification.sh
env:
SWAGGER_CONVERTER_API: "http://localhost:8080"
run: |
export GOPATH="${GITHUB_WORKSPACE}/go"
cd go-algorand
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ 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.3.1
uses: reviewdog/action-golangci-lint@v2.6.1
with:
go_version_file: go.mod
golangci_lint_version: "v1.53.2"
golangci_lint_version: "v1.58.0"
golangci_lint_flags: "-c .golangci.yml --allow-parallel-runners"
reporter: "github-pr-check"
tool_name: "Lint Errors"
Expand Down Expand Up @@ -63,13 +63,13 @@ jobs:
run: |
cd cicdtmp/golangci-lint
git clone https://github.com/golangci/golangci-lint.git .
git checkout tags/v1.53.2
git checkout tags/v1.58.0
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.14.1/install.sh | sh -s
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/v0.17.4/install.sh | sh -s
reviewdog --version
- name: Build custom linters
run: |
Expand Down
8 changes: 7 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ linters-settings:
- (*github.com/spf13/pflag.FlagSet).MarkDeprecated
- (*github.com/spf13/pflag.FlagSet).MarkShorthandDeprecated
govet:
check-shadowing: true
# Enables these linters in addition to the default ones.
enable:
- shadow
settings:
shadow:
# explanation of strict vs non-strict:
Expand Down Expand Up @@ -131,6 +133,10 @@ issues:
linters:
- staticcheck
text: "SA4006: this value" # of X is never used
- path: _test\.go
linters:
- revive
text: "dot-imports: should not use dot imports"
- linters:
- staticcheck
text: "SA1019: rand*"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04 as builder

ARG GO_VERSION="1.20.14"
ARG GO_VERSION="1.21.10"

ARG CHANNEL
ARG URL
Expand Down Expand Up @@ -46,7 +46,7 @@ FROM debian:bookworm-20240311-slim as final
ENV PATH="/node/bin:${PATH}" ALGOD_PORT="8080" KMD_PORT="7833" ALGORAND_DATA="/algod/data"

# curl is needed to lookup the fast catchup url
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl gosu && \
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && \
update-ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
Expand Down
38 changes: 26 additions & 12 deletions agreement/abstractions.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ type BlockValidator interface {
// and can now be recorded in the ledger. This is an optimized version of
// calling EnsureBlock() on the Ledger.
type ValidatedBlock interface {
// WithSeed creates a copy of this ValidatedBlock with its
// cryptographically random seed set to the given value.
//
// Calls to Seed() or to Digest() on the copy's Block must
// reflect the value of the new seed.
WithSeed(committee.Seed) ValidatedBlock

// Block returns the underlying block that has been validated.
Block() bookkeeping.Block
}
Expand All @@ -72,21 +65,42 @@ var ErrAssembleBlockRoundStale = errors.New("requested round for AssembleBlock i
// An BlockFactory produces an Block which is suitable for proposal for a given
// Round.
type BlockFactory interface {
// AssembleBlock produces a new ValidatedBlock which is suitable for proposal
// at a given Round.
// AssembleBlock produces a new UnfinishedBlock for a given Round.
// It must be finalized before proposed by agreement. It is provided
// a list of participating addresses that may propose this block.
//
// AssembleBlock should produce a ValidatedBlock for which the corresponding
// AssembleBlock should produce a block for which the corresponding
// BlockValidator validates (i.e. for which BlockValidator.Validate
// returns true). If an insufficient number of nodes can assemble valid
// entries, the agreement protocol may lose liveness.
//
// AssembleBlock may return an error if the BlockFactory is unable to
// produce a ValidatedBlock for the given round. If an insufficient number of
// produce an UnfinishedBlock for the given round. If an insufficient number of
// nodes on the network can assemble entries, the agreement protocol may
// lose liveness.
AssembleBlock(basics.Round) (ValidatedBlock, error)
AssembleBlock(rnd basics.Round, partAddresses []basics.Address) (UnfinishedBlock, error)
}

// An UnfinishedBlock represents a Block produced by a BlockFactory
// and must be finalized before being proposed by agreement.
type UnfinishedBlock interface {
// FinishBlock creates a proposable block, having set the cryptographically
// random seed and payout related fields.
//
// Calls to Seed() or to Digest() on the copy's Block must
// reflect the value of the new seed.
FinishBlock(seed committee.Seed, proposer basics.Address, eligible bool) Block

Round() basics.Round
}

// Block (in agreement) represents an UnfinishedBlock produced by a
// BlockFactory, that was later finalized by providing the seed and the
// proposer, and can now be proposed by agreement.
//
//msgp:ignore Block
type Block bookkeeping.Block

// A Ledger represents the sequence of Entries agreed upon by the protocol.
// The Ledger consists of two parts: a LedgerReader and a LedgerWriter, which
// provide read and write access to the ledger, respectively.
Expand Down
14 changes: 11 additions & 3 deletions agreement/agreementtest/simulate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,17 @@ func (b testValidatedBlock) Block() bookkeeping.Block {
return b.Inside
}

func (b testValidatedBlock) WithSeed(s committee.Seed) agreement.ValidatedBlock {
func (b testValidatedBlock) Round() basics.Round {
return b.Inside.Round()
}

func (b testValidatedBlock) FinishBlock(s committee.Seed, proposer basics.Address, eligible bool) agreement.Block {
b.Inside.BlockHeader.Seed = s
return b
b.Inside.BlockHeader.Proposer = proposer
if !eligible {
b.Inside.BlockHeader.ProposerPayout = basics.MicroAlgos{}
}
return agreement.Block(b.Inside)
}

type testBlockValidator struct{}
Expand All @@ -94,7 +102,7 @@ type testBlockFactory struct {
Owner int
}

func (f testBlockFactory) AssembleBlock(r basics.Round) (agreement.ValidatedBlock, error) {
func (f testBlockFactory) AssembleBlock(r basics.Round, addrs []basics.Address) (agreement.UnfinishedBlock, error) {
return testValidatedBlock{Inside: bookkeeping.Block{BlockHeader: bookkeeping.BlockHeader{Round: r}}}, nil
}

Expand Down
23 changes: 16 additions & 7 deletions agreement/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,17 @@ func (b testValidatedBlock) Block() bookkeeping.Block {
return b.Inside
}

func (b testValidatedBlock) WithSeed(s committee.Seed) ValidatedBlock {
func (b testValidatedBlock) Round() basics.Round {
return b.Inside.Round()
}

func (b testValidatedBlock) FinishBlock(s committee.Seed, proposer basics.Address, eligible bool) Block {
b.Inside.BlockHeader.Seed = s
return b
b.Inside.BlockHeader.Proposer = proposer
if !eligible {
b.Inside.BlockHeader.ProposerPayout = basics.MicroAlgos{}
}
return Block(b.Inside)
}

type testBlockValidator struct{}
Expand All @@ -180,7 +188,7 @@ type testBlockFactory struct {
Owner int
}

func (f testBlockFactory) AssembleBlock(r basics.Round) (ValidatedBlock, error) {
func (f testBlockFactory) AssembleBlock(r basics.Round, _ []basics.Address) (UnfinishedBlock, error) {
return testValidatedBlock{Inside: bookkeeping.Block{BlockHeader: bookkeeping.BlockHeader{Round: r}}}, nil
}

Expand Down Expand Up @@ -413,7 +421,7 @@ type testAccountData struct {
}

func makeProposalsTesting(accs testAccountData, round basics.Round, period period, factory BlockFactory, ledger Ledger) (ps []proposal, vs []vote) {
ve, err := factory.AssembleBlock(round)
ve, err := factory.AssembleBlock(round, accs.addresses)
if err != nil {
logging.Base().Errorf("Could not generate a proposal for round %d: %v", round, err)
return nil, nil
Expand Down Expand Up @@ -525,19 +533,20 @@ func (v *voteMakerHelper) MakeRandomProposalValue() *proposalValue {

func (v *voteMakerHelper) MakeRandomProposalPayload(t *testing.T, r round) (*proposal, *proposalValue) {
f := testBlockFactory{Owner: 1}
ve, err := f.AssembleBlock(r)
ub, err := f.AssembleBlock(r, nil)
require.NoError(t, err)
pb := ub.FinishBlock(committee.Seed{}, basics.Address{}, false)

var payload unauthenticatedProposal
payload.Block = ve.Block()
payload.Block = bookkeeping.Block(pb)
payload.SeedProof = randomVRFProof()

propVal := proposalValue{
BlockDigest: payload.Digest(),
EncodingDigest: crypto.HashObj(payload),
}

return &proposal{unauthenticatedProposal: payload, ve: ve}, &propVal
return &proposal{unauthenticatedProposal: payload}, &propVal
}

// make a vote for a fixed proposal value
Expand Down
14 changes: 11 additions & 3 deletions agreement/fuzzer/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,17 @@ func (b testValidatedBlock) Block() bookkeeping.Block {
return b.Inside
}

func (b testValidatedBlock) WithSeed(s committee.Seed) agreement.ValidatedBlock {
func (b testValidatedBlock) Round() basics.Round {
return b.Inside.Round()
}

func (b testValidatedBlock) FinishBlock(s committee.Seed, proposer basics.Address, eligible bool) agreement.Block {
b.Inside.BlockHeader.Seed = s
return b
b.Inside.BlockHeader.Proposer = proposer
if !eligible {
b.Inside.BlockHeader.ProposerPayout = basics.MicroAlgos{}
}
return agreement.Block(b.Inside)
}

type testBlockValidator struct{}
Expand All @@ -108,7 +116,7 @@ type testBlockFactory struct {
Owner int
}

func (f testBlockFactory) AssembleBlock(r basics.Round) (agreement.ValidatedBlock, error) {
func (f testBlockFactory) AssembleBlock(r basics.Round, _ []basics.Address) (agreement.UnfinishedBlock, error) {
return testValidatedBlock{Inside: bookkeeping.Block{BlockHeader: bookkeeping.BlockHeader{Round: r}}}, nil
}

Expand Down
Loading

0 comments on commit 5466548

Please sign in to comment.