-
Notifications
You must be signed in to change notification settings - Fork 176
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
sealing halt on exec fork #178
Changes from 28 commits
a97d504
0b7ae9a
8682f5f
9ad30da
f8624f7
0c84641
fb21a73
8da45d3
b82c533
c075e73
9662906
f1742a6
f186c66
36a3ec5
7269be8
94288ff
bcd4f3d
5de72e3
9f4c7ad
4bd114e
0c1f245
278b470
0df7cce
4524714
d61f61f
7c48153
6fc4c6a
a6f3aa5
2d0fef0
e1006ad
0e7af9c
ab67a1b
33de9d9
addcb4b
49fb4a1
d14a1e7
2b6e669
d798b6b
3a9d171
3ded2bf
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -112,7 +112,8 @@ func (bs *BuilderSuite) createAndRecordBlock(parentBlock *flow.Block) *flow.Bloc | |||||||||||||
|
||||||||||||||
incorporatedResultForPrevBlock = unittest.IncorporatedResult.Fixture( | ||||||||||||||
unittest.IncorporatedResult.WithResult(previousResult), | ||||||||||||||
unittest.IncorporatedResult.WithIncorporatedBlockID(block.ID()), | ||||||||||||||
//unittest.IncorporatedResult.WithIncorporatedBlockID(block.ID()), | ||||||||||||||
unittest.IncorporatedResult.WithIncorporatedBlockID(parentBlock.ID()), | ||||||||||||||
) | ||||||||||||||
result := unittest.ExecutionResultFixture( | ||||||||||||||
unittest.WithBlock(&block), | ||||||||||||||
|
@@ -140,21 +141,11 @@ func (bs *BuilderSuite) createAndRecordBlock(parentBlock *flow.Block) *flow.Bloc | |||||||||||||
// IncorporatedResultSeal, which ties the seal to the incorporated result it | ||||||||||||||
// seals, is also recorded for future access. | ||||||||||||||
func (bs *BuilderSuite) chainSeal(incorporatedResult *flow.IncorporatedResult) { | ||||||||||||||
|
||||||||||||||
finalState, _ := incorporatedResult.Result.FinalStateCommitment() | ||||||||||||||
|
||||||||||||||
seal := &flow.Seal{ | ||||||||||||||
BlockID: incorporatedResult.Result.BlockID, | ||||||||||||||
ResultID: incorporatedResult.Result.ID(), | ||||||||||||||
FinalState: finalState, | ||||||||||||||
} | ||||||||||||||
bs.chain = append(bs.chain, seal) | ||||||||||||||
|
||||||||||||||
incorporatedResultSeal := &flow.IncorporatedResultSeal{ | ||||||||||||||
IncorporatedResult: incorporatedResult, | ||||||||||||||
Seal: seal, | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
incorporatedResultSeal := unittest.IncorporatedResultSeal.Fixture( | ||||||||||||||
unittest.IncorporatedResultSeal.WithResult(incorporatedResult.Result), | ||||||||||||||
unittest.IncorporatedResultSeal.WithIncorporatedBlockID(incorporatedResult.IncorporatedBlockID), | ||||||||||||||
) | ||||||||||||||
bs.chain = append(bs.chain, incorporatedResultSeal.Seal) | ||||||||||||||
bs.irsMap[incorporatedResultSeal.ID()] = incorporatedResultSeal | ||||||||||||||
bs.irsList = append(bs.irsList, incorporatedResultSeal) | ||||||||||||||
} | ||||||||||||||
|
@@ -524,15 +515,23 @@ func (bs *BuilderSuite) TestPayloadSealAllValid() { | |||||||||||||
bs.Assert().ElementsMatch(bs.chain, bs.assembled.Seals, "should have included valid chain of seals") | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func (bs *BuilderSuite) TestPayloadSealSomeValid() { | ||||||||||||||
// TestPayloadSealSomeValidOnFork verifies that builder only includes seals whose | ||||||||||||||
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. seems incomplete 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. Sorry, this entire test was an outdated artifact from work-in-progress. Removed it |
||||||||||||||
// | ||||||||||||||
// if an IncorporatedResultSeal is included in mempool, whose final state does not match the execution result | ||||||||||||||
func (bs *BuilderSuite) TestPayloadSealSomeValidOnFork_old() { | ||||||||||||||
// skipping this test: | ||||||||||||||
// * currently, the builder relies on the IncorporatedResultSeal to be constructed | ||||||||||||||
// correctly by the matching engine | ||||||||||||||
// * with the implementation of this test, the matching engine | ||||||||||||||
bs.T().Skip() | ||||||||||||||
|
||||||||||||||
bs.pendingSeals = bs.irsMap | ||||||||||||||
|
||||||||||||||
// add some invalid seals to the mempool | ||||||||||||||
for i := 0; i < 8; i++ { | ||||||||||||||
invalid := &flow.IncorporatedResultSeal{ | ||||||||||||||
IncorporatedResult: unittest.IncorporatedResultFixture(), | ||||||||||||||
Seal: unittest.SealFixture(), | ||||||||||||||
IncorporatedResult: unittest.IncorporatedResult.Fixture(), | ||||||||||||||
Seal: unittest.Seal.Fixture(), | ||||||||||||||
} | ||||||||||||||
bs.pendingSeals[invalid.ID()] = invalid | ||||||||||||||
} | ||||||||||||||
|
@@ -543,6 +542,54 @@ func (bs *BuilderSuite) TestPayloadSealSomeValid() { | |||||||||||||
bs.Assert().ElementsMatch(bs.chain, bs.assembled.Seals, "should have included only valid chain of seals") | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// TestPayloadSealSomeValidOnFork verifies that builder only includes seals whose | ||||||||||||||
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. seems incomplete 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. thanks for noticing. Fixed the test's doc. |
||||||||||||||
// | ||||||||||||||
// if an IncorporatedResultSeal is included in mempool, whose final state does not match the execution result | ||||||||||||||
AlexHentschel marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
func (bs *BuilderSuite) TestPayloadSealOnlyFork() { | ||||||||||||||
// skipping this test: | ||||||||||||||
// * currently, the builder relies on the IncorporatedResultSeal to be constructed | ||||||||||||||
// correctly by the matching engine | ||||||||||||||
// * with the implementation of this test, the matching engine | ||||||||||||||
//bs.T().Skip() | ||||||||||||||
AlexHentschel marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
||||||||||||||
// in the test setup, we already create a single fork | ||||||||||||||
// [first] <- [F0] <- [F1] <- [F2] <- [F3] <- [A0] <- [A1] <- [A2] <- [A3] | ||||||||||||||
// Where block | ||||||||||||||
// * [first] is sealed and finalized | ||||||||||||||
// * [F0] ... [F3] are finalized but _not_ sealed | ||||||||||||||
// * [A0] ... [A3] are _not_ finalized and _not_ sealed | ||||||||||||||
// We now create an additional fork: [F3] <- [B0] <- [B1] <- ... <- [B7] | ||||||||||||||
Comment on lines
+525
to
+530
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. I'm not quite clear how this tests work. 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. thanks for the reference. The test for the flow-go/module/builder/consensus/builder_test.go Lines 87 to 92 in addcb4b
it has some specialized functionality for testing the payload Builder :
I am inclined to keep the current test structure as I just added a test. 😅 |
||||||||||||||
var forkHead *flow.Block | ||||||||||||||
for f := 0; f < 100; f++ { | ||||||||||||||
AlexHentschel marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
forkHead = bs.blocks[bs.finalID] | ||||||||||||||
for i := 0; i < 8; i++ { | ||||||||||||||
forkHead = bs.createAndRecordBlock(forkHead) | ||||||||||||||
// Method createAndRecordBlock adds a seal for every block into the mempool. | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
bs.pendingSeals = bs.irsMap | ||||||||||||||
_, err := bs.build.BuildOn(forkHead.ID(), bs.setter) | ||||||||||||||
bs.Require().NoError(err) | ||||||||||||||
|
||||||||||||||
// expected seals: [F0] <- ... <- [F3] <- [B0] <- ... <- [B7] | ||||||||||||||
bs.Assert().Equal(12, len(bs.assembled.Seals), "should have included only valid chain of seals") | ||||||||||||||
bs.Assert().ElementsMatch(bs.chain[:4], bs.assembled.Seals[:4], "should have included only valid chain of seals") | ||||||||||||||
bs.Assert().Equal(bs.chain[len(bs.chain)-1], bs.assembled.Seals[len(bs.assembled.Seals)-1], "should have included only valid chain of seals") | ||||||||||||||
bs.Assert().Equal(bs.chain[len(bs.chain)-2], bs.assembled.Seals[len(bs.assembled.Seals)-2], "should have included only valid chain of seals") | ||||||||||||||
bs.Assert().Equal(bs.chain[len(bs.chain)-3], bs.assembled.Seals[len(bs.assembled.Seals)-3], "should have included only valid chain of seals") | ||||||||||||||
bs.Assert().Equal(bs.chain[len(bs.chain)-4], bs.assembled.Seals[len(bs.assembled.Seals)-4], "should have included only valid chain of seals") | ||||||||||||||
bs.Assert().Equal(bs.chain[len(bs.chain)-5], bs.assembled.Seals[len(bs.assembled.Seals)-5], "should have included only valid chain of seals") | ||||||||||||||
bs.Assert().Equal(bs.chain[len(bs.chain)-6], bs.assembled.Seals[len(bs.assembled.Seals)-6], "should have included only valid chain of seals") | ||||||||||||||
bs.Assert().Equal(bs.chain[len(bs.chain)-7], bs.assembled.Seals[len(bs.assembled.Seals)-7], "should have included only valid chain of seals") | ||||||||||||||
bs.Assert().Equal(bs.chain[len(bs.chain)-8], bs.assembled.Seals[len(bs.assembled.Seals)-8], "should have included only valid chain of seals") | ||||||||||||||
//bs.Assert().ElementsMatch(bs.chain[len(bs.chain)-8:], bs.assembled.Seals[4:], "should have included only valid chain of seals") | ||||||||||||||
|
||||||||||||||
//bs.Assert().ElementsMatch(bs.chain, bs.assembled.Seals, "should have included only valid chain of seals") | ||||||||||||||
bs.Assert().Empty(bs.assembled.Guarantees, "should have no guarantees in payload with empty mempool") | ||||||||||||||
|
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func (bs *BuilderSuite) TestPayloadSealCutoffChain() { | ||||||||||||||
|
||||||||||||||
// remove the seal at the start | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package mempool | ||
|
||
import "github.com/onflow/flow-go/model/flow" | ||
|
||
// OnEjection is a callback which a mempool executes on ejecting | ||
// one of its elements. The callbacks are executed from within the thread | ||
// that serves the mempool. Implementations should be non-blocking. | ||
type OnEjection func(flow.Entity) |
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
IncorporatedResult
is used to store approval signatures when they are received:flow-go/model/flow/incorporated_result.go
Line 26 in 7c48153
aggregatedSignatures
in the ID computation, this changes the ID of the entity, which should not be the case.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.
I don't think it changes the ID of the IncorporatedResult because
aggregatedSignatures
is a private field and is ignored in the RLP encoding which is used to calculate the IDThere 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.
💡 thanks for pointing this out @arrivets . I was not aware that RLP did skip private fields.
Obviously, I didn't read the test you wrote:
flow-go/model/flow/incorporated_result_test.go
Lines 12 to 14 in 49fb4a1
Rolled back my changes to
incorporated_result.go