Skip to content
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

ICS28: Handle pending proposals to spawn consumer chains #697

Merged
merged 77 commits into from
Apr 4, 2022
Merged
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
604b3ae
Create README.md
mpoke Jan 17, 2022
a9b6dad
Add files with CCV spec
mpoke Jan 17, 2022
312d108
fix links to ICS 4
mpoke Jan 17, 2022
4f2b2f8
fix links to ICS 7
mpoke Jan 17, 2022
0f826ac
add ICS 28 to main README.md
mpoke Jan 17, 2022
4c4550a
adding tech spec for unbonding delegations
mpoke Jan 18, 2022
106afe0
add context on unbonding operations
mpoke Jan 18, 2022
06a2eb2
add unbonding operation diagram
mpoke Jan 19, 2022
6085697
Update spec/app/ics-028-cross-chain-validation/overview_and_basic_con…
mpoke Jan 25, 2022
d2b7377
Update spec/app/ics-028-cross-chain-validation/overview_and_basic_con…
mpoke Jan 25, 2022
b132122
Update spec/app/ics-028-cross-chain-validation/system_model_and_prope…
mpoke Jan 25, 2022
e470c84
Update spec/app/ics-028-cross-chain-validation/technical_specificatio…
mpoke Jan 25, 2022
28e7131
Update spec/app/ics-028-cross-chain-validation/README.md
mpoke Jan 25, 2022
4bdcd8b
Update spec/app/ics-028-cross-chain-validation/README.md
mpoke Jan 25, 2022
dee8d30
minor, remove confusing phrasing
mpoke Jan 25, 2022
db69640
child -> consumer; parent -> provider
mpoke Jan 25, 2022
35cdcd8
clarify which staking module
mpoke Jan 25, 2022
ab41f91
extend staking assumptions, remove redundant inv, prove staking props…
mpoke Jan 25, 2022
45b038c
modify staking hooks spec to cover other unbonding ops
mpoke Jan 20, 2022
faac42c
Merge branch 'marius/ccv-init-and-vsc' into marius/ccv-staking-hooks
mpoke Jan 25, 2022
9631aba
provider Staking module
mpoke Jan 25, 2022
4c3f2db
Merge branch 'marius/ccv-staking-hooks' of github.com:cosmos/ibc into…
mpoke Jan 25, 2022
9ef5aef
break long lines
mpoke Jan 25, 2022
bdf3c48
break long lines
mpoke Jan 25, 2022
0d9edad
remove dependecies to Cosmos SDK
mpoke Jan 26, 2022
6afb942
Merge branch 'marius/ccv-init-and-vsc' into marius/ccv-staking-hooks
mpoke Jan 26, 2022
08ceb8a
changes in the security model
mpoke Jan 27, 2022
5c7da62
specify multiple consumer chains
mpoke Jan 27, 2022
9d25746
channel init overview
mpoke Jan 27, 2022
270cae8
Merge branch 'marius/ccv-init-and-vsc' into marius/ccv-staking-hooks
mpoke Jan 27, 2022
69b0a1f
address issues #27 and #33 from cosmos/interchain-security repo
mpoke Feb 10, 2022
01b7a3b
Merge branch 'marius/ccv-staking-hooks' of github.com:cosmos/ibc into…
mpoke Feb 10, 2022
495c8db
resolve merge conflict
mpoke Feb 10, 2022
ff8c173
extend consumer InitGenesis
mpoke Feb 14, 2022
69763bc
describe mechanism to disseminate genesis state
mpoke Feb 15, 2022
7db4308
describe mapping heights provider <> consumer
mpoke Feb 15, 2022
5b0302b
remove ExportGenesis and restarted chains
mpoke Feb 16, 2022
fccb14d
add overview of consumer initiated slashing
mpoke Feb 16, 2022
51872a6
add slashing invariant
mpoke Feb 17, 2022
cb1707a
add assumptions needed by evidence
mpoke Feb 17, 2022
a09d008
Update spec/app/ics-028-cross-chain-validation/overview_and_basic_con…
mpoke Feb 17, 2022
9982f76
draft CCV props for slashing
mpoke Feb 17, 2022
744ea88
replace time w/ height; add HtoVSC and VSCtoH
mpoke Feb 17, 2022
16dc913
replace time with height in invariants and properties
mpoke Feb 17, 2022
5a873e1
validate channel IDs on provider genesis
mpoke Feb 21, 2022
263d890
prove Slashing Invariant
mpoke Feb 21, 2022
29babea
enable mapping from consumer to provider heights
mpoke Feb 21, 2022
5977701
fix conflic: merge with marius/ccv-init-genesis
mpoke Feb 21, 2022
4166744
technical spec for slashing
mpoke Feb 22, 2022
fcc1c14
minor changes
mpoke Feb 22, 2022
9902ecd
fix links to tendermint spec
mpoke Feb 23, 2022
0484d32
clarify Staking vs Slashing modules
mpoke Feb 23, 2022
bda9108
replace VSC acks w/ VSCMaturedPackets
mpoke Feb 23, 2022
ee33c48
fix some TODOs
mpoke Feb 23, 2022
c983620
fix properties
mpoke Feb 24, 2022
7283049
Merge branch 'marius/ccv' into marius/ccv-staking-hooks
mpoke Feb 24, 2022
078fa97
Merge branch 'marius/ccv-staking-hooks' into marius/ccv-init-genesis
mpoke Feb 24, 2022
44b058a
Merge branch 'marius/ccv-init-genesis' into marius/ccv-evidence
mpoke Feb 24, 2022
3221e79
HtoVSC and VSCtoH from () to []
mpoke Feb 25, 2022
7ecb10e
fix infraction height and add intuition diagram
mpoke Feb 28, 2022
110e799
resolve merge conflict
mpoke Feb 28, 2022
8b0915b
keep ValidatorSet in consumer CCV module state
mpoke Mar 7, 2022
c904c21
remove CCV channel status
mpoke Mar 7, 2022
6889441
add outstanding downtime flag and decouple from validatorSet
mpoke Mar 8, 2022
72ae68f
adressing Josef's comment
mpoke Mar 8, 2022
e4aac3e
update init methods and ics26 methods
mpoke Mar 9, 2022
754aefd
fix merge conflicts
mpoke Mar 10, 2022
4608ab5
updating ValSet Update methods
mpoke Mar 10, 2022
4b20b7a
Merge branch 'marius/ccv-evidence' into marius/668-ccv-channel-state
mpoke Mar 10, 2022
d0293b4
updating Consumer Initiated Slashing methods
mpoke Mar 10, 2022
f2fbb66
fix issues pointed by Simon
mpoke Mar 11, 2022
e0401ee
dealing with downtime slashing atomicity
mpoke Mar 11, 2022
974224c
Merge branch 'marius/ccv-evidence' into marius/668-ccv-channel-state
mpoke Mar 11, 2022
cabc738
resolve merge conflict
mpoke Mar 11, 2022
9791e36
resolve conflicts when merging base
mpoke Mar 23, 2022
1328fa4
handle pending proposals
mpoke Mar 23, 2022
c801e7f
Merge branch 'marius/ccv' into marius/683-ccv-pending-clients
mpoke Apr 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 79 additions & 38 deletions spec/app/ics-028-cross-chain-validation/technical_specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,16 @@ This section describes the internal state of the CCV module. For simplicity, the
#### State on the provider chain

