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: Cross-Chain Validation V1 #666

Merged
merged 34 commits into from
Aug 9, 2022
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
79becaf
ICS 28 CCV draft w/ init and validator set update (#640)
mpoke Feb 10, 2022
e548e72
merge CODEOWNERS from master
mpoke Feb 24, 2022
f637f0c
ICS28: CCV draft w/ complete unbonding (#646)
mpoke Feb 28, 2022
0f132dc
ICS28: Extend consumer InitGenesis (#659)
mpoke Feb 28, 2022
5292796
ICS28: Consumer Initiated Slashing (aka Evidence) (#663)
mpoke Mar 23, 2022
723af4d
ICS28: Remove CCV channel state (#678)
mpoke Mar 23, 2022
c626454
Update technical_specification.md
mpoke Mar 28, 2022
28d46ee
ICS28: Replace "Initiator" w/ "Caller" and “Trigger Event” (#696)
mpoke Apr 4, 2022
51dd64d
ICS28: Handle pending proposals to spawn consumer chains (#697)
mpoke Apr 4, 2022
2322702
ICS28: Remove genesisHash from specification (#699)
mpoke Apr 4, 2022
a6c9861
ICS28: CCV Reward Distribution subprotocol (#704)
mpoke Apr 20, 2022
6a04566
ICS28: Set initH in onChanOpenConfirm (#705)
mpoke Apr 20, 2022
dfc0398
ICS28: Enable the removal of a consumer chain from the provider (#707)
mpoke May 10, 2022
484b02c
ICS28: Remove BeforeUnbondingOpCompleted (#711)
mpoke May 10, 2022
9bdba66
ICS28: Update SlashPacketData (#728)
mpoke May 10, 2022
a6bc8d1
ICS28: Remove dependency on Tendermint and ABCI (#730)
mpoke May 11, 2022
0b3c84a
call UnbondMaturePackets() earlier (#747)
mpoke May 20, 2022
b7611ae
fix edge case enabled by aggregation (#746)
mpoke May 20, 2022
a635623
Use `h < hp'` instead of `h <= hp'` in Bond-Based Consumer Voting Pow…
danwt May 20, 2022
fe3c111
replace slashRequests w/ downtimeSlashRequests (#745)
mpoke May 20, 2022
76f2577
ics28 update sendPacket (#756)
mpoke May 23, 2022
3842922
ICS28: Restructure technical spec (#760)
mpoke Jun 9, 2022
ad30596
ICS28: Unbonding ops are put on hold even w/o consumer chains (#763)
mpoke Jun 9, 2022
5be51c0
Use currentTimestamp() >= p.stopTime in StopConsumerChainProposalHand…
danwt Jun 20, 2022
3713192
adding consumerUnbondingPeriod (#771)
mpoke Jun 23, 2022
6187e04
fix sendFungibleTokens signature
mpoke Jun 23, 2022
f1b1040
Merge branch 'master' into marius/ccv
mpoke Jun 23, 2022
7ea1ce6
Merge branch 'marius/ccv' of github.com:cosmos/ibc into marius/ccv
mpoke Jun 23, 2022
6ebbd60
add authors
mpoke Jun 24, 2022
5265e0b
ICS28: Removing the only consumer chain (#770)
mpoke Jun 27, 2022
b967c18
add conditions for CreateConsumerClient and StopConsumerChain (#775)
mpoke Jun 27, 2022
5ea9021
update created date
mpoke Jun 27, 2022
5d3b778
Merge branch 'main' into marius/ccv
mpoke Aug 1, 2022
195c36c
ICS28: Account for slashing in Bond-Based Consumer Voting Power prope…
mpoke Aug 3, 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
Prev Previous commit
Next Next commit
ICS28: Handle pending proposals to spawn consumer chains (#697)
* handle pending proposals
  • Loading branch information
mpoke authored Apr 4, 2022
commit 51dd64d6b86a25d54b3dd893ec73dbc3c0a4013b
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