Skip to content

Commit e164f9f

Browse files
authored
Rename CAP-0083 + add meta example (#1940)
* Rename CAP-0083 + add meta example This change renames `STELLAR_VALUE_SKIP` to `STELLAR_VALUE_EMPTY_TX_SET` based on feedback on the name "skip" being misleading. It also adds example `LedgerCloseData` meta. * Fix a few missed "skip" usages that copilot found
1 parent a7f52d0 commit e164f9f

2 files changed

Lines changed: 129 additions & 42 deletions

File tree

core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
| [CAP-0080](cap-0080.md) | 26 | Host functions for efficient ZK BN254 use cases | Siddharth Suresh | Implemented |
9696
| [CAP-0081](cap-0081.md) | TBD | TTL-Ordered Eviction | Garand Tyson | Accepted |
9797
| [CAP-0082](cap-0082.md) | 26 | Checked 256-bit integer arithmetic host functions | Jay Geng | Implemented |
98-
| [CAP-0083](cap-0083.md) | TBD | Allow validators to vote to skip the current ledger | Brett Boston | Awaiting Decision |
98+
| [CAP-0083](cap-0083.md) | TBD | Allow validators to vote to drop the transaction set from the current ledger | Brett Boston | Awaiting Decision |
9999

100100
### Draft Proposals
101101
| Number | Title | Author | Status |

core/cap-0083.md

Lines changed: 128 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
```
44
CAP: 0083
5-
Title: Allow validators to vote to skip the current ledger
5+
Title: Allow validators to vote to drop the transaction set from the current ledger
66
Working Group:
77
Owner: Brett Boston <@bboston7>
88
Authors: Brett Boston <@bboston7>
@@ -16,26 +16,26 @@ Protocol version: TBD
1616
## Simple Summary
1717

1818
This CAP introduces a new `StellarValue` type to allow validators to explicitly
19-
skip the ledger that is being voted on. It also relaxes validation criteria on
20-
PREPARE messages.
19+
drop the transaction set from the ledger that is being voted on. It also relaxes
20+
validation criteria on PREPARE messages.
2121

2222
## Working Group
2323

2424
As specified in the preamble.
2525

2626
## Motivation
2727

28-
Providing a mechanism for validators to explicitly vote to skip ledgers allows
29-
them to conduct some SCP voting prior to receiving a transaction set. This will
30-
improve SCP performance, as transaction set dissemination is costly and
31-
validators can safely make initial progress on consensus while waiting for
28+
Providing a mechanism for validators to explicitly vote to drop transaction sets
29+
allows them to conduct some SCP voting prior to receiving a transaction set.
30+
This will improve SCP performance, as transaction set dissemination is costly
31+
and validators can safely make initial progress on consensus while waiting for
3232
transaction sets.
3333

3434
If, during the PREPARE phase of balloting, a validator has not received the
3535
transaction set being voted on within a reasonable amount of time, or the
36-
transaction set is invalid, they may vote to skip the current ledger. This
37-
prevents consensus from getting stuck waiting for a transaction set that may
38-
never arrive, as a valid transaction set is required before moving on to the
36+
transaction set is invalid, they may vote to drop it from the current ledger.
37+
This prevents consensus from getting stuck waiting for a transaction set that
38+
may never arrive, as a valid transaction set is required before moving on to the
3939
CONFIRM phase of balloting.
4040

4141
Relaxing validity checks on PREPARE messages is necessary to enable early
@@ -50,11 +50,12 @@ This CAP is aligned with the following Stellar Network Goal:
5050

5151
## Abstract
5252

53-
This CAP introduces a new `StellarValue` extension type `STELLAR_VALUE_SKIP`.
54-
With this change, validators may switch their ballot to a `STELLAR_VALUE_SKIP`
55-
during the PREPARE phase of balloting prior to setting `c`[^1].
56-
`STELLAR_VALUE_SKIP` includes information about the value that a validator was
57-
considering before switching to voting to skip the ledger.
53+
This CAP introduces a new `StellarValue` extension type
54+
`STELLAR_VALUE_EMPTY_TX_SET`. With this change, validators may switch their
55+
ballot to a `STELLAR_VALUE_EMPTY_TX_SET` during the PREPARE phase of balloting
56+
prior to setting `c`[^1]. `STELLAR_VALUE_EMPTY_TX_SET` includes information
57+
about the value that a validator was considering before switching to voting to
58+
drop the transaction set.
5859

5960
This CAP also relaxes the validation of PREPARE messages to permit invalid
6061
transaction sets. This change ensures the network does not drop ballots from
@@ -65,7 +66,8 @@ early balloting stages.
6566

6667
### XDR changes
6768

68-
To enable ledger skipping, this CAP proposes the following change to
69+
To enable explicitly empty transaction sets, this CAP proposes the following
70+
change to
6971
`Stellar-ledger.x`:
7072

7173
```diff mddiffcheck.base=0a621ec7811db000a60efae5b35f78dee3aa2533
@@ -79,15 +81,15 @@ index a17036b..667f8e7 100644
7981
STELLAR_VALUE_BASIC = 0,
8082
- STELLAR_VALUE_SIGNED = 1
8183
+ STELLAR_VALUE_SIGNED = 1,
82-
+ STELLAR_VALUE_SKIP = 2
84+
+ STELLAR_VALUE_EMPTY_TX_SET = 2
8385
};
8486

