-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Implement Height interface in core IBC #7211
Conversation
This PR is blocking continued progress on the relayer |
@@ -72,13 +77,16 @@ to the counterparty channel. Any timeout set to 0 is disabled.`), | |||
// if the timeouts are not absolute, retrieve latest block height and block timestamp | |||
// for the consensus state connected to the destination port/channel | |||
if !absoluteTimeouts { | |||
consensusState, _, err := channelutils.QueryCounterpartyConsensusState(clientCtx, srcPort, srcChannel, uint64(clientCtx.Height)) | |||
consensusState, _, err := channelutils.QueryLatestConsensusState(clientCtx, srcPort, srcChannel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was incorrect, we cannot query consensus state with a consensus height using our own block height
if err != nil { | ||
return err | ||
} | ||
|
||
proofHeight := uint64(clientCtx.Height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was incorrect, cannot retrieve proofHeight/consensusHeight
from our own context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for fixing these, most of the cli code is broken and we can address anything else in a final refactor of it
if err != nil { | ||
return err | ||
} | ||
|
||
proofHeight := uint64(clientCtx.Height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Quick Q on the height interface... How do I get the height number out of it? |
cast to the height concrete type and use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work !!! Glad to see this is finally ready to be merged! 🎉
left some small nits, but nothing needs to be addressed now. In a followup pr or at some point in the future is fine
version.AppName, host.ModuleName, types.SubModuleName, | ||
), | ||
Args: cobra.ExactArgs(10), | ||
Args: cobra.ExactArgs(12), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lmao the usability of entering 12 arguments by command line 👀 My hot take is IBC should drop support for doing handshakes by CLI. I'd rather just leave this to relayers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe, this is probably reasonable, although it has been convenient for testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still have 40+ files left to review
testConnectionID = "connectionid" | ||
testChannelID = "testchannelid" | ||
testPortID = "testportid" | ||
) | ||
|
||
var ( | ||
prefix = commitmenttypes.NewMerklePrefix([]byte("ibc")) | ||
prefix = commitmenttypes.NewMerklePrefix([]byte("ibc")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we define this in ibctesting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just use chain.GetPrefix()
@@ -152,7 +151,7 @@ func checkValidity( | |||
|
|||
// update the consensus state from a new header | |||
func update(clientState *ClientState, header *Header) (*ClientState, *ConsensusState) { | |||
height := clienttypes.NewHeight(0, header.GetHeight()) | |||
height := header.GetHeight().(clienttypes.Height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this validated somewhere? otherwise, it will panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is a Tendermint Header
I would prefer to return the concrete type instead from the fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final review comments. Great work!
@@ -731,3 +732,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { | |||
}) | |||
} | |||
} | |||
|
|||
func malleateHeight(height exported.Height, diff uint64) exported.Height { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move this to ibctesting since it's reused on the handshakes?
it might be worthwhile to add a |
Co-authored-by: Federico Kunze <[email protected]>
…k into aditya/height-interface
All the RPC request types must have the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to think a bit about the misbehaviour handling logic (may also require minor spec updates). Otherwise great work.
version.AppName, host.ModuleName, types.SubModuleName, | ||
), | ||
Args: cobra.ExactArgs(10), | ||
Args: cobra.ExactArgs(12), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe, this is probably reasonable, although it has been convenient for testing
} | ||
|
||
// calculate the age of the misbehaviour | ||
infractionHeight := tmMisbehaviour.GetHeight() | ||
infractionHeight := tmMisbehaviour.GetHeight().(clienttypes.Height).EpochHeight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm a little worried about this. Is it possible we could treat previously invalid evidence as valid again after an upgrade? I think we need to parse the epoch from the chain ID of the misbehaviour and check using the height comparator.
} | ||
|
||
// calculate the age of the misbehaviour | ||
infractionHeight := tmMisbehaviour.GetHeight() | ||
infractionHeight := tmMisbehaviour.GetHeight().(clienttypes.Height).EpochHeight | ||
infractionTime := tmMisbehaviour.GetTime() | ||
ageDuration := ctx.BlockTime().Sub(infractionTime) | ||
ageBlocks := int64(cs.LatestHeight.EpochHeight - infractionHeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ageBlocks
can still be calculated by summing the differences across epochs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require knowing the last epoch height of each epoch, and having them easily retrievable from state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aye, yes, never mind
Good point @cwgoes . We want to have the ability to submit misbehaviour from a previous epoch without storing the last epoch height of each epoch and summing them up to find out an absolute difference in block heights. Note that in the expiration check we have both a time check and a block check. We can retain both checks in the case where the misbehaviour epoch number and the client's current epoch are the same. In cases where the misbehaviour epoch is less than the client epoch, we can rely solely on the time check which will still work across epochs even as the epoch heights reset. This allows us to submit previous epoch misbehaviour without adding any more state in the client store to track last epoch-heights for each epoch |
Description
Part 2 of #6531
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes