Skip to content

Commit 1c43f20

Browse files
authored
Merge branch 'main' into fix/issue-151-zkgm-only-maker-ack
2 parents 07c856d + 6f1a139 commit 1c43f20

16 files changed

Lines changed: 224 additions & 58 deletions

gno.land/r/core/ibc/v1/apps/zkgm/gnokey_tx_queries_zkgm.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ Verify:
272272
```txt
273273
commitment_before_ack true
274274
sender_balance_before_ack 0
275-
commitment_after_ack false
275+
commitment_after_ack true
276276
sender_balance_after_ack 21
277277
OK!
278278
```
@@ -299,7 +299,7 @@ Verify:
299299
```txt
300300
commitment_before_timeout true
301301
sender_balance_before_timeout 0
302-
commitment_after_timeout false
302+
commitment_after_timeout true
303303
sender_balance_after_timeout 21
304304
OK!
305305
```
@@ -327,7 +327,7 @@ Verify:
327327
commitment_before_ack true
328328
sender_balance_before_ack 0
329329
market_maker_balance_before_ack 0
330-
commitment_after_ack false
330+
commitment_after_ack true
331331
sender_balance_after_ack 0
332332
market_maker_balance_after_ack 21
333333
OK!

gno.land/r/core/ibc/v1/apps/zkgm/testing/e2e/scenarios_batchsend/z41_forward_multihop_roundtrip_filetest.gno

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func main(cur realm) {
6464
// parent_ack_before_ack false
6565
//
6666
// [SCENARIO] 2. child ack propagates to parent
67-
// child_commitment_after_ack false
67+
// child_commitment_after_ack true
6868
// in_flight_after_ack false
6969
// parent_ack_after_ack true
7070
// parent_ack_matches_child_ack true

gno.land/r/core/ibc/v1/apps/zkgm/testing/e2e/scenarios_batchsend/zs11_handshake_send_recv_ack_success_filetest.gno

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ func main(cur realm) {
6565
// quote_balance_after_recv 21
6666
//
6767
// [SCENARIO] 3. ack success
68-
// commitment_after_ack false
68+
// commitment_after_ack true
6969
// receipt_after_ack true
7070
// ack_success_roundtrip ok

gno.land/r/core/ibc/v1/apps/zkgm/testing/e2e/scenarios_batchsend/zs14b_ack_timeout_noops_filetest.gno

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func main(cur realm) {
4949

5050
order := z.TokenOrderV2{
5151
Sender: []byte(sender),
52-
Receiver: []byte(marketMaker),
52+
Receiver: []byte("timeout-only-receiver"),
5353
BaseToken: []byte("ibc/base"),
5454
BaseAmount: u256.NewUint(21),
5555
QuoteToken: []byte("ugnot"),
@@ -81,12 +81,21 @@ func main(cur realm) {
8181

8282
println("")
8383
println("[SCENARIO] 4. ack after timeout is skipped")
84-
e2e.BatchSend(cross(cur), packet)
85-
core.PacketTimeout(cross(cur), core.NewMsgPacketTimeout(cross(cur), packet, nil, core.Height(1)))
86-
println("commitment_after_timeout", core.HasPacketCommitment(cross(cur), packet))
84+
timeoutPacket := core.NewPacket(cross(cur), pair.Source, pair.Destination, e2e.MustPacketData(cross(cur), e2e.MustTokenOrderInstruction(cross(cur), z.TokenOrderV2{
85+
Sender: []byte(sender),
86+
Receiver: []byte(marketMaker),
87+
BaseToken: []byte("ibc/base"),
88+
BaseAmount: u256.NewUint(21),
89+
QuoteToken: []byte("ugnot"),
90+
QuoteAmount: u256.NewUint(21),
91+
Kind: z.TOKEN_ORDER_KIND_UNESCROW,
92+
})), 0, core.Timestamp(1))
93+
e2e.BatchSend(cross(cur), timeoutPacket)
94+
core.PacketTimeout(cross(cur), core.NewMsgPacketTimeout(cross(cur), timeoutPacket, nil, core.Height(1)))
95+
println("commitment_after_timeout", core.HasPacketCommitment(cross(cur), timeoutPacket))
8796
println("sender_after_timeout", impl.VoucherBalanceOf(string(order.BaseToken), address(sender)))
8897

89-
core.PacketAcknowledgement(cross(cur), ackMsg)
98+
core.PacketAcknowledgement(cross(cur), core.NewMsgPacketAcknowledgement(cross(cur), []core.Packet{timeoutPacket}, [][]byte{ack}, nil, core.Height(1)))
9099
println("market_maker_after_ack_after_timeout", impl.VoucherBalanceOf(string(order.BaseToken), address(marketMaker)))
91100
println("sender_after_ack_after_timeout", impl.VoucherBalanceOf(string(order.BaseToken), address(sender)))
92101
println("ack_timeout_noops", "ok")
@@ -119,18 +128,18 @@ func mustMarketMakerTokenOrderAck(marketMaker []byte) []byte {
119128

120129
// Output:
121130
// [SCENARIO] 1. first ack settles
122-
// commitment_after_first_ack false
131+
// commitment_after_first_ack true
123132
// market_maker_after_first_ack 21
124133
//
125134
// [SCENARIO] 2. duplicate ack is skipped
126-
// commitment_after_second_ack false
135+
// commitment_after_second_ack true
127136
// market_maker_after_second_ack 21
128137
//
129138
// [SCENARIO] 3. timeout after ack is skipped
130139
// sender_after_timeout_after_ack 0
131140
//
132141
// [SCENARIO] 4. ack after timeout is skipped
133-
// commitment_after_timeout false
142+
// commitment_after_timeout true
134143
// sender_after_timeout 21
135144
// market_maker_after_ack_after_timeout 21
136145
// sender_after_ack_after_timeout 21

gno.land/r/core/ibc/v1/apps/zkgm/testing/e2e/scenarios_batchsend/zs54_forward_child_timeout_parent_failure_ack_filetest.gno

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ package scenarios_batchsend
44
import (
55
u256 "gno.land/p/gnoswap/uint256"
66
z "gno.land/p/onbloc/unionibc/zkgm"
7-
core "gno.land/r/onbloc/unionibc/v1/core"
87
zkgm "gno.land/r/onbloc/unionibc/v1/apps/zkgm"
98
e2e "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/e2e"
109
_ "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/loader"
10+
core "gno.land/r/onbloc/unionibc/v1/core"
1111
)
1212

1313
const forwardChildTimeoutClientType = core.ClientType("gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/e2e/scenarios_batchsend/forward-child-timeout")
@@ -125,13 +125,13 @@ func expectedUniversalErrorAckHash(cur realm) string {
125125
// child_inflight_after_recv true
126126
//
127127
// [SCENARIO] 2. child timeout writes parent failure ack
128-
// child_commitment_after_timeout false
128+
// child_commitment_after_timeout true
129129
// child_inflight_after_timeout false
130130
// parent_ack_after_timeout true
131131
// parent_ack_is_universal_error true
132132
//
133133
// [SCENARIO] 3. duplicate child timeout is a no-op
134-
// child_commitment_after_second_timeout false
134+
// child_commitment_after_second_timeout true
135135
// child_inflight_after_second_timeout false
136136
// parent_ack_after_second_timeout true
137137
// parent_ack_hash_unchanged_after_second_timeout true
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// PKGPATH: gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/loader
2+
package loader
3+
4+
import (
5+
stdtesting "testing"
6+
7+
u256 "gno.land/p/gnoswap/uint256"
8+
"gno.land/p/nt/testutils/v0"
9+
z "gno.land/p/onbloc/unionibc/zkgm"
10+
zkgm "gno.land/r/onbloc/unionibc/v1/apps/zkgm"
11+
e2e "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/e2e"
12+
sh "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/scenariohelpers"
13+
impl "gno.land/r/onbloc/unionibc/v1/apps/zkgm/v0/impl"
14+
core "gno.land/r/onbloc/unionibc/v1/core"
15+
)
16+
17+
func main(cur realm) {
18+
inst := sh.InstallImpl(cross(cur))
19+
zkgm.RegisterCoreApp(cross(cur))
20+
e2e.RegisterMockLightClient(cross(cur))
21+
pair := e2e.OpenE2EChannelPair(cross(cur))
22+
23+
sender := string(testutils.TestAddress("zs89-sender"))
24+
baseToken := sh.MintVoucher(cross(cur), inst, core.ChannelId(80), "base/zs89", sender, 100, "ZS89")
25+
order := z.TokenOrderV2{
26+
Sender: []byte(sender),
27+
Receiver: []byte("remote-zs89"),
28+
BaseToken: []byte(baseToken),
29+
BaseAmount: u256.NewUint(21),
30+
QuoteToken: []byte("quote/zs89"),
31+
QuoteAmount: u256.NewUint(21),
32+
Kind: z.TOKEN_ORDER_KIND_ESCROW,
33+
}
34+
instr := e2e.MustTokenOrderInstruction(cross(cur), order)
35+
36+
println("[SCENARIO] first public send commits and escrows")
37+
stdtesting.SetRealm(stdtesting.NewUserRealm(address(sender)))
38+
packet := zkgm.Send(cross(cur), pair.Source, core.Timestamp(100), [32]byte{}, instr)
39+
println("sender_after_first", impl.VoucherBalanceOf(baseToken, address(sender)))
40+
println("channel_after_first", sh.ChannelBalanceStr(pair.Source, u256.Zero(), order.BaseToken, order.QuoteToken))
41+
println("commitment_after_first", core.HasPacketCommitment(cross(cur), packet))
42+
43+
println("")
44+
println("[SCENARIO] duplicate public send aborts and rolls escrow back")
45+
46+
println("duplicate_rejected", zs89DuplicateSendReverted(cur, sender, pair.Source, instr))
47+
println("sender_after_duplicate", impl.VoucherBalanceOf(baseToken, address(sender)))
48+
println("channel_after_duplicate", sh.ChannelBalanceStr(pair.Source, u256.Zero(), order.BaseToken, order.QuoteToken))
49+
println("commitment_after_duplicate", core.HasPacketCommitment(cross(cur), packet))
50+
}
51+
52+
func zs89DuplicateSendReverted(cur realm, sender string, channelId core.ChannelId, instr z.Instruction) bool {
53+
p := revive(func() {
54+
stdtesting.SetRealm(stdtesting.NewUserRealm(address(sender)))
55+
zkgm.Send(cross(cur), channelId, core.Timestamp(100), [32]byte{}, instr)
56+
})
57+
return p != nil
58+
}
59+
60+
// Output:
61+
// [SCENARIO] first public send commits and escrows
62+
// sender_after_first 79
63+
// channel_after_first 21
64+
// commitment_after_first true
65+
//
66+
// [SCENARIO] duplicate public send aborts and rolls escrow back
67+
// duplicate_rejected true
68+
// sender_after_duplicate 79
69+
// channel_after_duplicate 21
70+
// commitment_after_duplicate true

gno.land/r/core/ibc/v1/apps/zkgm/testing/realcometbls/scenarios_batchsend/z36_real_cometbls_ack_token_order_filetest.gno

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
package scenarios_batchsend
33

44
import (
5-
z "gno.land/p/onbloc/unionibc/zkgm"
65
u256 "gno.land/p/gnoswap/uint256"
76
"gno.land/p/nt/testutils/v0"
8-
core "gno.land/r/onbloc/unionibc/v1/core"
7+
z "gno.land/p/onbloc/unionibc/zkgm"
98
e2e "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/e2e"
109
_ "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/loader"
1110
realcometbls "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/realcometbls"
1211
impl "gno.land/r/onbloc/unionibc/v1/apps/zkgm/v0/impl"
12+
core "gno.land/r/onbloc/unionibc/v1/core"
1313
)
1414

1515
func main(cur realm) {
@@ -54,6 +54,6 @@ func mustMarketMakerTokenOrderAck(marketMaker []byte) []byte {
5454
// Output:
5555
// commitment_before_ack true
5656
// market_maker_balance_before_ack 0
57-
// commitment_after_ack false
57+
// commitment_after_ack true
5858
// market_maker_balance_after_ack 21
5959
// ack_real_cometbls ok

gno.land/r/core/ibc/v1/apps/zkgm/testing/realcometbls/scenarios_batchsend/z37_real_cometbls_timeout_non_membership_filetest.gno

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
package scenarios_batchsend
33

44
import (
5-
z "gno.land/p/onbloc/unionibc/zkgm"
65
u256 "gno.land/p/gnoswap/uint256"
76
"gno.land/p/nt/testutils/v0"
8-
core "gno.land/r/onbloc/unionibc/v1/core"
7+
z "gno.land/p/onbloc/unionibc/zkgm"
98
e2e "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/e2e"
109
_ "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/loader"
1110
realcometbls "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/realcometbls"
1211
impl "gno.land/r/onbloc/unionibc/v1/apps/zkgm/v0/impl"
12+
core "gno.land/r/onbloc/unionibc/v1/core"
1313
)
1414

1515
func main(cur realm) {
@@ -41,6 +41,6 @@ func main(cur realm) {
4141
// Output:
4242
// commitment_before_timeout true
4343
// sender_balance_before_timeout 0
44-
// commitment_after_timeout false
44+
// commitment_after_timeout true
4545
// sender_balance_after_timeout 21
4646
// timeout_real_cometbls ok

gno.land/r/core/ibc/v1/apps/zkgm/testing/realcometbls/scenarios_batchsend/z38b_ack_double_ack_noop_filetest.gno

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
package scenarios_batchsend
33

44
import (
5-
z "gno.land/p/onbloc/unionibc/zkgm"
65
u256 "gno.land/p/gnoswap/uint256"
76
"gno.land/p/nt/testutils/v0"
8-
core "gno.land/r/onbloc/unionibc/v1/core"
7+
z "gno.land/p/onbloc/unionibc/zkgm"
98
e2e "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/e2e"
109
_ "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/loader"
1110
realcometbls "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/realcometbls"
1211
impl "gno.land/r/onbloc/unionibc/v1/apps/zkgm/v0/impl"
12+
core "gno.land/r/onbloc/unionibc/v1/core"
1313
)
1414

1515
func main(cur realm) {
@@ -53,8 +53,8 @@ func mustMarketMakerTokenOrderAck(marketMaker []byte) []byte {
5353
}
5454

5555
// Output:
56-
// commitment_after_first_ack false
56+
// commitment_after_first_ack true
5757
// market_maker_balance_after_first_ack 21
58-
// commitment_after_second_ack false
58+
// commitment_after_second_ack true
5959
// market_maker_balance_after_second_ack 21
6060
// double_ack_noop ok

gno.land/r/core/ibc/v1/apps/zkgm/testing/realcometbls/scenarios_batchsend/z38c_timeout_after_ack_noop_filetest.gno

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
package scenarios_batchsend
33

44
import (
5-
z "gno.land/p/onbloc/unionibc/zkgm"
65
u256 "gno.land/p/gnoswap/uint256"
76
"gno.land/p/nt/testutils/v0"
8-
core "gno.land/r/onbloc/unionibc/v1/core"
7+
z "gno.land/p/onbloc/unionibc/zkgm"
98
e2e "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/e2e"
109
_ "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/loader"
1110
realcometbls "gno.land/r/onbloc/unionibc/v1/apps/zkgm/testing/realcometbls"
1211
impl "gno.land/r/onbloc/unionibc/v1/apps/zkgm/v0/impl"
12+
core "gno.land/r/onbloc/unionibc/v1/core"
1313
)
1414

1515
func main(cur realm) {
@@ -56,10 +56,10 @@ func mustMarketMakerTokenOrderAck(marketMaker []byte) []byte {
5656
}
5757

5858
// Output:
59-
// commitment_after_ack false
59+
// commitment_after_ack true
6060
// market_maker_balance_after_ack 21
6161
// sender_balance_before_timeout 0
62-
// commitment_after_timeout false
62+
// commitment_after_timeout true
6363
// market_maker_balance_after_timeout 21
6464
// sender_balance_after_timeout 0
6565
// timeout_after_ack_noop ok

0 commit comments

Comments
 (0)