Repository navigation
Commit e9a05f6
authored
Cx receipt fixes main (#5101)
* fix(quorum): count enabled bitmap bits, not committee size, for pre-staking quorum
uniformVerifier.IsQuorumAchievedByMask compared the full committee size
(len(mask.Publics)) against the threshold instead of counting bits actually
set in the signer bitmap. An all-zero bitmap paired with an all-zero
(identity) aggregate BLS signature therefore satisfied quorum for any
pre-staking-epoch committee, since len(mask.Publics) always exceeds the
threshold regardless of how many signers were enabled.
Count enabled bits via mask.IndexEnabled and reject a nil mask outright.
Add regression coverage: a mask-level table test for zero/below-threshold/
at-threshold/padding-bit bitmaps, and an engine-level test asserting that
verifySignature rejects an empty pre-staking quorum end-to-end.
* fix(core): key CX-receipt spent-marker off the signed header, not MerkleProof
IsSpent and WriteCXReceiptsProofSpent only derived the spent-marker key from
the signed block.Header (ShardID/Number) from IsCXMerkleProofReplayFixEpoch
onward. For any proof whose Header.Epoch() precedes that fork epoch, the key
fell back to CXMerkleProof.ShardID/BlockNum -- fields that ValidateCXReceiptsProof
never binds to the Header for those epochs. Since the Header (and therefore its
signature) can't be altered without invalidating VerifyHeaderSignature, but
MerkleProof.ShardID/BlockNum are otherwise unauthenticated, a genuine,
already-applied CXReceiptsProof could be resubmitted with a mutated
MerkleProof identity: each resubmission hashed to a different, "unspent"
key, letting ApplyIncomingReceipt credit the destination again with no
corresponding source debit.
Always derive the spent-marker key from the Header. This doesn't change what
ValidateCXReceiptsProof accepts, and is a no-op for honestly generated
proofs -- MerkleProof.ShardID/BlockNum are naturally populated from the same
source block as the Header, so the on-disk key is unchanged for real
historical data; only a proof with a deliberately mismatched MerkleProof
identity resolves to a different (correct) key than before.
Add TestIsSpentIgnoresMutatedMerkleProofIdentity covering the replay case.1 parent db22d51 commit e9a05f6
5 files changed
Lines changed: 137 additions & 10 deletions
File tree
- consensus/quorum
- core
- internal/chain
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
55 | 87 | | |
56 | 88 | | |
57 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
| 73 | + | |
75 | 74 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2708 | 2708 | | |
2709 | 2709 | | |
2710 | 2710 | | |
2711 | | - | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
2712 | 2719 | | |
2713 | 2720 | | |
2714 | 2721 | | |
| |||
2726 | 2733 | | |
2727 | 2734 | | |
2728 | 2735 | | |
2729 | | - | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
2730 | 2740 | | |
2731 | 2741 | | |
2732 | 2742 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
14 | 59 | | |
15 | 60 | | |
16 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
498 | 499 | | |
499 | 500 | | |
500 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
501 | 538 | | |
502 | 539 | | |
503 | 540 | | |
| |||
0 commit comments