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

Wasm hooks E2E test & change intermediary address prefix #3937

Merged
merged 14 commits into from
Jan 7, 2023

Conversation

nicolaslara
Copy link
Contributor

What is the purpose of the change

Adds an e2e test to wasm hooks

Brief Changelog

Adds an e2e test to wasm hooks

Testing and Verifying

att tests pass

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? (yes / no)
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (yes / no)
  • How is the feature or change documented? (not applicable / specification (x/<module>/spec/) / Osmosis docs repo / not documented)

@github-actions github-actions bot added the C:CLI label Jan 6, 2023
@github-actions github-actions bot added the C:docs Improvements or additions to documentation label Jan 6, 2023
@nicolaslara nicolaslara added V:state/breaking State machine breaking PR and removed C:docs Improvements or additions to documentation labels Jan 6, 2023
@github-actions github-actions bot added the C:docs Improvements or additions to documentation label Jan 6, 2023
Comment on lines +248 to +250
// co up two levels
projectDir := filepath.Dir(filepath.Dir(wd))
fmt.Println(wd, projectDir)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// co up two levels
projectDir := filepath.Dir(filepath.Dir(wd))
fmt.Println(wd, projectDir)
// go up two levels
projectDir := filepath.Dir(filepath.Dir(wd))

Comment on lines +261 to +262
// Using code_id 1 because this is the only contract right now. This may need to change if more contracts are added
contracts, err := nodeA.QueryContractsFromId(chainA.LatestCodeId)
Copy link
Member

Choose a reason for hiding this comment

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

I think this comment can be removed now right?

if len(balance) == 0 {
return false
}
return balance[0].Amount.Int64() == 10
Copy link
Member

Choose a reason for hiding this comment

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

Where does 10 come from? Can this be not hard coded or does it make the most sense to do it this way?

Copy link
Member

Choose a reason for hiding this comment

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

I think this is from the ibs transfer call up above. +1 to have a variable that we can format into the ibc transfer command and use here

amount := totalFunds.(map[string]interface{})["amount"].(string)
denom := totalFunds.(map[string]interface{})["denom"].(string)
// check if denom contains "uosmo"
return err == nil && amount == "10" && strings.Contains(denom, "ibc")
Copy link
Member

Choose a reason for hiding this comment

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

same question about 10

@@ -34,7 +34,7 @@ So we detail where we want to get each of these fields from:
* Sender: We cannot trust the sender of an IBC packet, the counterparty chain has full ability to lie about it.
We cannot risk this sender being confused for a particular user or module address on Osmosis.
So we replace the sender with an account to represent the sender prefixed by the channel and a wasm module prefix.
This is done by setting the sender to `Bech32(Hash("ibc-memo-action" || channelID || sender))`, where the channelId is the channel id on the local chain.
This is done by setting the sender to `Bech32(Hash("ibc-wasm-hook-intermediaryg" || channelID || sender))`, where the channelId is the channel id on the local chain.
Copy link
Member

Choose a reason for hiding this comment

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

I think there is a typo in "wasm-hook-intermediary" with the g at the end

@@ -0,0 +1,56 @@
package cli
Copy link
Member

Choose a reason for hiding this comment

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

can we use osmocli for this instead?

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 started looking into that and realized I didn't know how to use osmocli 😅, so in the interest of time, I just went with what I knew

Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

LGTM

contractAddr := contracts[0]

validatorAddr := nodeB.GetWallet(initialization.ValidatorWalletName)
fmt.Println("validatorAddr", validatorAddr)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fmt.Println("validatorAddr", validatorAddr)

if len(balance) == 0 {
return false
}
return balance[0].Amount.Int64() == 10
Copy link
Member

Choose a reason for hiding this comment

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

I think this is from the ibs transfer call up above. +1 to have a variable that we can format into the ibc transfer command and use here


// sender wasm addr
senderBech32, err := ibchookskeeper.DeriveIntermediateSender("channel-0", validatorAddr, "osmo")
fmt.Println("sender", senderBech32)
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'm not sure if prints are helpful for debugging purposes. If so, can we change them to be logs. Logs format lines and test case info, making it easier to debug and also don't bypass testing package's output buffering

Suggested change
fmt.Println("sender", senderBech32)
s.T().Log("sender", senderBech32)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

prints were a leftover from when I was debugging. Can be removed (or logged)

15*time.Second,
10*time.Millisecond,
)
fmt.Println("response", response)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fmt.Println("response", response)
s.T().Log("response", response)

@ValarDragon ValarDragon changed the title Wasm hooks E2E test Wasm hooks E2E test & change intermediary address prefix Jan 7, 2023
@ValarDragon ValarDragon added the A:backport/v14.x backport patches to v14.x branch label Jan 7, 2023
@ValarDragon ValarDragon merged commit 637f3f3 into main Jan 7, 2023
@ValarDragon ValarDragon deleted the nicolas/wasm-hooks-e2e branch January 7, 2023 08:53
mergify bot pushed a commit that referenced this pull request Jan 7, 2023
* initial setup for manual and e2e tests

* added cli for calculating the sender

* tidy

* added cleaner flags and better checks at the end

* proper checks

* cleanup

* initial e2e tests

* debugging

* cleanup

* tidy

* remove import cycle

* test cleanup

* updated prefix

* fix go test

(cherry picked from commit 637f3f3)

# Conflicts:
#	go.mod
#	go.sum
#	go.work.sum
#	tests/ibc-hooks/ibc_middleware_test.go
#	x/ibc-hooks/README.md
#	x/ibc-hooks/wasm_hook.go
@ValarDragon ValarDragon removed the A:backport/v14.x backport patches to v14.x branch label Jan 7, 2023
nicolaslara added a commit that referenced this pull request Jan 7, 2023
* initial setup for manual and e2e tests

* added cli for calculating the sender

* tidy

* added cleaner flags and better checks at the end

* proper checks

* cleanup

* initial e2e tests

* debugging

* cleanup

* tidy

* remove import cycle

* test cleanup

* updated prefix

* fix go test
ValarDragon pushed a commit that referenced this pull request Jan 7, 2023
* Add sender to wasm hooks (#3879)

* added sender to wasm hooks

* cleaner transfer. The module doesn't need to get the funds at any point

* wasmhooks doesn't need an account anymore

* using ibc hooks from this branch

* added comment for account from when the upgrade happened

* getting the prefix from the config

* using address with prefix

* updated ibc-hooks hash

* updated sum files

* updated spec

* updaed go.mod to match main (bad merge)

* removed unnecessary include

* updated go.mod

* updated go.mod

* ibc-hooks mod change

* external change

* Wasm hooks E2E test & change intermediary address prefix (#3937)

* initial setup for manual and e2e tests

* added cli for calculating the sender

* tidy

* added cleaner flags and better checks at the end

* proper checks

* cleanup

* initial e2e tests

* debugging

* cleanup

* tidy

* remove import cycle

* test cleanup

* updated prefix

* fix go test

* internal go mod change

* external go mod change

* go sum

* document manual test script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:CLI C:docs Improvements or additions to documentation V:state/breaking State machine breaking PR
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants