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

Async Ack #1876

Merged
merged 19 commits into from
Jul 2, 2024
Merged

Async Ack #1876

merged 19 commits into from
Jul 2, 2024

Conversation

chipshort
Copy link
Contributor

@chipshort chipshort commented May 3, 2024

also fixes #1891

I had to do changes in quite a few places

@chipshort chipshort changed the title [Do Not Merge] Async Ack prototype [Do Not Merge] Async Ack May 23, 2024
@chipshort chipshort marked this pull request as ready for review May 23, 2024 11:26
Copy link

@srdtrk srdtrk left a comment

Choose a reason for hiding this comment

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

Lgtm. Added some comments :)

x/wasm/ibc.go Outdated Show resolved Hide resolved
x/wasm/keeper/handler_plugin.go Show resolved Hide resolved
x/wasm/keeper/handler_plugin.go Outdated Show resolved Hide resolved
@webmaster128 webmaster128 added this to the 0.52 milestone Jun 27, 2024
@chipshort chipshort changed the title [Do Not Merge] Async Ack Async Ack Jul 2, 2024

if data == nil {
// contract wants async acknowledgement, so store the packet for later
err = k.StoreAsyncAckPacket(ctx, convertPacket(msg.Packet))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this call into the keeper now (was in IBCHandler before). That makes the whole thing a little easier to understand, but now we have to convert the packet back into a channeltypes.Packet

Copy link

codecov bot commented Jul 2, 2024

Codecov Report

Attention: Patch coverage is 38.31776% with 66 lines in your changes missing coverage. Please review.

Project coverage is 54.68%. Comparing base (5ae2f4a) to head (eeb3cd4).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1876      +/-   ##
==========================================
- Coverage   54.87%   54.68%   -0.20%     
==========================================
  Files          65       65              
  Lines        9775     9857      +82     
==========================================
+ Hits         5364     5390      +26     
- Misses       3866     3919      +53     
- Partials      545      548       +3     
Files Coverage Δ
x/wasm/client/cli/tx.go 15.18% <ø> (ø)
x/wasm/keeper/keeper_cgo.go 94.11% <100.00%> (ø)
x/wasm/keeper/relay.go 79.38% <68.42%> (-1.87%) ⬇️
x/wasm/types/keys.go 52.30% <0.00%> (-8.41%) ⬇️
x/wasm/keeper/keeper.go 76.82% <41.66%> (-1.14%) ⬇️
x/wasm/keeper/handler_plugin.go 64.70% <31.48%> (-15.49%) ⬇️

Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

Great stuff.

I am just wondering about one thing: how to cleanup this temporary packet store at some point for the packets that get never acknowledged. Would be great to have some sort of configurable lifetime.

docs/proto/proto-docs.md Show resolved Hide resolved
@@ -225,8 +225,6 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/CosmWasm/wasmvm/v2 v2.0.0 h1:IqNCI2G0mvs7K6ej17/I28805rVqnu+Y1cWDqIdwb08=
github.com/CosmWasm/wasmvm/v2 v2.0.0/go.mod h1:su9lg5qLr7adV95eOfzjZWkGiky8WNaNIHDr7Fpu7Ck=
Copy link
Member

Choose a reason for hiding this comment

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

We should have a go mod tidy check in wasmd (just like wasmvm)

x/wasm/keeper/handler_plugin.go Outdated Show resolved Hide resolved
x/wasm/keeper/relay.go Outdated Show resolved Hide resolved
x/wasm/types/keys.go Outdated Show resolved Hide resolved
@webmaster128 webmaster128 mentioned this pull request Jul 2, 2024
6 tasks
@chipshort
Copy link
Contributor Author

how to cleanup this temporary packet store at some point for the packets that get never acknowledged. Would be great to have some sort of configurable lifetime.

That's a general problem with async acks, even on the ibc-go layer. If there is no ack, the packet commitment is not deleted there either.
Adding a lifetime opens a whole different can of worms. When would we clean it up?
Also, I'm not sure how a valid contract should handle that case. After deleting the stored packet, there is no way to ack the packet anymore, so that can in theory cause a packet that would otherwise have been acknowledged to get stuck.

I'm not convinced there's a good solution for this, so my take is to just live with the fact that incorrect contracts will write packets that are never cleaned up (just like they can write stuff into their own state that never gets cleaned up).

@webmaster128
Copy link
Member

my take is to just live with the fact that incorrect contracts will write packets that are never cleaned up

Right, sounds good. In that case should we add a storage write fee to StoreAsyncAckPacket? Or does prefixStore.Set(key, packetBz) charge gas automatically?

@chipshort
Copy link
Contributor Author

Yes prefixStore.Set(key, packetBz) will charge that. You can see an example in the test in relay_test.go.

Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>
Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

Beautiful

@chipshort chipshort merged commit 2e465b0 into main Jul 2, 2024
15 of 16 checks passed
@chipshort chipshort deleted the chipshort/async-ack branch July 2, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible problem with the nil ack
3 participants