Skip to content

Commit

Permalink
split AssembledBlock/ProposableBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
cce committed Apr 1, 2024
1 parent af2412d commit bdda2a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 8 additions & 3 deletions agreement/abstractions.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,24 @@ type BlockFactory interface {
// produce a AssembledBlock 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) (AssembledBlock, error)
AssembleBlock(rnd basics.Round, partAddresses []basics.Address) (AssembledBlock, error)
}

// An AssembledBlock represents a Block produced by a BlockFactory
// and can now be proposed by agreement.
// and must be finalized before being proposed by agreement.
type AssembledBlock interface {
// WithSeed creates a copy of this AssembledBlock 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) AssembledBlock
FinalizeBlock(seed committee.Seed, proposer basics.Address) ProposableBlock
}

// An ProposableBlock represents a Block produced by a BlockFactory,
// that was later finalized by providing the seed and the proposer,
// and can now be proposed by agreement.
type ProposableBlock interface {
// Block returns the underlying block that has been assembled.
Block() bookkeeping.Block
}
Expand Down
6 changes: 3 additions & 3 deletions agreement/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type proposal struct {

// makeProposalFromAssembledBlock is called when making a new proposal message,
// using the output of AssembleBlock (from makeProposals -> proposalForBlock)
func makeProposalFromAssembledBlock(blk AssembledBlock, pf crypto.VrfProof, origPer period, origProp basics.Address) proposal {
func makeProposalFromAssembledBlock(blk ProposableBlock, pf crypto.VrfProof, origPer period, origProp basics.Address) proposal {
e := blk.Block()
var payload unauthenticatedProposal
payload.Block = e
Expand Down Expand Up @@ -265,8 +265,8 @@ func proposalForBlock(address basics.Address, vrf *crypto.VRFSecrets, blk Assemb
return proposal{}, proposalValue{}, fmt.Errorf("proposalForBlock: could not derive new seed: %v", err)
}

blk = blk.WithSeed(newSeed)
prop := makeProposalFromAssembledBlock(blk, seedProof, period, address)
proposableBlock := blk.FinalizeBlock(newSeed, address)
prop := makeProposalFromAssembledBlock(proposableBlock, seedProof, period, address)
value := proposalValue{
OriginalPeriod: period,
OriginalProposer: address,
Expand Down
2 changes: 1 addition & 1 deletion agreement/pseudonode.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (n asyncPseudonode) makePseudonodeVerifier(voteVerifier *AsyncVoteVerifier)

// makeProposals creates a slice of block proposals for the given round and period.
func (n asyncPseudonode) makeProposals(round basics.Round, period period, accounts []account.ParticipationRecordForRound) ([]proposal, []unauthenticatedVote) {
ve, err := n.factory.AssembleBlock(round)
ve, err := n.factory.AssembleBlock(round, accounts)

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-warnings

[Lint Warnings] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-warnings

[Lint Warnings] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-warnings

[Lint Warnings] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-warnings

[Lint Warnings] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / Performance regression check

cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / Performance regression check

cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-errors

[Lint Errors] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-errors

[Lint Errors] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-warnings

[Lint Warnings] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-warnings

[Lint Warnings] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-warnings

[Lint Warnings] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-warnings

[Lint Warnings] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-errors

[Lint Errors] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / reviewdog-errors

[Lint Errors] reported by reviewdog 🐶 cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) Raw Output: agreement/pseudonode.go:287:44: cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock) (typecheck) "github.com/algorand/go-algorand/agreement" ^

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / build-windows

cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock

Check failure on line 287 in agreement/pseudonode.go

View workflow job for this annotation

GitHub Actions / build-windows

cannot use accounts (variable of type []account.ParticipationRecordForRound) as []basics.Address value in argument to n.factory.AssembleBlock
if err != nil {
if err != ErrAssembleBlockRoundStale {
n.log.Errorf("pseudonode.makeProposals: could not generate a proposal for round %d: %v", round, err)
Expand Down

0 comments on commit bdda2a5

Please sign in to comment.