8587
struct LedgerCloseValueSignature
8688
@@ -43,6 +44,14 @@ struct StellarValue
8789
void;
8890
case STELLAR_VALUE_SIGNED:
8991
LedgerCloseValueSignature lcValueSignature;
90-
+ case STELLAR_VALUE_SKIP:
92+
+ case STELLAR_VALUE_EMPTY_TX_SET:
9193
+ struct
9294
+ {
9395
+ Hash txSetHash;
@@ -124,7 +126,7 @@ struct StellarValue
124126
void;
125127
case STELLAR_VALUE_SIGNED:
126128
LedgerCloseValueSignature lcValueSignature;
127-
case STELLAR_VALUE_SKIP:
129+
case STELLAR_VALUE_EMPTY_TX_SET:
128130
struct
129131
{
130132
Hash txSetHash;
@@ -139,29 +141,112 @@ struct StellarValue
139141

140142

141143
#### XDR Example
142-
TBD
144+
The stellar-core repo contains [an example `LedgerCloseData` meta file demonstrating the application of a `STELLAR_VALUE_EMPTY_TX_SET` ledger](https://github.com/stellar/stellar-core/blob/master/test-lcm/HerderTests/370dd5e0af5cfa8d.xdr).
145+
For readability, this CAP provides a JSON-ified version of this XDR below.
146+
```json
147+
[
148+
{
149+
"v": 2,
150+
"v2": {
151+
"ext": {
152+
"v": 0
153+
},
154+
"ledgerHeader": {
155+
"hash": "797ed2ec897cb6faac1b103cc6f027b5af5075ddf39039e973555d71613a1851",
156+
"header": {
157+
"ledgerVersion": 27,
158+
"previousLedgerHash": "2585cbeb05e12e8112f89e78d91e6c8c5a75fc08b91d7539773a48a8b6a35b3a",
159+
"scpValue": {
160+
"txSetHash": "0000000000000000000000000000000000000000000000000000000000000000",
161+
"closeTime": 15,
162+
"upgrades": [],
163+
"ext": {
164+
"v": "STELLAR_VALUE_EMPTY_TX_SET",
165+
"proposedValue": {
166+
"txSetHash": "827145925ccb74c257c14372b8325ccb9f4af0099e57025e777a6e2cb365acaf",
167+
"previousLedgerHash": "2585cbeb05e12e8112f89e78d91e6c8c5a75fc08b91d7539773a48a8b6a35b3a",
168+
"previousLedgerVersion": 27,
169+
"lcValueSignature": {
170+
"nodeID": "GAXSR3PPLX3TDFUXXQ2GGOCQISJKADKKFAJ72PEEYKA3DV6MJ6FCG4O6",
171+
"signature": "05aadb43376fa6544048fb646212b987f9aec110a65c2e9d02806c9dca51d7ed9286d71e68f68a13b0af7efd5b95b6b928d0d8f4c7ed03a327786fbd1a287c03"
172+
}
173+
}
174+
}
175+
},
176+
"txSetResultHash": "df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b81119",
177+
"bucketListHash": "ff0815329f0269bcfdb3385fb751f1db076c88da3028f9733d302d564565b551",
178+
"ledgerSeq": 5,
179+
"totalCoins": 1000000000000000000,
180+
"feePool": 0,
181+
"inflationSeq": 0,
182+
"idPool": 0,
183+
"baseFee": 100,
184+
"baseReserve": 100000000,
185+
"maxTxSetSize": 50,
186+
"skipList": [
187+
"0000000000000000000000000000000000000000000000000000000000000000",
188+
"0000000000000000000000000000000000000000000000000000000000000000",
189+
"0000000000000000000000000000000000000000000000000000000000000000",
190+
"0000000000000000000000000000000000000000000000000000000000000000"
191+
],
192+
"ext": {
193+
"v": 0
194+
}
195+
},
196+
"ext": {
197+
"v": 0
198+
}
199+
},
200+
"txSet": {
201+
"v": 1,
202+
"v1TxSet": {
203+
"previousLedgerHash": "2585cbeb05e12e8112f89e78d91e6c8c5a75fc08b91d7539773a48a8b6a35b3a",
204+
"phases": [
205+
{
206+
"v": 0,
207+
"v0Components": []
208+
},
209+
{
210+
"v": 1,
211+
"parallelTxsComponent": {
212+
"baseFee": null,
213+
"executionStages": []
214+
}
215+
}
216+
]
217+
}
218+
},
219+
"txProcessing": [],
220+
"upgradesProcessing": [],
221+
"scpInfo": [],
222+
"totalByteSizeOfLiveSorobanState": 0,
223+
"evictedKeys": []
224+
}
225+
}
226+
]
227+
```
143228

144-
### Skip Value Semantics
229+
### Empty Transaction Set Value Semantics
145230

146-
#### Skip Value Representation
231+
#### Empty Transaction Set Value Representation
147232

148-
When the network votes to skip the ledger, validators will externalize a `StellarValue` with fields set as follows:
233+
When the network votes to drop a transaction set, validators will externalize a `StellarValue` with fields set as follows:
149234

150235
* `txSetHash` : Set to `0x0`
151236
* `closeTime` : Set as usual
152237
* `upgrades` : Set as usual
153-
* `ext` : Set to `STELLAR_VALUE_SKIP`
154-
* `proposedValue` : Details about the original `StellarValue` that a quorum of validators decided to skip.
238+
* `ext` : Set to `STELLAR_VALUE_EMPTY_TX_SET`
239+
* `proposedValue` : Details about the original `StellarValue` that a quorum of validators decided to drop the transaction set from.
155240
* `proposedValue.txSetHash` : The hash of the transaction set that was insufficiently disseminated or invalid.
156-
* `proposedValue.previousLedgerHash` : The hash of the ledger prior to this one. Used to construct an empty transaction set corresponding to this skip value.
157-
* `proposedValue.previousLedgerVersion` : The ledger version of the previous ledger. Used to construct an empty transaction set corresponding to this skip value.
241+
* `proposedValue.previousLedgerHash` : The hash of the ledger prior to this one. Used to construct an empty transaction set corresponding to this empty-tx-set value.
242+
* `proposedValue.previousLedgerVersion` : The ledger version of the previous ledger. Used to construct an empty transaction set corresponding to this empty-tx-set value.
158243
* `proposedValue.lcValueSignature` : The signature from the original `StellarValue`. Can be used to determine which validator proposed the original `StellarValue`.
159244

160-
#### Skip Value Application
245+
#### Empty Transaction Set Value Application
161246

162-
At apply time, ledgers containing a skip value should be treated as ledgers with
163-
empty transaction sets. In every other way, they should be treated as normal
164-
`STELLAR_VALUE_SIGNED` ledgers.
247+
At apply time, ledgers containing a `STELLAR_VALUE_EMPTY_TX_SET` value should be
248+
treated as any other ledger with an empty transaction set. In every other way,
249+
they should be treated as normal `STELLAR_VALUE_SIGNED` ledgers.
165250

166251
### PREPARE Message Validation
167252

@@ -177,20 +262,20 @@ ballots for `STELLAR_VALUE_SIGNED` values with invalid transaction sets.
177262

178263
We considered a few alternative methods to achieve parallel downloading of transaction sets before landing on this protocol change:
179264

180-
* Rather than skipping a ledger on failure to download a transaction set, we looked into rolling back SCP to an earlier phase. However, this would be a large change to SCP, which was not designed to ever step backwards. We decided it was cleaner, and easier to verify the change if validators instead voted to skip the current ledger.
181-
* We analyzed how far along consensus a validator could safely proceed without a transaction set if there was no skip or rollback mechanism, and decided that the lack of such a mechanism was too limiting. Without some method for validators to agree that a transaction set is unavailable, it is only safe to proceed with early nomination voting.
265+
* Rather than dropping a transaction set on failure to download a transaction set, we looked into rolling back SCP to an earlier phase. However, this would be a large change to SCP, which was not designed to ever step backwards. We decided it was cleaner, and easier to verify the change if validators instead voted to drop the transaction set from the current ledger.
266+
* We analyzed how far along consensus a validator could safely proceed without a transaction set if there was no drop or rollback mechanism, and decided that the lack of such a mechanism was too limiting. Without some method for validators to agree that a transaction set is unavailable, it is only safe to proceed with early nomination voting.
182267

183268
## Protocol Upgrade Transition
184269

185-
`STELLAR_VALUE_SKIP` values will become valid on the network at the protocol boundary. However, validators will not generate them unless they have enabled parallel transaction set downloading. Parallel transaction set downloading will initially be disabled by default, and we would like to gradually enable it across the validator network.
270+
`STELLAR_VALUE_EMPTY_TX_SET` values will become valid on the network at the protocol boundary. However, validators will not generate them unless they have enabled parallel transaction set downloading. Parallel transaction set downloading will initially be disabled by default, and we would like to gradually enable it across the validator network.
186271

187272
Validation of PREPARE messages will be relaxed at the protocol boundary.
188273

189274
### Downstream Impact
190275

191-
Downstream consumers of `StellarValue`s may require modification. Specifically, those that reason about `txSetHash` will need to handle the new `0x0` value, and those that reason about `ext` will need to handle the new `STELLAR_VALUE_SKIP` extension.
276+
Downstream consumers of `StellarValue`s may require modification. Specifically, those that reason about `txSetHash` will need to handle the new `0x0` value, and those that reason about `ext` will need to handle the new `STELLAR_VALUE_EMPTY_TX_SET` extension.
192277

193-
To help determine if you depend on something that contains a `StellarValue`, transitive dependencies on `StellarValue` are as follows:
278+
To help determine if you depend on something that contains a `StellarValue`, transitive dependencies on `StellarValue` (outside of the SCP messages already discussed in this CAP) are as follows:
194279
```
195280
StellarValue
196281
@@ -209,7 +294,7 @@ StellarValue
209294
└──► StoredDebugTransactionSet.scpValue
210295
```
211296

212-
Downstream consumers of `StellarValue`s should treat skipped ledgers as empty ledgers.
297+
Downstream consumers of `StellarValue`s should treat ledgers containing `STELLAR_VALUE_EMPTY_TX_SET` as empty ledgers.
213298

214299
### Backwards Incompatibilities
215300
As detailed in the previous section, downstream consumers of `StellarValue`s may require modification.
@@ -218,15 +303,17 @@ As detailed in the previous section, downstream consumers of `StellarValue`s may
218303
We expect this change to increase throughput on validators by expediting consensus. Simulation has shown this to be manageable. However, we will rollout the parallel downloading portion of this change slowly to ensure that real-world performance data matches simulation.
219304

220305
## Security Concerns
221-
This CAP introduces a new method by which malicious validators could negatively impact the network. A malicious validator could introduce bad transaction set hashes, which then force the network to skip a ledger after some delay. However, this attack is mitigated by the following factors:
306+
This CAP introduces a new method by which malicious validators could negatively impact the network. A malicious validator could introduce bad transaction set hashes, which then force the network to externalize an empty ledger after some delay. However, this attack is mitigated by the following factors:
222307

223308
* The attacker would have to win leader election to propose the bad value. This limits the frequency with which this attack can be pulled off.
224-
* By design, we include the original value that was skipped in the `STELLAR_VALUE_SKIP` struct, including the signature for the value. This enables node operators to easily determine which validators are misbehaving and remove them from their quorum sets.
309+
* By design, we include the original value that was dropped in the `STELLAR_VALUE_EMPTY_TX_SET` struct, including the signature for the value. This enables node operators to easily determine which validators are misbehaving and remove them from their quorum sets.
225310

226311
## Test Cases
227-
TBD
312+
The [pull request that implements this feature](https://github.com/stellar/stellar-core/pull/5209) contains many tests for it. Of particular interest to CAP readers might be the test "network externalizes empty-tx-set on missing value", which generates `LedgerCloseData` meta for `STELLAR_VALUE_EMPTY_TX_SET` ledgers when run with the `--capture-lcm` flag.
313+
314+
Future pull requests will introduce an automated test harness that stresses a large number of interleavings for transaction set arrival and SCP messages.
228315

229316
## Implementation
230-
Draft implementation: https://github.com/stellar/stellar-core/pull/5209
317+
Implementation: https://github.com/stellar/stellar-core/pull/5209
231318

232319
[^1]: See the [SCP IETF draft](https://www.ietf.org/archive/id/draft-mazieres-dinrg-scp-05.txt) for a complete semantics of `c`

0 commit comments

Comments
 (0)