Skip to content

Commit

Permalink
ics28 update sendPacket (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoke authored May 23, 2022
1 parent fe3c111 commit 76f2577
Showing 1 changed file with 38 additions and 34 deletions.
72 changes: 38 additions & 34 deletions spec/app/ics-028-cross-chain-validation/technical_specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ The *initialization* sub-protocol enables a provider chain and a consumer chain
// implements the AppModule interface
function InitGenesis(state: ProviderGenesisState): [ValidatorUpdate] {
// bind to ProviderPortId port
err = portKeeper.BindPort(ProviderPortId)
err = portKeeper.bindPort(ProviderPortId)
// check whether the capability for the port can be claimed
abortSystemUnless(err == nil)

Expand Down Expand Up @@ -796,7 +796,7 @@ function InitGenesis(gs: ConsumerGenesisState): [ValidatorUpdate] {
abortSystemUnless(gs.initialValSet == gs.providerConsensusState.validatorSet)

// bind to ConsumerPortId port
err = portKeeper.BindPort(ConsumerPortId)
err = portKeeper.bindPort(ConsumerPortId)
// check whether the capability for the port can be claimed
abortSystemUnless(err == nil)

Expand Down Expand Up @@ -1361,14 +1361,15 @@ function EndBlock(): [ValidatorUpdate] {
channelId = chainToChannel[chainId]

foreach data IN pendingVSCPackets[chainId] {
// create packet and send it using the interface exposed by ICS-4
packet = Packet{
timeoutHeight: zeroTimeoutHeight,
timeoutTimestamp: ccvTimeoutTimestamp,
destChannel: channelId,
data: data,
}
channelKeeper.SendPacket(packet)
// send data using the interface exposed by ICS-4
channelKeeper.sendPacket(
portKeeper.getCapability(portKeeper.portPath(ProviderPortId)),
ProviderPortId, // source port ID
channelId, // source channel ID
zeroTimeoutHeight,
ccvTimeoutTimestamp,
data
)
}

// remove pending VSCPackets
Expand Down Expand Up @@ -1835,14 +1836,15 @@ function UnbondMaturePackets() {
// create VSCMaturedPacketData
packetData = VSCMaturedPacketData{id: id}

// create packet and send it using the interface exposed by ICS-4
packet = Packet{
timeoutHeight: zeroTimeoutHeight,
timeoutTimestamp: ccvTimeoutTimestamp,
destChannel: providerChannel,
data: packetData,
}
channelKeeper.SendPacket(packet)
// send VSCMaturedPacketData using the interface exposed by ICS-4
channelKeeper.sendPacket(
portKeeper.getCapability(portKeeper.portPath(ConsumerPortId)),
ConsumerPortId, // source port ID
providerChannel, // source channel ID
zeroTimeoutHeight,
ccvTimeoutTimestamp,
packetData
)

// remove entry from the list
maturingVSCs.Remove(id, ts)
Expand Down Expand Up @@ -2004,14 +2006,15 @@ function SendSlashRequest(

// check whether the CCV channel to the provider chain is established
if providerChannel != "" {
// create packet and send it using the interface exposed by ICS-4
packet = Packet{
timeoutHeight: zeroTimeoutHeight,
timeoutTimestamp: ccvTimeoutTimestamp,
destChannel: providerChannel,
data: packetData,
}
channelKeeper.SendPacket(packet)
// send SlashPacket data using the interface exposed by ICS-4
channelKeeper.sendPacket(
portKeeper.getCapability(portKeeper.portPath(ConsumerPortId)),
ConsumerPortId, // source port ID
providerChannel, // source channel ID
zeroTimeoutHeight,
ccvTimeoutTimestamp,
packetData
)

if downtime {
// set outstandingDowntime for this validator
Expand Down Expand Up @@ -2067,14 +2070,15 @@ function SendPendingSlashRequests() {
// iterate over every pending SlashRequest in reverse order
foreach req IN pendingSlashRequests.Reverse() {
if !req.downtime OR !outstandingDowntime[req.data.valAddress] {
// create packet and send it using the interface exposed by ICS-4
packet = Packet{
timeoutHeight: zeroTimeoutHeight,
timeoutTimestamp: ccvTimeoutTimestamp,
destChannel: providerChannel,
data: req.data,
}
channelKeeper.SendPacket(packet)
// send req.data using the interface exposed by ICS-4
channelKeeper.sendPacket(
portKeeper.getCapability(portKeeper.portPath(ConsumerPortId)),
ConsumerPortId, // source port ID
providerChannel, // source channel ID
zeroTimeoutHeight,
ccvTimeoutTimestamp,
req.data
)

if req.downtime {
// set outstandingDowntime for this validator
Expand Down

0 comments on commit 76f2577

Please sign in to comment.