-
Notifications
You must be signed in to change notification settings - Fork 473
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
agreement: split ValidatedBlock and AssembledBlock interfaces #5967
Changes from all commits
80b2721
8ffc5cc
2b97b66
569a5c8
af2412d
bdda2a5
421fa47
09a8364
d2745e5
5a19b26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,7 +165,11 @@ 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) FinalizeBlock(s committee.Seed, _ basics.Address) ProposableBlock { | ||
b.Inside.BlockHeader.Seed = s | ||
return b | ||
} | ||
|
@@ -180,7 +184,7 @@ type testBlockFactory struct { | |
Owner int | ||
} | ||
|
||
func (f testBlockFactory) AssembleBlock(r basics.Round) (ValidatedBlock, error) { | ||
func (f testBlockFactory) AssembleBlock(r basics.Round, _ []basics.Address) (AssembledBlock, error) { | ||
return testValidatedBlock{Inside: bookkeeping.Block{BlockHeader: bookkeeping.BlockHeader{Round: r}}}, nil | ||
} | ||
|
||
|
@@ -413,7 +417,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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the idea is that the underlying type is not going to be a Block, it's going to be something that holds onto extra information about those addresses (balances, presumably) so that a later call to FinalizeBlock can erase the payout if it won't leave the account above min balance? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes and whatever else you need to do (like updating the seed, assigning proposer etc) to finish/finalize the block |
||
if err != nil { | ||
logging.Base().Errorf("Could not generate a proposal for round %d: %v", round, err) | ||
return nil, nil | ||
|
@@ -525,8 +529,9 @@ 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) | ||
ae, err := f.AssembleBlock(r, nil) | ||
require.NoError(t, err) | ||
ve := ae.FinalizeBlock(committee.Seed{}, basics.Address{}) | ||
|
||
var payload unauthenticatedProposal | ||
payload.Block = ve.Block() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need Round() now?
AssembledBlocks can't give out their Block()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is not to allow access to the AssembledBlock, it is an opaque type that should not be used for serializing or access until Finalize is called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this more opaque also helped me catch some agreement tests & test helpers that were using the AssembleBlock() value without calling WithSeed before — those tests were ignoring and not validating the seed anyway, but it was good to find where they were.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does seem good that an assembledBlock will no longer implement ValidatedBlock.