Skip to content

Commit

Permalink
WithSeed -> WithProposal
Browse files Browse the repository at this point in the history
  • Loading branch information
jannotti committed Feb 5, 2024
1 parent bb401cf commit 316083f
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 12 deletions.
8 changes: 5 additions & 3 deletions agreement/abstractions.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ 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.
// WithProposal creates a copy of this ValidatedBlock with its
// cryptographically random seed and proposer set. Abstractly, it is how the
// agreement code "finishes" a block and makes it a proposal for a specific
// account.
//
// Calls to Seed() or to Digest() on the copy's Block must
// reflect the value of the new seed.
WithSeed(committee.Seed, basics.Address) ValidatedBlock
WithProposal(committee.Seed, basics.Address) ValidatedBlock

// Block returns the underlying block that has been validated.
Block() bookkeeping.Block
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 @@ -79,7 +79,7 @@ func (b testValidatedBlock) Block() bookkeeping.Block {
return b.Inside
}

func (b testValidatedBlock) WithSeed(s committee.Seed, proposer basics.Address) agreement.ValidatedBlock {
func (b testValidatedBlock) WithProposal(s committee.Seed, proposer basics.Address) agreement.ValidatedBlock {
b.Inside.BlockHeader.Seed = s
b.Inside.BlockHeader.Proposer = proposer
return b
Expand Down
2 changes: 1 addition & 1 deletion agreement/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (b testValidatedBlock) Block() bookkeeping.Block {
return b.Inside
}

func (b testValidatedBlock) WithSeed(s committee.Seed, proposer basics.Address) ValidatedBlock {
func (b testValidatedBlock) WithProposal(s committee.Seed, proposer basics.Address) ValidatedBlock {
b.Inside.BlockHeader.Seed = s
b.Inside.BlockHeader.Proposer = proposer
return b
Expand Down
2 changes: 1 addition & 1 deletion agreement/fuzzer/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (b testValidatedBlock) Block() bookkeeping.Block {
return b.Inside
}

func (b testValidatedBlock) WithSeed(s committee.Seed, proposer basics.Address) agreement.ValidatedBlock {
func (b testValidatedBlock) WithProposal(s committee.Seed, proposer basics.Address) agreement.ValidatedBlock {
b.Inside.BlockHeader.Seed = s
b.Inside.BlockHeader.Proposer = proposer
return b
Expand Down
2 changes: 1 addition & 1 deletion agreement/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func proposalForBlock(address basics.Address, vrf *crypto.VRFSecrets, ve Validat
if ve.Block().ConsensusProtocol().EnableMining {
hdrProp = address
}
ve = ve.WithSeed(newSeed, hdrProp)
ve = ve.WithProposal(newSeed, hdrProp)
proposal := makeProposal(ve, seedProof, period, address)
value := proposalValue{
OriginalPeriod: period,
Expand Down
2 changes: 1 addition & 1 deletion data/datatest/impls.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (i entryFactoryImpl) AssembleBlock(round basics.Round) (agreement.Validated
}

// WithSeed implements the agreement.ValidatedBlock interface.
func (ve validatedBlock) WithSeed(s committee.Seed, proposer basics.Address) agreement.ValidatedBlock {
func (ve validatedBlock) WithProposal(s committee.Seed, proposer basics.Address) agreement.ValidatedBlock {
newblock := *ve.blk
newblock.BlockHeader.Seed = s
newblock.BlockHeader.Proposer = proposer
Expand Down
2 changes: 1 addition & 1 deletion ledger/ledgercore/validatedBlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (vb ValidatedBlock) Delta() StateDelta {
}

// WithSeed returns a copy of the ValidatedBlock with a modified seed and associated proposer
func (vb ValidatedBlock) WithSeed(s committee.Seed, proposer basics.Address) ValidatedBlock {
func (vb ValidatedBlock) WithProposal(s committee.Seed, proposer basics.Address) ValidatedBlock {
newblock := vb.blk
newblock.BlockHeader.Seed = s
newblock.BlockHeader.Proposer = proposer
Expand Down
2 changes: 1 addition & 1 deletion ledger/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func endBlock(t testing.TB, ledger *Ledger, eval *eval.BlockEvaluator, proposer

// We have this backdoor way to install a proposer or seed into the header
// for tests. Doesn't matter that it makes them both the same.
*vb = vb.WithSeed(committee.Seed(prp), prp)
*vb = vb.WithProposal(committee.Seed(prp), prp)

err = ledger.AddValidatedBlock(*vb, agreement.Certificate{})
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,8 +1291,8 @@ type validatedBlock struct {
}

// WithSeed satisfies the agreement.ValidatedBlock interface.
func (vb validatedBlock) WithSeed(s committee.Seed, proposer basics.Address) agreement.ValidatedBlock {
lvb := vb.vb.WithSeed(s, proposer)
func (vb validatedBlock) WithProposal(s committee.Seed, proposer basics.Address) agreement.ValidatedBlock {
lvb := vb.vb.WithProposal(s, proposer)
return validatedBlock{vb: &lvb}
}

Expand Down

0 comments on commit 316083f

Please sign in to comment.