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

English spec for SendPacketEvent handling #230

Merged
merged 5 commits into from
Sep 15, 2020

Conversation

milosevic
Copy link
Contributor

Addresses #229.

Copy link
Contributor

@istoilkovska istoilkovska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general.

I'm missing a bit of context and explanations on why it is necessary for the relayer to do verification before creating and submitting the datagrams. Also, it seems that the last paragraph of Relayer.md is incomplete.

proofHeight Height) (ConnectionEnd, CommitmentProof)


// Returns client connection with a commitment proof. If proof != nil, then it is being verified with the corresponding light client.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Returns client connection with a commitment proof. If proof != nil, then it is being verified with the corresponding light client.
// Returns client state with a commitment proof. If proof != nil, then it is being verified with the corresponding light client.

docs/spec/relayer/Packets.md Show resolved Hide resolved
sequence uint64,
proofHeight Height) (bytes, CommitmentProof)

// Returns next recv sequence number a commitment proof. If proof != nil, then it is being verified with the corresponding
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Returns next recv sequence number a commitment proof. If proof != nil, then it is being verified with the corresponding
// Returns next recv sequence number with a commitment proof. If proof != nil, then it is being verified with the corresponding

if proof == nil return nil

clientState = GetClientState(chainA, connection.clientIdentifier, ev.Height)
return getHostInfo(clientStateA.chainID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return getHostInfo(clientStateA.chainID)
return getHostInfo(clientState.chainID)

### PacketRecv datagram creation

```golang
func createDatagram(ev SendPacketEvent, chainA Chain, chainB Chain, installedHeight Height) PacketRecv {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this function should be called createPacketRecvDatagram.

docs/spec/relayer/Packets.md Show resolved Hide resolved
connection, proof = GetConnection(chainB, connectionId, LATEST_HEIGHT)
if proof != nil { return nil }

if connectionB == null OR connectionB.state != OPEN { return nil }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if connectionB == null OR connectionB.state != OPEN { return nil }
if connection == null OR connection.state != OPEN { return nil }

@milosevic milosevic merged commit 6f84d97 into master Sep 15, 2020
Copy link
Collaborator

@ancazamfir ancazamfir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, a few comments, opened for debate :)

docs/spec/relayer/Packets.md Show resolved Hide resolved
docs/spec/relayer/Packets.md Show resolved Hide resolved
docs/spec/relayer/Packets.md Show resolved Hide resolved
docs/spec/relayer/Packets.md Show resolved Hide resolved
docs/spec/relayer/Packets.md Show resolved Hide resolved
docs/spec/relayer/Packets.md Show resolved Hide resolved
// we now check if this packet is already received by the destination chain
if (channel.ordering === ORDERED) {
nextSequenceRecv, proof = GetNextSequenceRecv(chainB, ev.destPort, ev.destChannel, LATEST_HEIGHT)
if proof != nil { return nil }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this check below the sequence matching check and change it to:

Suggested change
if proof != nil { return nil }
if proof == nil { return nil }

i.e. first we check if the chain expects exactly the ev.sequence. Not sure what to do if it doesn't though. Maybe the packet was delivered or maybe a full rpc node is lying?
Then if we ask for a proof and we don't get one something is wrong -> change the rpc full node?
Then do the proof verification, if it fails -> change the rpc full node?

I don't know the safest sequence here...and I think we trust the full node here? So maybe ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We trust light client, so everything checked by the light client (via header's app hash) we also trust. I will add more on error handling in the next version, but in general we should probably switch to different rpc node within GetX functions, but handler ideally don't need to care about that. But this need to be clarified.

docs/spec/relayer/Packets.md Show resolved Hide resolved
docs/spec/relayer/Packets.md Show resolved Hide resolved
docs/spec/relayer/Relayer.md Show resolved Hide resolved
@romac romac deleted the zarko/packets-english-spec branch April 8, 2021 20:41
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
Add spec for SendPacketEvent handling and PacketRecv creation logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants