-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Switch mock proofs to real proofs; debug #5711
Conversation
The handshake problems can be clearly reproduced now: go test ./x/ibc/03-connection/keeper/... |
I fixed one minor mistake in a test-case. Right now there are two errors: --- FAIL: TestKeeperTestSuite (0.41s)
--- FAIL: TestKeeperTestSuite/TestConnOpenAck (0.06s)
--- FAIL: TestKeeperTestSuite/TestConnOpenAck/Case_success (0.01s)
handshake_test.go:204:
Error Trace: handshake_test.go:204
suite.go:77
Error: Received unexpected error:
self consensus state not found
Test: TestKeeperTestSuite/TestConnOpenAck/Case_success
Messages: valid test case 0 failed: success I tried to fix this with 850e6c3#diff-b1978f573dd726c3b9b0b8bb6f72b7ffR180 but this didn't seem to work. The other problem is the one we've observed in the handshakes: --- FAIL: TestKeeperTestSuite/TestConnOpenConfirm (0.04s)
--- FAIL: TestKeeperTestSuite/TestConnOpenConfirm/Case_success (0.01s)
handshake_test.go:255:
Error Trace: handshake_test.go:255
suite.go:77
Error: Received unexpected error:
github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types.ClientState.VerifyConnectionState
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types/client_state.go:160
github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper.Keeper.VerifyConnectionState
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper/verify.go:59
github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper.Keeper.ConnOpenConfirm
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper/handshake.go:222
github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper_test.(*KeeperTestSuite).TestConnOpenConfirm.func6
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper/handshake_test.go:252
github.com/stretchr/testify/suite.(*Suite).Run.func1
/home/cwgoes/working/tendermint/go/pkg/mod/github.com/stretchr/testify@v1.5.1/suite/suite.go:77
connection state verification failed: calculated root hash is invalid: expected [65 202 250 227 28 199 15 88 1 250 16 22 162 221 84 169 188 184 32 27 91 56 153 25 254 153 118 118 37 50 197 22] but got [96 48 99 120 144 155 117 126 20 167 25 162 81 126 86 115 253 133 118 85 75 108 219 45 193 246 196 136 24 26 203 198]
Test: TestKeeperTestSuite/TestConnOpenConfirm/Case_success
Messages: valid test case 0 failed: success This recurs across all of the handshake / verification tests. |
(path.String() == proof.path.String()) && | ||
bytes.Equal(value, proof.value) { | ||
return nil | ||
} else { |
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
block ends with a return
statement, so drop this else
and outdent its block (from golint
)
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 have altered the test-cases to return the consensus heights they should be using, no luck yet, I suspect there is a single underlying problem that we need to isolate. go test ./x/ibc/03-connection/keeper/... -run TestKeeperTestSuite/TestConnOpenTry --- FAIL: TestKeeperTestSuite (0.06s)
--- FAIL: TestKeeperTestSuite/TestConnOpenTry (0.06s)
--- FAIL: TestKeeperTestSuite/TestConnOpenTry/Case_success (0.01s)
handshake_test.go:125:
Error Trace: handshake_test.go:125
suite.go:77
Error: Received unexpected error:
github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types.ClientState.VerifyConnectionState
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types/client_state.go:160
github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper.Keeper.VerifyConnectionState
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper/verify.go:59
github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper.Keeper.ConnOpenTry
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper/handshake.go:82
github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper_test.(*KeeperTestSuite).TestConnOpenTry.func8
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper/handshake_test.go:118
github.com/stretchr/testify/suite.(*Suite).Run.func1
/home/cwgoes/working/tendermint/go/pkg/mod/github.com/stretchr/testify@v1.5.1/suite/suite.go:77
connection state verification failed: calculated root hash is invalid: expected [65 202 250 227 28 199 15 88 1 250 16 22 162 221 84 169 188 184 32 27 91 56 153 25 254 153 118 118 37 50 197 22] but got [222 160 240 36 202 50 93 224 173 12 40 103 181 198 119 229 212 218 118 71 53 182 161 92 177 58 140 184 151 245 148 127]
Test: TestKeeperTestSuite/TestConnOpenTry/Case_success
Messages: valid test case 0 failed with consensus height 3: success
FAIL
FAIL github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper 0.087s
FAIL I'm also confused by the fact that the expected root hash seems to be constant but the real one changes each time I re-run the tests - is the test-suite supposed to be deterministic? |
) | ||
|
||
if tc.expPass { | ||
suite.Require().NoError(err, "valid test case %d failed: %s", i, tc.msg) | ||
suite.Require().NoError(err, "valid test case %d failed with consensus height %d: %s", i, consensusHeight, tc.msg) |
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.
Using the variable on range scope i
in function literal (from scopelint
)
} else { | ||
suite.Require().Error(err, "invalid test case %d passed: %s", i, tc.msg) | ||
suite.Require().Error(err, "invalid test case %d passed with consensus height %d: %s", i, consensusHeight, tc.msg) |
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.
Using the variable on range scope i
in function literal (from scopelint
)
connection.GetCompatibleVersions(), tc.proofInit, tc.proofConsensus, | ||
uint64(proofHeight), uint64(consensusHeight), | ||
connection.GetCompatibleVersions(), proofInit, proofConsensus, | ||
uint64(proofHeight), consensusHeight, |
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.
unnecessary conversion (from unconvert
)
|
||
// consensusKey := ibctypes.KeyConsensusState(testClientIDB, uint64(proofHeight)) | ||
// proofConsensus, consensusHeight := suite.queryProof(consensusKey) | ||
consensusKey := ibctypes.KeyConsensusState(testClientIDB, uint64(consensusHeight)) |
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.
unnecessary conversion (from unconvert
)
suite.chainA.GetContext(), testConnectionIDA, tc.version, tc.proofTry, tc.proofConsensus, | ||
uint64(proofHeight), uint64(consensusHeight), | ||
suite.chainA.GetContext(), testConnectionIDA, tc.version, proofTry, proofConsensus, | ||
uint64(proofHeight), consensusHeight, |
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.
unnecessary conversion (from unconvert
)
Issues fixed in 69cf142:
Still debugging
|
Still some issues with expected consensus state & self consensus state mis-matching. |
|
To run the go test ./x/ibc/03-connection/keeper/... -run TestKeeperTestSuite/TestConnOpenTry resulting in root: {[216 137 244 20 97 87 138 53 114 6 173 141 41 248 245 15 217 3 64 210 56 147 140 117 121 232 178 151 123 196 76 13]} at height 4
path: /ibc/consensusState%2Ftestclientida%2F3
--- FAIL: TestKeeperTestSuite (0.02s)
--- FAIL: TestKeeperTestSuite/TestConnOpenTry (0.02s)
--- FAIL: TestKeeperTestSuite/TestConnOpenTry/Case_success (0.01s)
handshake_test.go:133:
Error Trace: handshake_test.go:133
suite.go:77
Error: Received unexpected error:
github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types.ClientState.VerifyClientConsensusState
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types/client_state.go:132
github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper.Keeper.VerifyClientConsensusState
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper/verify.go:29
github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper.Keeper.ConnOpenTry
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper/handshake.go:93
github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper_test.(*KeeperTestSuite).TestConnOpenTry.func8
/home/cwgoes/working/tendermint/go/src/github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper/handshake_test.go:126
github.com/stretchr/testify/suite.(*Suite).Run.func1
/home/cwgoes/working/tendermint/go/pkg/mod/github.com/stretchr/testify@v1.5.1/suite/suite.go:77
client consensus state verification failed: verifying value: leaf value hash not same: invalid proof
Test: TestKeeperTestSuite/TestConnOpenTry/Case_success
Messages: valid test case 0 failed with consensus height 3 and proof height 3: success
FAIL
FAIL github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper 0.048s |
// Create target ctx | ||
ctxTarget := chain.GetContext() | ||
|
||
// create client | ||
clientState, err := ibctmtypes.Initialize(client.ClientID, trustingPeriod, ubdPeriod, client.Header) | ||
clientState, err := ibctmtypes.Initialize(chain.ClientID, trustingPeriod, ubdPeriod, client.Header) |
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 so looks like my code caused some confusion here.
I believe I should rename this field to client.ChainID
and document clearly that the clientID that other chains store for the given client
is the chainID of the client chain for simplicity in the tests.
So TestChainA may have a chainID field called: testchainida
.
If TestChainB creates a client for TestChainA, it will give it the clientID testchainida
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.
OK, that's alright too, it was just inconsistent in some places. The key question is why consensus state verification is failing though.
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 working through the test cases now, and I'm getting a failure on Connection state verification before i hit consensus state verification
Did you comment out the connection state issue to hit consensus 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.
No, it works for me, can you provide replication instructions?
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.
Sorry i meant on my own branch that reverts your identifier issue
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.
OK, great! Feel free to revise then.
Step 1: Get these tests working. Step 2: Test relayer again, get it working. |
All the handshake tests pass locally for me & the changes make sense, left a comment about a height offset we need to remember to deal with correctly in the relayer. Hopefully we can turn these into more end-to-end tests in the future, but for now fixing the verification tests and moving back to the relayer to get the connection handshake working there makes sense to me as an order of priorities. |
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. Minor cleanup comments
client.Header = nextHeader(client) | ||
|
||
/* |
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.
remove comment?
invalidProof struct{} | ||
) | ||
|
||
func (validProof) GetCommitmentType() commitment.Type { | ||
return commitment.Merkle | ||
} | ||
|
||
func (validProof) VerifyMembership( | ||
func (proof validProof) VerifyMembership( |
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.
are we still using these proofs?
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 shouldn't be, maybe we can delete them altogether?
(path.String() == proof.path.String()) && | ||
bytes.Equal(value, proof.value) { | ||
return nil | ||
} else { |
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.
^^
@@ -105,12 +105,15 @@ func (cs ClientState) IsFrozen() bool { | |||
// Tendermint client stored on the target machine. | |||
func (cs ClientState) VerifyClientConsensusState( | |||
cdc *codec.Codec, | |||
provingRoot commitment.RootI, |
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 the counterparty commitment root? add comment
@@ -156,6 +159,8 @@ func (cs ClientState) VerifyConnectionState( | |||
return err | |||
} | |||
|
|||
fmt.Printf("verify against consensus state %v\n", consensusState) |
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.
fmt.Printf("verify against consensus state %v\n", consensusState) |
Thanks @fedekunze! Tested locally, everything except ICS 04 tests passes for me now. Those look like they also need to be updated to use Also, it would be nice to share code between the ICS 03 and ICS 04 tests somehow, there seems to be a lot of duplicate logic in the test setup that we have to edit in multiple places right now. |
Timestamp: ctx.BlockTime(), | ||
Height: height, | ||
// FIXME: Currently commented out due to time normalisation issues. | ||
//Timestamp: histInfo.Header.Time, |
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 is going to get fixed in this PR?
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 wasn't able to figure it out, some sort of normalisation (maybe in Tendermint?).
We should either fix it or open an issue to track it.
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.
What feature/guarantee/check are we missing by not having this timestamp?
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.
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.
tACK (can't approve since I created the PR) modulo comments & #5761. Thanks @AdityaSripal!
Timestamp: ctx.BlockTime(), | ||
Height: height, | ||
// FIXME: Currently commented out due to time normalisation issues. | ||
//Timestamp: histInfo.Header.Time, |
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 wasn't able to figure it out, some sort of normalisation (maybe in Tendermint?).
We should either fix it or open an issue to track it.
invalidProof struct{} | ||
) | ||
|
||
func (validProof) GetCommitmentType() commitment.Type { | ||
return commitment.Merkle | ||
} | ||
|
||
func (validProof) VerifyMembership( | ||
func (proof validProof) VerifyMembership( |
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 shouldn't be, maybe we can delete them altogether?
Failing sim and proto checks. Lets get those cleaned up before we merge this? |
Failing simulation:
|
closes #5693