You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go through all the places in 04-channel that does proof verification (these are in packet verification and channel handshakes)
RecvPacket
AcknowledgePacket
TimeoutPacket (ORDERED and UNORDERED)
TimeoutOnClose (ORDERED and UNORDERED)
ChanOpenTry
ChanOpenAck
ChanOpenConfirm
ChanCloseConfirm
In each place:
Replace connection.Verify... with the following:
funcChannelMethod() {
// logic prior to proof verification// expectedVal is constructed here// the if statement is new logic// the else statement will house the old existing logicifchannel.ConnectionHops[0] =="localhost" {
// get the desired state directly from this chain's channelKeeper// this will be a specific Get function dependent on the specific method this isactualVal:=k.Get(ICS24Path())
ifexpectedVal!=actual {
returnerror
}
} else {
// do counterparty proof verification with underlying clientconnection:= k.GetConnection(channel.ConnectionHops[0]
// this is a specific verify function depending on what method this isconnection.VerifyChannelState(proof, expectedKey, expectedVal)
}
// continue existing logic
}
Here is the example for RecvPacket:
// example of channel function that does// verification in special localhost casefunc (kKeeper) RecvPacket(
ctx sdk.Context,
chanCap*capabilitytypes.Capability,
packet exported.PacketI,
proof []byte,
proofHeight exported.Height,
) error {
// ... recv packet logiccommitment:=types.CommitPacket(k.cdc, packet)
// packet commitment verificationifchannel.ConnectionHops[0] =="localhost" {
storedCommit, ok:=k.GetPacketCommitment(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
if!ok||storedCommit!=commitment {
returnerror
}
} else {
// do counterparty proof verification with underlying client// move GetConnection code down into the else block since it will error on "localhost"// because the "localhost" connection doesn't actually exist in-state// Connection must be OPEN to receive a packet. It is possible for connection to not yet be open if packet was// sent optimistically before connection and channel handshake completed. However, to receive a packet,// connection and channel must both be openconnectionEnd, found:=k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0])
if!found {
returnsdkerrors.Wrap(connectiontypes.ErrConnectionNotFound, channel.ConnectionHops[0])
}
ifconnectionEnd.GetState() !=int32(connectiontypes.OPEN) {
returnsdkerrors.Wrapf(
connectiontypes.ErrInvalidConnectionState,
"connection state is not OPEN (got %s)", connectiontypes.State(connectionEnd.GetState()).String(),
)
}
// verify that the counterparty did commit to sending this packetiferr:=k.connectionKeeper.VerifyPacketCommitment(
ctx, connectionEnd, proofHeight, proof,
packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence(),
commitment,
); err!=nil {
returnsdkerrors.Wrap(err, "couldn't verify counterparty packet commitment")
}
}
// ... continued recv packet logic
}
The text was updated successfully, but these errors were encountered:
Hey @AdityaSripal, I started working through the 09-localhost issues a bit ago and wanted to run the first pass by you to ensure everything looks correct before I complete the rest of it.
@jtieri so then you're working on this? I will assign the issue to you then. Thanks a lot!
Yepp! I'm going to take on all the issues labeled 09-localhost. Aditya expressed it may be better to complete the issues in our forked repo first so Agoric can utilize these changes sooner than later, and then sometime in your guys next sprint we can work on upstreaming these changes. (or at least that is the understanding that I walked away with)
Go through all the places in 04-channel that does proof verification (these are in packet verification and channel handshakes)
In each place:
Replace
connection.Verify...
with the following:Here is the example for RecvPacket:
The text was updated successfully, but these errors were encountered: