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

Add weighted operations run simulation #1055

Merged
merged 16 commits into from
Nov 2, 2022

Conversation

GNaD13
Copy link
Contributor

@GNaD13 GNaD13 commented Oct 19, 2022

Close #797

add operations run simulation for

  • update admin
  • migrate contract
  • clear admin

add new test contract for simulation migrate contract

@GNaD13 GNaD13 requested a review from alpe as a code owner October 19, 2022 14:31
@GNaD13 GNaD13 marked this pull request as draft October 19, 2022 15:00
@GNaD13 GNaD13 marked this pull request as ready for review October 23, 2022 17:20
Copy link
Member

@alpe alpe left a comment

Choose a reason for hiding this comment

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


msg := types.MsgUpdateAdmin{
Sender: simAccount.Address.String(),
NewAdmin: simtypes.RandomAccounts(r, 1)[0].Address.String(),
Copy link
Member

Choose a reason for hiding this comment

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

Let's use simtypes.RandomAcc(r, accs) instead to not run dry

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 have fixed

msg := types.MsgInstantiateContract{
Sender: simAccount.Address.String(),
Admin: simtypes.RandomAccounts(r, 1)[0].Address.String(),
Admin: adminAccount.Address.String(),
Copy link
Member

Choose a reason for hiding this comment

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

👍

DefaultWeightMsgInstantiateContract int = 100

DefaultWeightMsgStoreCode int = 100
DefaultWeightMsgInstantiateContract int = 50
Copy link
Member

Choose a reason for hiding this comment

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

Why flipping store and instantiate weights?

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 have fixed

DefaultWeightMsgExecuteContract int = 100
DefaultWeightMsgUpdateAdmin int = 100
Copy link
Member

Choose a reason for hiding this comment

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

I would expect this to happen quire rarely. How about 25?

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 have changed

DefaultWeightMsgExecuteContract int = 100
DefaultWeightMsgUpdateAdmin int = 100
DefaultWeightMsgClearAdmin int = 100
Copy link
Member

Choose a reason for hiding this comment

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

I would expect this to happen quire rarely. How about 10?

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 have changed

DefaultWeightMsgExecuteContract int = 100
DefaultWeightMsgUpdateAdmin int = 100
DefaultWeightMsgClearAdmin int = 100
DefaultWeightMsgMigrateContract int = 100
Copy link
Member

Choose a reason for hiding this comment

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

I would expect more instantiations than migrations. How about 50?

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 have changed

txCtx.SimAccount.PrivKey,
)
if err != nil {
return simtypes.NoOpMsg(types.ModuleName, types.MsgMigrateContract{}.Type(), "unable to generate mock tx"), nil, err
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
return simtypes.NoOpMsg(types.ModuleName, types.MsgMigrateContract{}.Type(), "unable to generate mock tx"), nil, err
return simtypes.NoOpMsg(types.ModuleName, types.MsgMigrateContract{}.Type(), "unable to generate tx"), nil, err

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 have changed

return simtypes.NoOpMsg(types.ModuleName, types.MsgMigrateContract{}.Type(), "unable to read response data"), nil, err
}

fmt.Printf("%v\n", result.Data[0].MsgType)
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid Printfs

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 have removed


var wasmBz []byte
var err error
wasmBz, err = os.ReadFile("./../x/wasm/keeper/testdata/reflect_1_1.wasm")
Copy link
Member

Choose a reason for hiding this comment

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

I tried to avoid hard coding any contracts here. See L106-7.
As we only store reflect contracts you can just pick a different code id and drop the store code part.

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 have fixed to embed

@alpe alpe changed the title add weighted operations run simulation Add weighted operations run simulation Nov 1, 2022
@codecov
Copy link

codecov bot commented Nov 1, 2022

Codecov Report

Merging #1055 (5697af6) into main (84e24d3) will decrease coverage by 0.08%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1055      +/-   ##
==========================================
- Coverage   59.28%   59.19%   -0.09%     
==========================================
  Files          53       53              
  Lines        6722     6732      +10     
==========================================
  Hits         3985     3985              
- Misses       2442     2452      +10     
  Partials      295      295              
Impacted Files Coverage Δ
x/wasm/module.go 37.90% <0.00%> (ø)
x/wasm/types/proposal.go 61.31% <0.00%> (-1.81%) ⬇️

@alpe
Copy link
Member

alpe commented Nov 1, 2022

Let's remove some code to finish this: see 5697af6

@GNaD13
Copy link
Contributor Author

GNaD13 commented Nov 2, 2022

Let's remove some code to finish this: see 5697af6

Got it :3 tysm!!!

@mergify mergify bot mentioned this pull request Nov 2, 2022
Copy link
Member

@alpe alpe left a comment

Choose a reason for hiding this comment

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

Great contribution! 🏄

@alpe alpe merged commit bfb4bc0 into CosmWasm:main Nov 2, 2022
NoahSaso pushed a commit to NoahSaso/wasmd that referenced this pull request Dec 2, 2022
* add WeightedOperations msg update admin

* add check contract info condition

* add fnc simulate migrate

* add weights operations migrate contract

* fix simulation msg update admin

* add simulation.NewWeightedOperation

* add sml msg clear admin

* fix lint

* remove msg migrate

* change admin to use test account

* add migrate

* add new contract for simulation migrate

* correct return log

* Polish SimulateMsgMigrateContract

Co-authored-by: Alex Peters <alpe@users.noreply.github.com>
Magicloud pushed a commit to fpco/wasmd that referenced this pull request Jan 13, 2023
* add WeightedOperations msg update admin

* add check contract info condition

* add fnc simulate migrate

* add weights operations migrate contract

* fix simulation msg update admin

* add simulation.NewWeightedOperation

* add sml msg clear admin

* fix lint

* remove msg migrate

* change admin to use test account

* add migrate

* add new contract for simulation migrate

* correct return log

* Polish SimulateMsgMigrateContract

Co-authored-by: Alex Peters <alpe@users.noreply.github.com>
conorpp pushed a commit to wormhole-foundation/wasmd that referenced this pull request Feb 1, 2023
* add WeightedOperations msg update admin

* add check contract info condition

* add fnc simulate migrate

* add weights operations migrate contract

* fix simulation msg update admin

* add simulation.NewWeightedOperation

* add sml msg clear admin

* fix lint

* remove msg migrate

* change admin to use test account

* add migrate

* add new contract for simulation migrate

* correct return log

* Polish SimulateMsgMigrateContract

Co-authored-by: Alex Peters <alpe@users.noreply.github.com>
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.

Add operations to run with Simulations
2 participants