- `ProviderPortId = "provider"` is the port ID the provider CCV module is expected to bind to.
- `pendingClient: Map<(Timestamp, string), Height>` is a mapping from `(timestamp, chainId)` tuples to the initial height of pending clients, i.e., belonging to consumer chains that were not yet spawned, but for which a `CreateConsumerChainProposal` was received.
- `pendingProposals: [CreateConsumerChainProposal]` is a list of pending proposals to spawn new consumer chains. The list exposes the following interface:
```typescript
interface [CreateConsumerChainProposal] {
// append a proposal to the list; the list is modified
Append(p: CreateConsumerChainProposal)

// remove a proposal from the list; the list is modified
Remove(p: CreateConsumerChainProposal)
}
```
- `chainToClient: Map<string, Identifier>` is a mapping from consumer chain IDs to the associated client IDs.
- `chainToChannel: Map<string, Identifier>` is a mapping from consumer chain IDs to the CCV channel IDs.
- `channelToChain: Map<Identifier, string>` is a mapping from CCV channel IDs to consumer chain IDs.
Expand Down Expand Up @@ -305,6 +314,7 @@ This section describes the internal state of the CCV module. For simplicity, the
// the list is modified
RemoveAll()
}
```
- `HtoVSC: Map<Height, uint64>` is a mapping from consumer chain heights to VSC IDs. It enables the mapping from consumer heights to provider heights., i.e.,
- if `HtoVSC[h] == 0`, then the voting power on the consumer chain at height `h` was setup at genesis during Channel Initialization;
- otherwise, the voting power on the consumer chain at height `h` was updated by the VSC with ID `HtoVSC[h]`.
Expand Down Expand Up @@ -400,37 +410,11 @@ function InitGenesis(state: ProviderGenesisState): [ValidatorUpdate] {
// implements governance proposal Handler
function CreateConsumerChainProposal(p: CreateConsumerChainProposal) {
if currentTimestamp() > p.spawnTime {
// get UnbondingPeriod from provider Staking module
unbondingTime = stakingKeeper.UnbondingTime()

// create client state as defined in ICS 7
clientState = ClientState{
chainId: p.chainId,
trustLevel: DefaultTrustLevel, // 1/3
trustingPeriod: unbondingTime/2,
unbondingPeriod: unbondingTime,
latestHeight: p.initialHeight,
}

// create consensus state as defined in ICS 7;
// SentinelRoot is used as a stand-in root value for
// the consensus state set at the upgrade height;
// the validator set is the same as the validator set
// from own consensus state at current height
ownConsensusState = getConsensusState(getCurrentHeight())
consensusState = ConsensusState{
timestamp: currentTimestamp(),
commitmentRoot: SentinelRoot,
validatorSet: ownConsensusState.validatorSet,
}

// create consumer chain client and store it
clientId = clientKeeper.CreateClient(clientState, consensusState)
chainToClient[p.chainId] = clientId
CreateConsumerClient(p)
}
else {
// store the client as a pending client
pendingClient[(p.spawnTime, p.chainId)] = p.initialHeight
// store the proposal as a pending proposal
pendingProposals.Append(p)
}
}
```
Expand All @@ -441,19 +425,66 @@ function CreateConsumerChainProposal(p: CreateConsumerChainProposal) {
- **Precondition**
- True.
- **Postcondition**
- If the spawn time has already passed,
- `UnbondingPeriod` is retrieved from the provider Staking module;
- a client state is created;
- a consensus state is created;
- a client of the consumer chain is created and the client ID is added to `chainToClient`.
- Otherwise, the client is stored in `pendingClient` as a pending client.
- If the spawn time has already passed, `CreateConsumerClient(p)` is invoked, with `p` the `CreateConsumerChainProposal`.
- Otherwise, the proposal is appended to the list of pending proposals, i.e., `pendingProposals`.
- **Error Condition**
- None.

<!-- omit in toc -->
#### **[CCV-PCF-CRCLIENT.1]**
```typescript
// PCF: Provider Chain Function
// Utility method
function CreateConsumerClient(p: CreateConsumerChainProposal) {
// get UnbondingPeriod from provider Staking module
// TODO governance and CCV params
// see https://github.com/cosmos/ibc/issues/673
unbondingTime = stakingKeeper.UnbondingTime()

// create client state as defined in ICS 7
clientState = ClientState{
chainId: p.chainId,
trustLevel: DefaultTrustLevel, // i.e., 1/3
trustingPeriod: unbondingTime/2,
unbondingPeriod: unbondingTime,
latestHeight: p.initialHeight,
}

// create consensus state as defined in ICS 7;
// SentinelRoot is used as a stand-in root value for
// the consensus state set at the upgrade height;
// the validator set is the same as the validator set
// from own consensus state at current height
ownConsensusState = getConsensusState(getCurrentHeight())
consensusState = ConsensusState{
timestamp: currentTimestamp(),
commitmentRoot: SentinelRoot,
validatorSet: ownConsensusState.validatorSet,
}

// create consumer chain client and store it
clientId = clientKeeper.CreateClient(clientState, consensusState)
chainToClient[p.chainId] = clientId
}
```
- **Caller**
- Either `CreateConsumerChainProposal` (see [CCV-PCF-CCPROP.1](#ccv-pcf-ccprop1)) or `BeginBlock()` (see [CCV-PCF-BBLOCK.1](#ccv-pcf-bblock1)).
- **Trigger Event**
- A governance proposal with `CreateConsumerChainProposal` as content has passed (i.e., it got the necessary votes).
- **Precondition**
- `currentTimestamp() > spawnTime`, where `spawnTime` is contained by the `CreateConsumerChainProposal`.
- **Postcondition**
- `UnbondingPeriod` is retrieved from the provider Staking module.
- A client state is created (as defined in [ICS 7](../../core/ics-002-client-semantics)).
- A consensus state is created (as defined in [ICS 7](../../core/ics-002-client-semantics)).
- A client of the consumer chain is created and the client ID is added to `chainToClient`.
- **Error Condition**
- None.

> **Note:** Creating a client of a remote chain requires a `ClientState` and a `ConsensusState` (as defined in [ICS 7](../../core/ics-002-client-semantics)).
> `ConsensusState` requires setting a validator set of the remote chain.
> The provider chain uses the fact that the validator set of the consumer chain is the same as its own validator set.
> The rest of information to create a `ClientState` it receives through a governance proposal.
> The rest of information to create a `ClientState` it receives through the governance proposal.

<!-- omit in toc -->
#### **[CCV-PCF-COINIT.1]**
Expand Down Expand Up @@ -1103,6 +1134,14 @@ The *validator set update* sub-protocol enables the provider chain
// CCF: Provider Chain Function
// implements the AppModule interface
function BeginBlock() {
// iterate over the pending proposals and create
// the consumer client if the spawn time has passed
foreach p IN pendingProposals {
if currentTimestamp() > p.spawnTime {
CreateConsumerClient(p)
pendingProposals.Remove(p)
}
}
}
```
- **Caller**
Expand All @@ -1112,7 +1151,9 @@ function BeginBlock() {
- **Precondition**
- True.
- **Postcondition**
- The state is not changed.
- For each `CreateConsumerChainProposal` `p` in the list of pending proposals `pendingProposals`, if `currentTimestamp() > p.spawnTime`, then
- `CreateConsumerClient(p)` is invoked;
- `p` is removed from `pendingProposals`.
- **Error Condition**
- None.

Expand Down