-
Notifications
You must be signed in to change notification settings - Fork 884
feat(autobahn): Add epoch.Registry to maintain committee/stake (CON-358) #3632
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
base: main
Are you sure you want to change the base?
Changes from all commits
f7d5ac1
29bbe85
44a64af
4a229bf
b7c404d
c48ac8c
16b592b
007cbba
4525d76
b131531
5e333d0
5018935
70550fd
93e1d0c
5224d3b
7384fa1
d6c48c2
b3880ab
00a7b13
293f53b
854d64f
66c6b13
7ea9e48
a849604
9e2dabb
582e42d
6aadef5
43c8b8b
395d4b1
c3f163c
3a7ab7f
3d4ca8b
139c114
4773c02
b0bb2e8
412ea86
250cf6e
68d56dd
afb324c
68d4631
b8700e8
5828931
56d67e2
66934ec
35dcdeb
d399716
d886dcd
7c8bf25
6e91151
e2361ca
b98c4b0
ed2a4a6
b8a2664
538de3f
d460c75
176ad8a
32c6c22
9bb19e1
3316902
e057aa8
9423daa
f3ebc6f
ae92ce1
a4f736c
d0e59a6
aef198e
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 |
|---|---|---|
|
|
@@ -18,11 +18,12 @@ type AppProposal struct { | |
| globalNumber GlobalBlockNumber | ||
| roadIndex RoadIndex | ||
| appHash AppHash | ||
| epochIndex uint64 | ||
| } | ||
|
|
||
| // NewAppProposal creates a new AppProposal. | ||
| func NewAppProposal(globalNumber GlobalBlockNumber, roadIndex RoadIndex, appHash AppHash) *AppProposal { | ||
| return &AppProposal{globalNumber: globalNumber, roadIndex: roadIndex, appHash: appHash} | ||
| func NewAppProposal(globalNumber GlobalBlockNumber, roadIndex RoadIndex, appHash AppHash, epochIndex uint64) *AppProposal { | ||
| return &AppProposal{globalNumber: globalNumber, roadIndex: roadIndex, appHash: appHash, epochIndex: epochIndex} | ||
| } | ||
|
|
||
| // GlobalNumber . | ||
|
|
@@ -34,6 +35,9 @@ func (m *AppProposal) RoadIndex() RoadIndex { return m.roadIndex } | |
| // AppHash . | ||
| func (m *AppProposal) AppHash() AppHash { return m.appHash } | ||
|
|
||
| // EpochIndex returns the epoch this proposal belongs to. | ||
| func (m *AppProposal) EpochIndex() uint64 { return m.epochIndex } | ||
|
|
||
| // Next is the next global block number to compute AppHash for. | ||
| func (m *AppProposal) Next() RoadIndex { | ||
| return m.RoadIndex() + 1 | ||
|
|
@@ -44,9 +48,12 @@ func (m *AppProposal) Verify(c *Committee, qc *CommitQC) error { | |
| if got, want := m.RoadIndex(), qc.Proposal().Index(); got != want { | ||
| return fmt.Errorf("roadIndex() = %v, want %v", got, want) | ||
| } | ||
| if got, want := m.GlobalNumber(), qc.GlobalRange(c); got < want.First || got >= want.Next { | ||
| if got, want := m.GlobalNumber(), qc.GlobalRange(); got < want.First || got >= want.Next { | ||
|
cursor[bot] marked this conversation as resolved.
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. [suggestion] AppProposal.Verify checks roadIndex and global-number range against the CommitQC but does not bind the epoch. In PushAppVote the committee is selected from the vote's self-declared EpochIndex(), so once more than one epoch exists a vote signed under the wrong (e.g. outgoing) epoch could still be accepted and counted toward an AppQC for a CommitQC from a different epoch whenever road/global numbers line up — and that AppQC then drives pruning. Not exploitable today (registry only ever holds epoch 0), but per this PR's stated intent of surfacing such bugs at the call site, add a check here (or in PushAppVote) that m.EpochIndex() == qc.Proposal().EpochIndex(). (Codex finding #1.) |
||
| return fmt.Errorf("globalNumber() = %v, want in range [%v,%v)", got, want.First, want.Next) | ||
| } | ||
| if got, want := m.EpochIndex(), qc.Proposal().EpochIndex(); got != want { | ||
| return fmt.Errorf("epoch_index = %d, want %d", got, want) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
|
|
@@ -57,6 +64,7 @@ var AppProposalConv = protoutils.Conv[*AppProposal, *pb.AppProposal]{ | |
| GlobalNumber: utils.Alloc(uint64(m.globalNumber)), | ||
| RoadIndex: utils.Alloc(uint64(m.roadIndex)), | ||
| AppHash: m.appHash, | ||
| EpochIndex: utils.Alloc(m.epochIndex), | ||
| } | ||
| }, | ||
| Decode: func(m *pb.AppProposal) (*AppProposal, error) { | ||
|
|
@@ -66,10 +74,14 @@ var AppProposalConv = protoutils.Conv[*AppProposal, *pb.AppProposal]{ | |
| if m.RoadIndex == nil { | ||
| return nil, fmt.Errorf("RoadIndex: missing") | ||
| } | ||
| if m.EpochIndex == nil { | ||
| return nil, fmt.Errorf("EpochIndex: missing") | ||
| } | ||
| return &AppProposal{ | ||
| globalNumber: GlobalBlockNumber(*m.GlobalNumber), | ||
| roadIndex: RoadIndex(*m.RoadIndex), | ||
| appHash: AppHash(m.AppHash), | ||
| epochIndex: *m.EpochIndex, | ||
| }, nil | ||
| }, | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.