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

feat: apply the wasm module of lbm-sdk #1

Merged
merged 10 commits into from
Jan 10, 2023

Conversation

zemyblue
Copy link
Member

@zemyblue zemyblue commented Jan 2, 2023

Apply all the wasm modules changes of lbm-sdk.
The x/wasm module is copied from the 3bdcb6ffe01c81615bedb777ca0e039cc46ef00c commit hash in lbm-sdk. And some parts is modified to fit properly. The modified part can be seen in the differences below.

The difference with lbm-sdk/x/wasm

  • use wamd's app instead of simapp of lbm-sdk
  • skip ibc unittest
  • add flagProposalType and cli.FlagProposal in gov tx cli (x/wasm/client/cli/gov_tx.go). This flags was added in cosmwasm/wasmd.
    • ProposalStoreCodeCmd()
    • ProposalInstantiateContractCmd()
    • ProposalMigrateContractCmd()
    • ProposalExecuteContractCmd()
    • ProposalSudoContractCmd()
    • ProposalUpdateContractAdminCmd()
    • ProposalClearContractAdminCmd()
    • ProposalPinCodesCmd()
    • ProposalUnpinCodesCmd()
    • ProposalUpdateInstantiateConfigCmd()
  • copy ReadFileWithSizeLimit function of lbm-sdk's internal file under x/wasm/client/cli/os directory. This is because functions inside internal directory cannot be imported.

Update process

  1. import zemyblue/lbm-sdk in line/wasmd (in this PR)
  2. register the PR which remove x/wasm in lbm-sdk. This lbm-sdk's PR imports current PR temporary and replace line/wasmd after merging current PR.
  3. register a PR to replace the import path of line/wasmd from zemyblue/lbm-sdk to line/lbm-sdk (via another PR in this repo)

app/app.go Outdated
Comment on lines 843 to 845
for acc := range maccPerms {
blockedAddrs[authtypes.NewModuleAddress(acc).String()] = !allowedReceivingModAcc[acc]
}

Check warning

Code scanning / CodeQL

Iteration over map

Iteration over map may be a possible source of non-determinism
@@ -239,9 +306,9 @@
}

func (k Keeper) instantiate(ctx sdk.Context, codeID uint64, creator, admin sdk.AccAddress, initMsg []byte, label string, deposit sdk.Coins, authZ AuthorizationPolicy) (sdk.AccAddress, []byte, error) {
defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "instantiate")
defer func(begin time.Time) { k.metrics.InstantiateElapsedTimes.Observe(time.Since(begin).Seconds()) }(time.Now())

Check warning

Code scanning / CodeQL

Calling the system time

Calling the system time may be a possible source of non-determinism
@@ -336,13 +404,16 @@

// Execute executes the contract instance
func (k Keeper) execute(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, msg []byte, coins sdk.Coins) ([]byte, error) {
defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "execute")
defer func(begin time.Time) { k.metrics.ExecuteElapsedTimes.Observe(time.Since(begin).Seconds()) }(time.Now())

Check warning

Code scanning / CodeQL

Calling the system time

Calling the system time may be a possible source of non-determinism
@@ -378,14 +450,17 @@
}

func (k Keeper) migrate(ctx sdk.Context, contractAddress sdk.AccAddress, caller sdk.AccAddress, newCodeID uint64, msg []byte, authZ AuthorizationPolicy) ([]byte, error) {
defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "migrate")
migrateSetupCosts := k.gasRegister.InstantiateContractCosts(k.IsPinnedCode(ctx, newCodeID), len(msg))
defer func(begin time.Time) { k.metrics.MigrateElapsedTimes.Observe(time.Since(begin).Seconds()) }(time.Now())

Check warning

Code scanning / CodeQL

Calling the system time

Calling the system time may be a possible source of non-determinism
@@ -451,21 +527,22 @@
// another native Go module directly, or on-chain governance (if sudo proposals are enabled). Thus, the keeper doesn't
// place any access controls on it, that is the responsibility or the app developer (who passes the wasm.Keeper in app.go)
func (k Keeper) Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) {
defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "sudo")
defer func(begin time.Time) { k.metrics.SudoElapsedTimes.Observe(time.Since(begin).Seconds()) }(time.Now())

Check warning

Code scanning / CodeQL

Calling the system time

Calling the system time may be a possible source of non-determinism
@@ -607,7 +688,7 @@

// QuerySmart queries the smart contract itself.
func (k Keeper) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error) {
defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "query-smart")
defer func(begin time.Time) { k.metrics.QuerySmartElapsedTimes.Observe(time.Since(begin).Seconds()) }(time.Now())

Check warning

Code scanning / CodeQL

Calling the system time

Calling the system time may be a possible source of non-determinism
@@ -661,7 +743,7 @@

// QueryRaw returns the contract's state for give key. Returns `nil` when key is `nil`.
func (k Keeper) QueryRaw(ctx sdk.Context, contractAddress sdk.AccAddress, key []byte) []byte {
defer telemetry.MeasureSince(time.Now(), "wasm", "contract", "query-raw")
defer func(begin time.Time) { k.metrics.QueryRawElapsedTimes.Observe(time.Since(begin).Seconds()) }(time.Now())

Check warning

Code scanning / CodeQL

Calling the system time

Calling the system time may be a possible source of non-determinism
version: v1.50.1
args: --timeout 10m
github-token: ${{ secrets.GITHUB_TOKEN }}
if: env.GIT_DIFF
Copy link

Choose a reason for hiding this comment

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

want a new line in the tail

run: |
cd ./benchmarks
go test -bench .
if: env.GIT_DIFF
Copy link

Choose a reason for hiding this comment

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

want a new line in the tail

README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
cmd/wasmd/root.go Outdated Show resolved Hide resolved

message EvidenceList {
repeated Evidence evidence = 1 [(gogoproto.nullable) = false];
}
Copy link

@shiki-tak shiki-tak Jan 6, 2023

Choose a reason for hiding this comment

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

nit: no new line at end of file

Copy link
Member Author

Choose a reason for hiding this comment

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

I added.

Copy link

@shiki-tak shiki-tak left a comment

Choose a reason for hiding this comment

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

LGTM

@zemyblue zemyblue merged commit cae21ec into Finschia:main Jan 10, 2023
@zemyblue zemyblue mentioned this pull request Mar 28, 2023
@zemyblue zemyblue deleted the apply_lbm_changes branch April 2, 2023 07:41
@da1suk8 da1suk8 mentioned this pull request May 8, 2023
5 tasks
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.

4 participants