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

e2e: timeout transfer with grandpa light client #5018

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
189 commits
Select commit Hold shift + click to select a range
01e8548
feat: add wasm light client module to feat/wasm-clients branch (#3486)
misko9 Jul 6, 2023
40337dd
Merge branch 'main' into feat/wasm-clients
crodriguezvega Jul 6, 2023
90ed894
linting
crodriguezvega Jul 7, 2023
cf6fbfe
Migrated the errors to new package (#4058)
vishal-kanna Jul 12, 2023
28d46c1
Merge branch 'main' into feat/wasm-client
charleenfei Jul 12, 2023
255905a
imp: make separate go.mod for 08-wasm (#4026)
crodriguezvega Jul 13, 2023
8bc0c68
imp: remove code id key from genesis contract (#4032)
crodriguezvega Jul 14, 2023
b6e8a3a
fix imports
crodriguezvega Jul 14, 2023
2901cf8
bump wasmvm (#4086)
crodriguezvega Jul 14, 2023
581a27f
build and test wasm client on PR (#4095)
Reecepbcups Jul 16, 2023
5a1a249
add authority param to wasm NewKeeper (#4092)
Reecepbcups Jul 16, 2023
3607dd2
Merge `storeWasmCode` and `importWasmCode` functions (#4088)
crodriguezvega Jul 17, 2023
9298fe6
Pin code to the wasm VM cache (#4093)
Reecepbcups Jul 18, 2023
731dbbf
just some renaming
crodriguezvega Jul 20, 2023
59ccad5
renaming to align with x/wasm naming (#4091)
crodriguezvega Jul 20, 2023
62ed4fb
imp: disallow submessage execution (#4130)
crodriguezvega Jul 20, 2023
341350a
use sudo (#4131)
crodriguezvega Jul 20, 2023
f822b4f
fix wrapf warning (#4172)
DimitrisJim Jul 25, 2023
bffb649
Merge branch 'main' into feat/wasm-clients
crodriguezvega Jul 30, 2023
bf9d465
Add linting for 08-wasm module (#4206)
DimitrisJim Aug 1, 2023
ed41863
add 08-wasm global store key (#4185)
crodriguezvega Aug 1, 2023
de89920
imp: delegate store operation of `clientState` and `consensusState` i…
crodriguezvega Aug 1, 2023
644367f
imp: remove `timestamp` from `consensusState` and query contract to r…
crodriguezvega Aug 1, 2023
20d4d7e
imp: remove `height` from `header` and merge `header` with `misbehavi…
crodriguezvega Aug 1, 2023
54f29ee
imp: add query and sudo message types to encapsulate all variants of …
crodriguezvega Aug 1, 2023
c4f8da4
add 08-wasm Keeper constructor that accepts pointer to Wasm VM instan…
crodriguezvega Aug 1, 2023
2e17bb2
Allow same VM to be assigned to the global vm. (#4236)
DimitrisJim Aug 3, 2023
49c5e7d
Disallow events, attributes being returned from a contract. (#4222)
DimitrisJim Aug 3, 2023
4f0a711
Clean up vm entry points (#4279)
DimitrisJim Aug 14, 2023
479f470
Merge branch 'main' into feat/wasm-clients
crodriguezvega Aug 14, 2023
2a7c242
add halborn audit report
adiraviraj Aug 15, 2023
fb9eed5
Add files via upload
adiraviraj Aug 15, 2023
03d077b
add wasm client audit reports (#4351)
adiraviraj Aug 15, 2023
16e1026
Document contract api. (#4283)
DimitrisJim Aug 15, 2023
2913dbd
oh linter you. (#4369)
DimitrisJim Aug 17, 2023
83ca9bb
deps(08-wasm): bump SDK v0.47.5 (#4540)
crodriguezvega Sep 1, 2023
fb745e8
add 08-wasm to dependabot
crodriguezvega Sep 1, 2023
1425ca2
Merge branch 'main' into feat/wasm-clients
crodriguezvega Sep 1, 2023
17d255c
cherry pick commit fixing broken links
crodriguezvega Sep 5, 2023
8f5354b
Fix dependabot file.
DimitrisJim Sep 7, 2023
120d45b
Add new cmd to store code via a gov proposal. (#4565)
DimitrisJim Sep 7, 2023
81086e4
update wasm clients branch linter to match main (#4609)
faddat Sep 9, 2023
94f380d
chore: implement `appmodule.AppModule` interface (#4607)
crodriguezvega Sep 11, 2023
12d74a9
add proposal simulator interface and tests (#4608)
crodriguezvega Sep 14, 2023
bbec01f
ci: use go1.21 for wasm clients (#4610)
faddat Sep 14, 2023
090bc9f
remove toolchain / go mod tidy
crodriguezvega Sep 14, 2023
1bc5845
Update wasm light client unit tests and tendermint/grandpa cw contrac…
misko9 Sep 15, 2023
aa8598d
PR 4306 comments
crodriguezvega Sep 15, 2023
70efe3a
fix dead links
crodriguezvega Sep 18, 2023
95c9e29
fix broken links
crodriguezvega Sep 19, 2023
c87c590
test: check nil vm and empty authority (#4722)
crodriguezvega Sep 22, 2023
2d63b4a
add extra documentation for wasmCall and wasmQuery (#4752)
crodriguezvega Sep 22, 2023
60e565b
Duplicate simapp in 08 wasm (#4532)
DimitrisJim Sep 26, 2023
4f0198c
chore: add 08-wasm events (#4605)
crodriguezvega Sep 27, 2023
43106d5
Go mod tidy. (#4776)
DimitrisJim Sep 27, 2023
540db8c
Add workflow to build image for 08-wasm (#4777)
DimitrisJim Sep 28, 2023
159343d
add comment
crodriguezvega Sep 28, 2023
61db385
Use an error when panicking. (#4791)
DimitrisJim Sep 29, 2023
18a2185
imp: use interface instead of concrete type for wasmvm (#4802)
colin-axner Oct 2, 2023
5bff313
Merge branch 'main' into cian/merge-main-wasm
chatton Oct 3, 2023
f6be1b8
chore: fixing TestVerifyMisbehaviourTendermint test suite
chatton Oct 3, 2023
64fe692
chore: fixing linting issues and making linter runnable on mac
chatton Oct 3, 2023
c7324c2
chore: updating callbacks workflow
chatton Oct 3, 2023
48cadc5
chore: change callbacks workflow to build in docker
chatton Oct 3, 2023
595b8b9
chore: updating callbacks dockerfile
chatton Oct 3, 2023
e9c0862
chore: commented out part of test matrix
chatton Oct 3, 2023
176a497
fix: rm dependency on 08-wasm in ibc-go (#4801)
charleenfei Oct 4, 2023
9a7b9b7
imp: remove unused fields, functions of contract result (#4750)
crodriguezvega Oct 4, 2023
be3e2ff
Merge branch 'feat/wasm-clients' into cian/merge-main-wasm
chatton Oct 4, 2023
b863dd3
chore: addressing PR feedback
chatton Oct 4, 2023
b61ede0
chore: pr feedback
chatton Oct 4, 2023
86478ce
Merge pull request #4805 from cosmos/cian/merge-main-wasm
chatton Oct 4, 2023
7032548
feat: add mockVM for wasm clients testing (#4804)
colin-axner Oct 4, 2023
3f4061b
Dont pull wasmvm static lib in simd dockerfile. (#4817)
DimitrisJim Oct 4, 2023
1c7e148
Remove wasm additions to main test workflow. (#4819)
DimitrisJim Oct 4, 2023
0ea6d08
uncomment init function (#4833)
charleenfei Oct 5, 2023
551fb95
chore: add has validatebasic compiler assertion (#4742)
crodriguezvega Oct 5, 2023
42ad3cf
Ensure wasmvm static library version matches wasmv import in gomod (#…
chatton Oct 5, 2023
8c9c717
align error on signer not matching authority, use expected error in s…
crodriguezvega Oct 6, 2023
32e4bd7
fix: make Verify Von/Membership calls sudo calls instead of queryMsg …
charleenfei Oct 6, 2023
bd8e201
Bump wasmvm to 1.4.1 (#4857)
DimitrisJim Oct 13, 2023
cd7b5d6
Store code before creating a wasm client. (#4851)
DimitrisJim Oct 17, 2023
10ffafa
Run grandpa e2e test in ci (#4880)
chatton Oct 17, 2023
2ff2052
Add test for types registered in 08-wasm. (#4853)
DimitrisJim Oct 17, 2023
bc380a4
Improve mock wasmvm query implementation (#4879)
chatton Oct 17, 2023
c9f3ba5
Remove codeHash const from types_test, use wasmtesting. (#4891)
DimitrisJim Oct 17, 2023
403af69
Add checks in ValidateBasic for StoreCode, add tests for messages. (#…
DimitrisJim Oct 17, 2023
2a39e7f
Only store code hashes in store. (#4292)
DimitrisJim Oct 17, 2023
bde2a2f
Add mapping for sudo payloads callbacks in mockVM (#4897)
DimitrisJim Oct 18, 2023
b54ac97
Add test case for invalid Initialize call due to unstored contract. (…
DimitrisJim Oct 18, 2023
76bae0d
imp(08-wasm): exported contract responses to tests (#4902)
srdtrk Oct 18, 2023
ab35cf4
fix(08-wasm): removed panic in 'CheckForMisbehaviour' (#4907)
srdtrk Oct 18, 2023
bcdceab
test(08-wasm): added 'TestInitialize' using mockVM (#4894)
srdtrk Oct 19, 2023
e3790f5
Use the Response types in TestStatus. (#4910)
DimitrisJim Oct 19, 2023
19368c9
Remove GetSigners from StoreCode msg. (#4911)
DimitrisJim Oct 19, 2023
335286d
style(08-wasm): renamed 'grandpaClientID' -> 'defaultWasmClientID' (#…
srdtrk Oct 19, 2023
f02c619
fix(08-wasm)!: use concrete types for json serialization (#4909)
damiannolan Oct 20, 2023
fb594f6
fix exportedd type refs (#4920)
charleenfei Oct 20, 2023
5121172
chore: make wasm contract api exported (#4927)
damiannolan Oct 23, 2023
02fe742
fix: add build flag directives to ignore e2e test (#4924)
damiannolan Oct 23, 2023
6f4102e
test: `CheckForMisbehaviour` payload using mock vm (#4901)
charleenfei Oct 24, 2023
e655794
Take your time. (#4938)
DimitrisJim Oct 24, 2023
8a0eda1
test: `VerifyClientMessage` using mockVM (#4921)
charleenfei Oct 24, 2023
40ba894
test: adding `VerifyMembership` tests with mock wasm engine (#4923)
damiannolan Oct 25, 2023
dd6d028
test(08-wasm): added 'TestUpdateState' using mockVM (#4914)
srdtrk Oct 25, 2023
e2522b2
Add additional coverage for test initialize. (#4940)
DimitrisJim Oct 25, 2023
8c1ed9a
Add mock test for VerifyUpgradeAndUpdateState (#4930)
DimitrisJim Oct 25, 2023
cb38b85
test: adding verify non membership tests for 08-wasm clients using mo…
damiannolan Oct 25, 2023
1b4ae46
test: `UpdateStateOnMisbehaviour` using mock wasmVM (#4919)
charleenfei Oct 25, 2023
4fa827a
imp(08-wasm): removed panic in `GetCodeHash` and `AddCodeHash` (#4948)
srdtrk Oct 25, 2023
6eb154c
Add ErrMockContract. (#4955)
DimitrisJim Oct 26, 2023
a48b631
Add mock height and check for it in membership tests (#4956)
DimitrisJim Oct 26, 2023
90027e4
Add testing for GetTimestampAtHeight (#4960)
DimitrisJim Oct 26, 2023
90e345a
Remove panic handling testing code for non-panicking methods. (#4957)
DimitrisJim Oct 26, 2023
1d31c73
Update Grandpa Contract Test to work with SDK v0.50 (#4959)
chatton Oct 26, 2023
0abc469
Add mock test for ExportMetadata (#4961)
DimitrisJim Oct 26, 2023
95a1237
feat(08-wasm): use 'clientID' as contract address (#4939)
srdtrk Oct 27, 2023
890ef9d
Move mock engine into testing. (#4936)
DimitrisJim Oct 27, 2023
eea9a7d
Add testing for wasmQuery/wasmCall. (#4934)
DimitrisJim Oct 30, 2023
433f1fa
No formatting necessary. (#4985)
DimitrisJim Oct 30, 2023
ddb514d
Rename entry points to match vm names. (#4986)
DimitrisJim Oct 30, 2023
56fb2af
imp: `CheckSubstituteAndUpdateState` for 08-wasm client (#4974)
charleenfei Oct 30, 2023
1fa22f3
Delete commented out test for tendermint. (#4989)
DimitrisJim Oct 30, 2023
b0142e7
Remove store-code cmd. (#4990)
DimitrisJim Oct 30, 2023
995a3bd
Add mock test for CheckSubstituteAndUpdateState. (#4950)
DimitrisJim Oct 30, 2023
9655a7b
refactor(08-wasm)!: use `collections.KeySet` for code hashes (#4973)
srdtrk Oct 30, 2023
bdcc012
cleanup - creating mock var for client state bytes (#4978)
muku314115 Oct 31, 2023
7fd07ad
Fix TestScheduleIBCUpgrade_Succeeds on wasm branch (#4997)
chatton Oct 31, 2023
16f7d6c
Modify wrappedStore to allow reads from both substitute and subject, …
DimitrisJim Oct 31, 2023
20c73fd
Remove grandpa unit tests covered by e2e. (#4996)
DimitrisJim Oct 31, 2023
0e13d2e
Build and push wasm image in PRs (#4998)
chatton Nov 1, 2023
fe602e0
Add snapshotter extension (#4723)
trinitys7 Nov 1, 2023
9e15947
chore: adding type alias for code hash byte slices (#5004)
damiannolan Nov 1, 2023
33993ba
wip: add timeout test
charleenfei Nov 3, 2023
30251d4
Moving mock values in a separate file (#5021)
muku314115 Nov 6, 2023
efedb95
Sync gas_register.go with wasmd main (#5007)
chatton Nov 6, 2023
147f0ca
feat(08-wasm): implement 'MigrateContract' RPC endpoint (#5000)
srdtrk Nov 6, 2023
243f36f
chore: rename code ID/checksum to code hash (#5030)
crodriguezvega Nov 7, 2023
729cb09
feat(08-wasm): implement 'RemoveCodeHash' RPC endpoint (#5006)
srdtrk Nov 8, 2023
1e8e25d
wip
charleenfei Nov 9, 2023
0be3f39
Merge branch 'main' into feat/wasm-clients
crodriguezvega Nov 9, 2023
1ac7113
Rename wasmInit to wasmInstantiate and Features to Capabilities. (#5065)
DimitrisJim Nov 9, 2023
d7b99e8
chore: rm testsuite ctx and store fields (#5067)
damiannolan Nov 9, 2023
103510a
test(e2e): added migrate contract tests (#5043)
srdtrk Nov 9, 2023
c8e9a09
docs: documentation for 08-wasm (#4203)
crodriguezvega Nov 10, 2023
4d67e4c
linter
charleenfei Nov 10, 2023
3a3a998
Merge branch 'main' into feat/wasm-client
charleenfei Nov 10, 2023
d22682d
linter
charleenfei Nov 10, 2023
bc1f21a
Merge branch 'main' into feat/wasm-client
charleenfei Nov 10, 2023
8c485a1
Set wasmvm cache size to zero. (#5066)
DimitrisJim Nov 10, 2023
ee88c74
Merge branch 'feat/wasm-client' into charly/issue#4926-write-e2e-test…
charleenfei Nov 13, 2023
e9c2be6
wip: update
charleenfei Nov 13, 2023
1c70944
Add check that wasm contract only modifies code hash in migrateContra…
chatton Nov 13, 2023
86d55a2
small string formatting change
crodriguezvega Nov 13, 2023
d982d5d
chore: remove uneeded checking for static linking.
DimitrisJim Nov 13, 2023
d3f8709
chore: remove SetCodeHash from Coordinator.
DimitrisJim Nov 13, 2023
33d1315
add 08-wasm to go.work.example
crodriguezvega Nov 14, 2023
d0c05d5
Merge branch 'main' into feat/wasm-clients
charleenfei Nov 14, 2023
0bee18b
Fix Upgrade Tests (#5109)
chatton Nov 14, 2023
bde614e
Merge branch 'main' into feat/wasm-clients
DimitrisJim Nov 14, 2023
826df9e
imp: unpin contract in remove code hash (#5103)
crodriguezvega Nov 14, 2023
c53bac7
imp: return `Unauthorised` if code hash is not stored (#5102)
crodriguezvega Nov 14, 2023
825bf2b
add 08-wasm code owners (#5100)
crodriguezvega Nov 14, 2023
716fcdc
imp: check response in instantiate and migrate from wasm vm calls (#5…
crodriguezvega Nov 14, 2023
f4ddaee
address review comments
crodriguezvega Nov 14, 2023
1cf7a2f
add validate genesis
crodriguezvega Nov 14, 2023
c24f8ed
gofumpt
crodriguezvega Nov 14, 2023
a006cb2
update test
charleenfei Nov 15, 2023
4fe4530
Merge branch 'feat/wasm-client' into charly/issue#4926-write-e2e-test…
charleenfei Nov 15, 2023
2cb6729
wip: latest cms
charleenfei Nov 15, 2023
e71b80f
remove grandpa tests using test data
crodriguezvega Nov 15, 2023
edc525f
unused field
crodriguezvega Nov 15, 2023
7b377ea
Add an error-ing implementation for GoAPI. (#5105)
DimitrisJim Nov 15, 2023
3b1cb9a
Rename codeid/codehash to checksum (#5107)
DimitrisJim Nov 15, 2023
ff6f9a7
Merge branch 'main' into feat/wasm-clients
crodriguezvega Nov 15, 2023
c983119
Go mod tidy on 08-wasm.
DimitrisJim Nov 15, 2023
c0402b9
increase block time
charleenfei Nov 16, 2023
a344eb5
Merge branch 'feat/wasm-client' into charly/issue#4926-write-e2e-test…
charleenfei Nov 27, 2023
c5c6d78
merge artifacts
charleenfei Nov 27, 2023
4df51ff
sample config
charleenfei Nov 27, 2023
90f57ae
update relayer to support timeout
charleenfei Nov 27, 2023
769431c
rm validation for polkadot chain tx
charleenfei Nov 27, 2023
56a1e6b
Merge branch 'main' into charly/issue#4926-write-e2e-test-for-timeout…
charleenfei Nov 27, 2023
c842f39
merge artifacts
charleenfei Nov 27, 2023
554e53c
last merge artifact hopefully
charleenfei Nov 27, 2023
c8936c5
Merge branch 'main' into charly/issue#4926-write-e2e-test-for-timeout…
charleenfei Nov 27, 2023
558c204
Merge branch 'main' into charly/issue#4926-write-e2e-test-for-timeout…
charleenfei Nov 28, 2023
3d9ffb1
Merge branch 'main' into charly/issue#4926-write-e2e-test-for-timeout…
charleenfei Nov 28, 2023
8ff31e1
update to separate test
charleenfei Nov 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/sample.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ relayers:
tag: "latest"
- id: hyperspace
image: ghcr.io/misko9/hyperspace
tag: "local"
tag: "timeout"
Copy link
Member

Choose a reason for hiding this comment

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

It is a bit weird that the tag is called timeout :P

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah it is a bit weird, maybe for now we can re-tag this image and give it a better name. Happy if this happened in a follow up though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea, i think this should hopefully be fixed once we have a stable relayer image that's not running off just a branch...


cometbft:
logLevel: info
Expand Down
223 changes: 171 additions & 52 deletions e2e/tests/wasm/grandpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type GrandpaTestSuite struct {
// * send transfer over ibc
func (s *GrandpaTestSuite) TestMsgTransfer_Succeeds_GrandpaContract() {
ctx := context.Background()
t := s.T()

chainA, chainB := s.GetGrandpaTestChains()

Expand Down Expand Up @@ -109,6 +110,15 @@ func (s *GrandpaTestSuite) TestMsgTransfer_Succeeds_GrandpaContract() {
fundAmount := int64(12_333_000_000_000)
polkadotUser, cosmosUser := s.fundUsers(ctx, fundAmount, polkadotChain, cosmosChain)

// TODO: this can be refactored to broadcast a MsgTransfer instead of CLI.
// https://github.com/cosmos/ibc-go/issues/4963
amountToSend := int64(1_770_000)
transfer := ibc.WalletAmount{
Address: polkadotUser.FormattedAddress(),
Denom: cosmosChain.Config().Denom,
Amount: math.NewInt(amountToSend),
}

pathName := s.GetPathName(0)

err = r.GeneratePath(ctx, eRep, cosmosChain.Config().ChainID, polkadotChain.Config().ChainID, pathName)
Expand All @@ -135,79 +145,188 @@ func (s *GrandpaTestSuite) TestMsgTransfer_Succeeds_GrandpaContract() {
// Start relayer
s.Require().NoError(r.StartRelayer(ctx, eRep, pathName))

t.Run("send successful IBC transfer from Cosmos to Polkadot parachain", func(t *testing.T) {
// Send 1.77 stake from cosmosUser to parachainUser
tx, err := cosmosChain.SendIBCTransfer(ctx, "channel-0", cosmosUser.KeyName(), transfer, ibc.TransferOptions{})
s.Require().NoError(tx.Validate(), "source ibc transfer tx is invalid")
s.Require().NoError(err)
// verify token balance for cosmos user has decreased
balance, err := cosmosChain.GetBalance(ctx, cosmosUser.FormattedAddress(), cosmosChain.Config().Denom)
s.Require().NoError(err)
s.Require().Equal(balance, math.NewInt(fundAmount-amountToSend), "unexpected cosmos user balance after first tx")
err = testutil.WaitForBlocks(ctx, 15, cosmosChain, polkadotChain)
s.Require().NoError(err)

// Verify tokens arrived on parachain user
parachainUserStake, err := polkadotChain.GetIbcBalance(ctx, string(polkadotUser.Address()), 2)
s.Require().NoError(err)
s.Require().Equal(amountToSend, parachainUserStake.Amount.Int64(), "unexpected parachain user balance after first tx")
})

t.Run("send two successful IBC transfers from Polkadot parachain to Cosmos, first with ibc denom, second with parachain denom", func(t *testing.T) {
// Send 1.16 stake from parachainUser to cosmosUser
amountToReflect := int64(1_160_000)
reflectTransfer := ibc.WalletAmount{
Address: cosmosUser.FormattedAddress(),
Denom: "2", // stake
Amount: math.NewInt(amountToReflect),
}
_, err := polkadotChain.SendIBCTransfer(ctx, "channel-0", polkadotUser.KeyName(), reflectTransfer, ibc.TransferOptions{})
s.Require().NoError(err)

// Send 1.88 "UNIT" from Alice to cosmosUser
amountUnits := math.NewInt(1_880_000_000_000)
unitTransfer := ibc.WalletAmount{
Address: cosmosUser.FormattedAddress(),
Denom: "1", // UNIT
Amount: amountUnits,
}
_, err = polkadotChain.SendIBCTransfer(ctx, "channel-0", "alice", unitTransfer, ibc.TransferOptions{})
s.Require().NoError(err)

// Wait for MsgRecvPacket on cosmos chain
finalStakeBal := math.NewInt(fundAmount - amountToSend + amountToReflect)
err = cosmos.PollForBalance(ctx, cosmosChain, 20, ibc.WalletAmount{
Address: cosmosUser.FormattedAddress(),
Denom: cosmosChain.Config().Denom,
Amount: finalStakeBal,
})
s.Require().NoError(err)

// Wait for a new update state
err = testutil.WaitForBlocks(ctx, 5, cosmosChain, polkadotChain)
s.Require().NoError(err)

// Verify cosmos user's final "stake" balance
cosmosUserStakeBal, err := cosmosChain.GetBalance(ctx, cosmosUser.FormattedAddress(), cosmosChain.Config().Denom)
s.Require().NoError(err)
s.Require().True(cosmosUserStakeBal.Equal(finalStakeBal))

// Verify cosmos user's final "unit" balance
unitDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", "UNIT"))
cosmosUserUnitBal, err := cosmosChain.GetBalance(ctx, cosmosUser.FormattedAddress(), unitDenomTrace.IBCDenom())
s.Require().NoError(err)
s.Require().True(cosmosUserUnitBal.Equal(amountUnits))

// Verify parachain user's final "unit" balance (will be less than expected due gas costs for stake tx)
parachainUserUnits, err := polkadotChain.GetIbcBalance(ctx, string(polkadotUser.Address()), 1)
s.Require().NoError(err)
s.Require().True(parachainUserUnits.Amount.LTE(math.NewInt(fundAmount)), "parachain user's final unit amount not expected")

// Verify parachain user's final "stake" balance
parachainUserStake, err := polkadotChain.GetIbcBalance(ctx, string(polkadotUser.Address()), 2)
s.Require().NoError(err)
s.Require().True(parachainUserStake.Amount.Equal(math.NewInt(amountToSend-amountToReflect)), "parachain user's final stake amount not expected")
})
}

// TestMsgTransfer_TimesOut_GrandpaContract
// sets up cosmos and polkadot chains, hyperspace relayer, and funds users on both chains
// * sends transfer over ibc channel, this transfer should timeout
func (s *GrandpaTestSuite) TestMsgTransfer_TimesOut_GrandpaContract() {
ctx := context.Background()
t := s.T()

chainA, chainB := s.GetGrandpaTestChains()

polkadotChain := chainA.(*polkadot.PolkadotChain)
cosmosChain := chainB.(*cosmos.CosmosChain)

// we explicitly skip path creation as the contract needs to be uploaded before we can create clients.
r := s.ConfigureRelayer(ctx, polkadotChain, cosmosChain, nil, func(options *interchaintest.InterchainBuildOptions) {
options.SkipPathCreation = true
})

s.InitGRPCClients(cosmosChain)

cosmosWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)

file, err := os.Open("contracts/ics10_grandpa_cw.wasm")
s.Require().NoError(err)

checksum := s.PushNewWasmClientProposal(ctx, cosmosChain, cosmosWallet, file)

s.Require().NotEmpty(checksum, "checksum was empty but should not have been")

eRep := s.GetRelayerExecReporter()

// Set client contract hash in cosmos chain config
err = r.SetClientContractHash(ctx, eRep, cosmosChain.Config(), checksum)
s.Require().NoError(err)

// Ensure parachain has started (starts 1 session/epoch after relay chain)
err = testutil.WaitForBlocks(ctx, 1, polkadotChain)
s.Require().NoError(err, "polkadot chain failed to make blocks")

// Fund users on both cosmos and parachain, mints Asset 1 for Alice
fundAmount := int64(12_333_000_000_000)
polkadotUser, cosmosUser := s.fundUsers(ctx, fundAmount, polkadotChain, cosmosChain)

// TODO: this can be refactored to broadcast a MsgTransfer instead of CLI.
// https://github.com/cosmos/ibc-go/issues/4963
// Send 1.77 stake from cosmosUser to parachainUser
amountToSend := int64(1_770_000)
transfer := ibc.WalletAmount{
Address: polkadotUser.FormattedAddress(),
Denom: cosmosChain.Config().Denom,
Amount: math.NewInt(amountToSend),
}
tx, err := cosmosChain.SendIBCTransfer(ctx, "channel-0", cosmosUser.KeyName(), transfer, ibc.TransferOptions{})
s.Require().NoError(err)
s.Require().NoError(tx.Validate()) // test source wallet has decreased funds
err = testutil.WaitForBlocks(ctx, 15, cosmosChain, polkadotChain)
s.Require().NoError(err)

// Verify tokens arrived on parachain user
parachainUserStake, err := polkadotChain.GetIbcBalance(ctx, string(polkadotUser.Address()), 2)
s.Require().NoError(err)
s.Require().Equal(amountToSend, parachainUserStake.Amount.Int64(), "parachain user's stake amount not expected after first tx")
pathName := s.GetPathName(0)

// Send 1.16 stake from parachainUser to cosmosUser
amountToReflect := int64(1_160_000)
reflectTransfer := ibc.WalletAmount{
Address: cosmosUser.FormattedAddress(),
Denom: "2", // stake
Amount: math.NewInt(amountToReflect),
}
_, err = polkadotChain.SendIBCTransfer(ctx, "channel-0", polkadotUser.KeyName(), reflectTransfer, ibc.TransferOptions{})
err = r.GeneratePath(ctx, eRep, cosmosChain.Config().ChainID, polkadotChain.Config().ChainID, pathName)
s.Require().NoError(err)

// Send 1.88 "UNIT" from Alice to cosmosUser
amountUnits := math.NewInt(1_880_000_000_000)
unitTransfer := ibc.WalletAmount{
Address: cosmosUser.FormattedAddress(),
Denom: "1", // UNIT
Amount: amountUnits,
}
_, err = polkadotChain.SendIBCTransfer(ctx, "channel-0", "alice", unitTransfer, ibc.TransferOptions{})
// Create new clients
err = r.CreateClients(ctx, eRep, pathName, ibc.DefaultClientOpts())
s.Require().NoError(err)

// Wait for MsgRecvPacket on cosmos chain
finalStakeBal := math.NewInt(fundAmount - amountToSend + amountToReflect)
err = cosmos.PollForBalance(ctx, cosmosChain, 20, ibc.WalletAmount{
Address: cosmosUser.FormattedAddress(),
Denom: cosmosChain.Config().Denom,
Amount: finalStakeBal,
})
err = testutil.WaitForBlocks(ctx, 1, cosmosChain, polkadotChain) // these 1 block waits seem to be needed to reduce flakiness
s.Require().NoError(err)

// Wait for a new update state
err = testutil.WaitForBlocks(ctx, 5, cosmosChain, polkadotChain)
// Create a new connection
err = r.CreateConnections(ctx, eRep, pathName)
s.Require().NoError(err)

// Verify cosmos user's final "stake" balance
cosmosUserStakeBal, err := cosmosChain.GetBalance(ctx, cosmosUser.FormattedAddress(), cosmosChain.Config().Denom)
err = testutil.WaitForBlocks(ctx, 1, cosmosChain, polkadotChain)
s.Require().NoError(err)
s.Require().True(cosmosUserStakeBal.Equal(finalStakeBal))

// Verify cosmos user's final "unit" balance
unitDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", "UNIT"))
cosmosUserUnitBal, err := cosmosChain.GetBalance(ctx, cosmosUser.FormattedAddress(), unitDenomTrace.IBCDenom())
// Create a new channel & get channels from each chain
err = r.CreateChannel(ctx, eRep, pathName, ibc.DefaultChannelOpts())
s.Require().NoError(err)
s.Require().True(cosmosUserUnitBal.Equal(amountUnits))

// Verify parachain user's final "unit" balance (will be less than expected due gas costs for stake tx)
parachainUserUnits, err := polkadotChain.GetIbcBalance(ctx, string(polkadotUser.Address()), 1)
err = testutil.WaitForBlocks(ctx, 1, cosmosChain, polkadotChain)
s.Require().NoError(err)
s.Require().True(parachainUserUnits.Amount.LTE(math.NewInt(fundAmount)), "parachain user's final unit amount not expected")

// Verify parachain user's final "stake" balance
parachainUserStake, err = polkadotChain.GetIbcBalance(ctx, string(polkadotUser.Address()), 2)
s.Require().NoError(err)
s.Require().True(parachainUserStake.Amount.Equal(math.NewInt(amountToSend-amountToReflect)), "parachain user's final stake amount not expected")
// Start relayer
s.Require().NoError(r.StartRelayer(ctx, eRep, pathName))

t.Run("IBC transfer from Cosmos chain to Polkadot parachain times out", func(t *testing.T) {
// Stop relayer
s.Require().NoError(r.StopRelayer(ctx, s.GetRelayerExecReporter()))

tx, err := cosmosChain.SendIBCTransfer(ctx, "channel-0", cosmosUser.KeyName(), transfer, ibc.TransferOptions{Timeout: testvalues.ImmediatelyTimeout()})
s.Require().NoError(err)
s.Require().NoError(tx.Validate(), "source ibc transfer tx is invalid")
time.Sleep(time.Nanosecond * 1) // want it to timeout immediately

// check that tokens are escrowed
actualBalance, err := cosmosChain.GetBalance(ctx, cosmosUser.FormattedAddress(), cosmosChain.Config().Denom)
s.Require().NoError(err)
expected := fundAmount - amountToSend
s.Require().Equal(expected, actualBalance.Int64())

// start relayer
s.Require().NoError(r.StartRelayer(ctx, s.GetRelayerExecReporter(), s.GetPathName(0)))
err = testutil.WaitForBlocks(ctx, 15, polkadotChain, cosmosChain)
s.Require().NoError(err)

// ensure that receiver on parachain did not receive any tokens
receiverBalance, err := polkadotChain.GetIbcBalance(ctx, polkadotUser.FormattedAddress(), 2)
s.Require().NoError(err)
s.Require().Equal(int64(0), receiverBalance.Amount.Int64())

// check that tokens have been refunded to sender address
senderBalance, err := cosmosChain.GetBalance(ctx, cosmosUser.FormattedAddress(), cosmosChain.Config().Denom)
s.Require().NoError(err)
s.Require().Equal(fundAmount, senderBalance.Int64())
})
}

// TestMsgMigrateContract_Success_GrandpaContract features
Expand Down
2 changes: 1 addition & 1 deletion e2e/testsuite/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const (
defaultRlyTag = "latest"

// TODO: https://github.com/cosmos/ibc-go/issues/4965
defaultHyperspaceTag = "local"
defaultHyperspaceTag = "timeout"
// defaultHermesTag is the tag that will be used if no relayer tag is specified for hermes.
defaultHermesTag = "v1.7.0"
// defaultChainTag is the tag that will be used for the chains if none is specified.
Expand Down
Loading