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

Hermes may send timeouts for packets that have not expired yet #1504

Closed
5 tasks
ancazamfir opened this issue Oct 26, 2021 · 1 comment · Fixed by #1520
Closed
5 tasks

Hermes may send timeouts for packets that have not expired yet #1504

ancazamfir opened this issue Oct 26, 2021 · 1 comment · Fixed by #1520
Assignees
Labels
A: bug Admin: something isn't working I: logic Internal: related to the relaying logic
Milestone

Comments

@ancazamfir
Copy link
Collaborator

Crate

relayer

Summary of Bug

hermes checks now() when deciding if a packet has timedout. This causes timeouts to be rejected by chain if the timestamp of the header for the consensus state on the counterparty chain is smaller than now()

error looks like this:

{
  "jsonrpc": "2.0",
  "id": -1,
  "result": {
    "hash": "7198EAB9E735D2990B8D844C530B02F94D2090951FA2413C9FF760D2F1C72051",
    "height": "212",
    "index": 1,
    "tx_result": {
      "code": 14,
      "data": null,
      "log": "\ngithub.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/keeper.Keeper.TimeoutPacket\n\tgithub.com/cosmos/[email protected]/x/ibc/core/04-channel/keeper/timeout.go:78\ngithub.com/cosmos/cosmos-sdk/x/ibc/core/keeper.Keeper.Timeout\n\tgithub.com/cosmos/[email protected]/x/ibc/core/keeper/msg_server.go:493\ngithub.com/cosmos/cosmos-sdk/x/ibc/core.NewHandler.func1\n\tgithub.com/cosmos/[email protected]/x/ibc/core/handler.go:87\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runMsgs\n\tgithub.com/cosmos/[email protected]/baseapp/baseapp.go:724\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx\n\tgithub.com/cosmos/[email protected]/baseapp/baseapp.go:669\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).DeliverTx\n\tgithub.com/cosmos/[email protected]/baseapp/abci.go:273\ngithub.com/tendermint/tendermint/abci/client.(*localClient).DeliverTxAsync\n\tgithub.com/tendermint/[email protected]/abci/client/local_client.go:95\ngithub.com/tendermint/tendermint/proxy.(*appConnConsensus).DeliverTxAsync\n\tgithub.com/tendermint/[email protected]/proxy/app_conn.go:85\ngithub.com/tendermint/tendermint/state.execBlockOnProxyApp\n\tgithub.com/tendermint/[email protected]/state/execution.go:320\ngithub.com/tendermint/tendermint/state.(*BlockExecutor).ApplyBlock\n\tgithub.com/tendermint/[email protected]/state/execution.go:140\ngithub.com/tendermint/tendermint/consensus.(*State).finalizeCommit\n\tgithub.com/tendermint/[email protected]/consensus/state.go:1635\ngithub.com/tendermint/tendermint/consensus.(*State).tryFinalizeCommit\n\tgithub.com/tendermint/[email protected]/consensus/state.go:1546\ngithub.com/tendermint/tendermint/consensus.(*State).enterCommit.func1\n\tgithub.com/tendermint/[email protected]/consensus/state.go:1481\ngithub.com/tendermint/tendermint/consensus.(*State).enterCommit\n\tgithub.com/tendermint/[email protected]/consensus/state.go:1519\ngithub.com/tendermint/tendermint/consensus.(*State).addVote\n\tgithub.com/tendermint/[email protected]/consensus/state.go:2132\ngithub.com/tendermint/tendermint/consensus.(*State).tryAddVote\n\tgithub.com/tendermint/[email protected]/consensus/state.go:1930\ngithub.com/tendermint/tendermint/consensus.(*State).handleMsg\n\tgithub.com/tendermint/[email protected]/consensus/state.go:838\ngithub.com/tendermint/tendermint/consensus.(*State).receiveRoutine\n\tgithub.com/tendermint/[email protected]/consensus/state.go:782\nfailed to execute message; message index: 28: timeout packet verification failed: packet timeout has not been reached for height or timestamp: packet timeout",
      "info": "",
      "gas_wanted": "3000000",
      "gas_used": "1026936",
      "events": [],
      "codespace": "channel"
    },

Version

master

Steps to Reproduce

I run a script that sends packets with 60 sec timeout stamp every 1 sec on two chains with 10 and 3 sec block times respectively. Wait for 100 sec and start hermes.

Acceptance Criteria

Don't send timeout packets for packets that have not timed out relatively to the header on the destination chain used for proof root.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate milestone (priority) applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@ancazamfir
Copy link
Collaborator Author

Problem is that we use Utc::now() instead of the timestamp of header at dst_chain_height (L1211):
https://github.com/informalsystems/ibc-rs/blob/a3b17271781ea4f73a3a64486adada4834b1ba65/relayer/src/link/relay_path.rs#L1200-L1216
The timestamp of the header at height dst_chain_height (or full header) should be obtained once (e.g. when we clear packets) and passed from the caller, or stored in self (??) so we don't query a header from chain for every timeout as this is an expensive operation.

@adizere adizere self-assigned this Oct 26, 2021
@adizere adizere added A: bug Admin: something isn't working I: logic Internal: related to the relaying logic labels Oct 26, 2021
@adizere adizere added this to the 11.2021 milestone Oct 26, 2021
@ancazamfir ancazamfir self-assigned this Oct 28, 2021
@adizere adizere modified the milestones: 11.2021, 10.2021 Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: bug Admin: something isn't working I: logic Internal: related to the relaying logic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants