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

Stop rejecting contract instantiation if account holds funds #776

Merged
merged 3 commits into from
Jan 30, 2024

Conversation

wojtek-coreum
Copy link
Collaborator

@wojtek-coreum wojtek-coreum commented Jan 26, 2024

Description

Reviewers checklist:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@wojtek-coreum wojtek-coreum requested a review from a team as a code owner January 26, 2024 09:11
@wojtek-coreum wojtek-coreum requested review from dzmitryhil, miladz68 and ysv and removed request for a team January 26, 2024 09:11
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (bdb7876) 33.04% compared to head (056a2dc) 33.06%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #776      +/-   ##
==========================================
+ Coverage   33.04%   33.06%   +0.01%     
==========================================
  Files         170      171       +1     
  Lines       48255    48266      +11     
==========================================
+ Hits        15948    15957       +9     
- Misses      29278    29280       +2     
  Partials     3029     3029              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @miladz68, @wojtek-coreum, and @ysv)


integration-tests/modules/wasm_test.go line 2238 at r1 (raw file):

}

// TestWASMContractInstantiationIsRejectedIfThereAreTokensOnItsAccount verifies that smart contract instantiation

TestWASMContractInstantiationIsRejectedIfThereAreTokensOnItsAccount is different from the test name.

Copy link
Collaborator Author

@wojtek-coreum wojtek-coreum left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @dzmitryhil, @miladz68, and @ysv)


integration-tests/modules/wasm_test.go line 2238 at r1 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

TestWASMContractInstantiationIsRejectedIfThereAreTokensOnItsAccount is different from the test name.

Done, funny that linter passed

Copy link
Contributor

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on @miladz68 and @ysv)

Copy link
Contributor

@ysv ysv left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @miladz68 and @wojtek-coreum)


app/app.go line 614 at r2 (raw file):

	wasmOpts := []wasmkeeper.Option{
		wasmkeeper.WithAcceptedAccountTypesOnContractInstantiation(
			&authtypes.BaseAccount{},

out of topic:
What happens when you try to instantiate contract with the same address as existing ?
Does This Pruner handle it ?


integration-tests/modules/wasm_test.go line 2288 at r2 (raw file):

					ToAddress:   contractAddress.String(),
					Amount:      sdk.NewCoins(amount),
					EndTime:     time.Now().Unix(),

IMO endTime should be in the future to properly test that vesting is applied


integration-tests/modules/wasm_test.go line 2302 at r2 (raw file):

					ToAddress:   contractAddress.String(),
					Amount:      sdk.NewCoins(amount),
					EndTime:     time.Now().Unix(),

IMO endTime should be in the future to properly test that vesting is applied


integration-tests/modules/wasm_test.go line 2481 at r2 (raw file):

}

func testSmartContractAccount(

what is the responsibility of this func ?
I didn't get the name

Code quote:

 testSmartContractAccount

Copy link
Collaborator Author

@wojtek-coreum wojtek-coreum left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @miladz68 and @ysv)


app/app.go line 614 at r2 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

out of topic:
What happens when you try to instantiate contract with the same address as existing ?
Does This Pruner handle it ?

I believe error saying that address is already taken is returned


integration-tests/modules/wasm_test.go line 2288 at r2 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

IMO endTime should be in the future to properly test that vesting is applied

Here I test that funds existing on the account are not burnt, that's why they are vested immediately. What you are describing is done separately in the next test below.


integration-tests/modules/wasm_test.go line 2481 at r2 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

what is the responsibility of this func ?
I didn't get the name

It verifies that the account used by the smart contract is in the expected state (account type, balance)

Copy link
Contributor

@ysv ysv left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @miladz68)

@wojtek-coreum wojtek-coreum merged commit fd1e810 into master Jan 30, 2024
10 checks passed
@wojtek-coreum wojtek-coreum deleted the wojtek/fix-contract-instantiation branch January 30, 2024 10:45
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.

3 participants