Giter VIP home page Giter VIP logo

wasmd's Issues

Enable the use of wasmplus's `IsInactiveContract()` in cosmwasmAPI

In the dynamic_link branch separated process, the following function of wasmplus cannot be used in the #22 separated method due to circular reference problems.

Separation must be done by another method

func (k Keeper) IsInactiveContract(ctx sdk.Context, contractAddress sdk.AccAddress) bool {
store := ctx.KVStore(k.storeKey)
return store.Has(types.GetInactiveContractKey(contractAddress))
}

Add `wasmvm.GoAPI` field to the keeper structure

The method #36 cannot be executed in x/wasm alone, because it uses the x/wasmplus functionality within x/wasm.

Then, instead of pluskeeper, which was added in #36, add an interface of wasmvm.GoAPI to the structure of keeper.
This allows the implementation of this interface to freely change the contents of the API.

Version bump to wasmd v0.50.0

This issue is related to #121

I have conducted operational verification using the current commit hash with the versions from Finschia/cosmwasm#342 and Finschia/wasmvm#139.

Remaining CI error

  • TestZeroHeightGenesis (appplus/export_test.go)
  • TestOnRecvPacket (x/wasm/ibc_test.go) - prefix error
  • TestParseVerificationFlags (x/wasm/client/cli/tx_test.go) - prefix error
  • TestGenesisInit (x/wasm/keeper/genesis_test.go)
  • TestImportContractWithCodeHistoryPreserved (x/wasm/keeper/genesis_test.go)
  • TestInstantiate (x/wasm/keeper/keeper_test.go) - address error
  • TestExecute (x/wasm/keeper/keeper_test.go) - address error
  • TestSudo (x/wasm/keeper/keeper_test.go) - address error
  • TestQueryAllContractState (x/wasm/keeper/keeper_test.go)
  • TestQueryRawContractState (x/wasm/keeper/querier_test.go)
  • TestQueryCode (x/wasm/keeper/querier_test.go)
  • TestQueryCodeList (x/wasm/keeper/querier_test.go)
  • TestQueryPinnedCodes (x/wasm/keeper/querier_test.go)
  • TestQueryCodeInfo (x/wasm/keeper/querier_test.go) - prefix error
  • TestQueryCodeInfoList (x/wasm/keeper/querier_test.go) - prefix error
  • TestDispatchSubMsgErrorHandling (x/wasm/keeper/submsg_test.go)
  • TestModuleMigrations (x/wasm/keeper/migrations_integration_test.go)
  • TestCodeValidateBasic (x/wasm/types/genesis_test.go)
  • TestHandleStoreAndInstantiate (x/wasmplus/module_test.go ONLY Finschia) - address error
  • TestErrorsCreateAndInstantiate (x/wasmplus/module_test.go ONLY Finschia)
  • TestHandleNonPlusWasmCreate (x/wasmplus/module_test.go ONLY Finschia)
  • TestGenesisExportImport (x/wasmplus/keeoer/genesis_test.go ONLY Finschia)

bump up wasmd v0.31

bump up to cosmwasm/wasmd v0.31

dependency

  • cosmwasm/wasmvm: v1.2.0
  • cosmwasm/cosmwasm-std: v1.0-1.2

Refactoring message_sever integration test

MsgStoreCodeAndInstantiateContract amino signature verify fail

MsgStoreCodeAndInstantiateContract amino signature verify fails because wrong amino codec is being used in MsgStoreCodeAndInstantiateContract::GetSignBytes(). Now wasm's amino codec is being used not wasmplus's amino codec.
https://github.com/line/wasmd/blob/main/x/wasmplus/types/tx.go#L54

And I got one more error.
https://github.com/line/wasmd/blob/main/x/wasmplus/types/codec.go#L19
when registering amino msg in codec, amino message type name is wrong.
currently "wasm/StoreCodeAndInstantiateContract", this should be "wasm/MsgStoreCodeAndInstantiateContract" like other messages.

Invalid address for call_callable_point or validate_dynamic_link_interface causes panic

Now we use MustAccAddressFromBech32 for converting bech32 string to account address in

contractAddr := sdk.MustAccAddressFromBech32(contractAddrStr)

and

contractAddr := sdk.MustAccAddressFromBech32(contractAddrStr)

.

It panics if the bech32 string is an invalid address.

https://github.com/Finschia/finschia-sdk/blob/d8ceec3131bbc09eae61437a532298bb77356033/types/address.go#L162

We should use AccAddressFromBech32 and do error handling for them.

Redesign `callablePointSDKEventAttributes` function

This function came from #26.

It's a bit weird that the callstack comes first, so move it to the tail.

func callablePointSDKEventAttributes(customAttributes []wasmvmtypes.EventAttribute, contractAddr sdk.AccAddress, callstack []byte) ([]sdk.Attribute, error) {
attrs, err := wasmkeeper.ContractSDKEventAttributes(customAttributes, contractAddr)
if err != nil {
return nil, err
}
// attrs[0] is addr
attrs = append([]sdk.Attribute{attrs[0], sdk.NewAttribute(wasmplustypes.AttributeKeyCallstack, string(callstack))}, attrs[1:]...)
return attrs, nil
}

Research about standard interface detection.

Summary

Research about standard interface detection.

  • Research on function that can replace EVM's function selector.
  • Defining standard interface detection protocol.
  • Suggest a way to use an external library like inheritance from wasm.

Problem Definition

We need to know whether a specific smart contract supports a specific protocol, so that the smart contract can be excute and searched without errors in other smart contracts. For this purpose, in the case of EVM, the function of a function selector is provided. Let's see if there is a function that can replace EVM's function selector function that can distinguish a specific function from the wasm binary even in wasm of lbm-sdk.

If that feature doesn't exist, find out how to replace it.

Inheritance is not supported like EVM throught rustlang, the smart contract development language of cosmwasm. Then, we also suggest how to make a protocol such as ERC-165 a library so that other smart contract developers can use it.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

Propose methods to completely separate the functions of dynamic_link into wasmplus

At present #22, only partial separation has been made for dynamic link branch of wasmd, so consider how to do this.


The following methods were used for implementation.

In #36, moved dynamic_link branch functionality to wasmplus.

It is implemented in the following way.

  1. Define the interface of the function defined in x/wasmplus/keeper.go in x/wasm/keeper.go.
  2. In x/wasm, functions and variables to be exposed to the outside world are defined as other variables in exported_*.go, in order to reduce differences from the original.
  3. Access the functions defined in x/wasmplus/api.go via the interface in x/wasm/keeper.go.

Make mock for bankplus module of finschia-sdk

Description

The current version of wasmd depends on the bankplus feature, which is an original functionality of the finschia-sdk.
Since the finschia-sdk is currently undergoing a version bump, we will use mocks to handle this dependency in the meantime.

This PR related to Finschia/finschia-sdk#1195, Finschia/finschia-sdk#1212

The parts that use bankplus are located in the following files:

  • app/app.go
  • appplus/app.go
  • x/wasm/keeper/genesis_test.go
  • x/wasm/keeper/options_test.go
  • x/wasm/keeper/test_common.go
  • x/wasmplus/keeper/genesis_test.go
  • x/wasmplus/keeper/keeper.go
  • x/wasmplus/keeper/test_common.go

The NewBaseKeeper interface will be modified as follows:

Before:
func NewBaseKeeper(
	cdc codec.Codec, storeKey sdk.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace,
	blockedAddr map[string]bool, deactMultiSend bool,
) BaseKeeper
After: 
func NewBaseKeeper(
	cdc codec.Codec, storeService store.KVStoreService, ak types.AccountKeeper,
	blockedAddr map[string]bool, deactMultiSend bool, authority string, logger log.Logger,
) BaseKeeper

wasmvm module not exist

When I run wasmd start, wasmvm module not exist error is occurred.

$ ./build/wasmd start
Error: wasmvm module not exist
Usage:
  wasmd start [flags]

commit hash: 577e450 (main branch)

TestExecuteManualInactiveContractFailure does not check whether the contract is active or not

func TestExecuteManualInactiveContractFailure(t *testing.T) {
ctx, keepers := CreateTestInput(t, false, AvailableCapabilities)
keeper := keepers.ContractKeeper
deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000))
topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000))
creator := keepers.Faucet.NewFundedRandomAccount(ctx, deposit...)
fred := keepers.Faucet.NewFundedRandomAccount(ctx, topUp...)
wasmCode, err := os.ReadFile("./testdata/hackatom.wasm")
require.NoError(t, err)
contractID, _, err := keeper.Create(ctx, creator, wasmCode, nil)
require.NoError(t, err)
_, _, bob := keyPubAddr()
initMsg := HackatomExampleInitMsg{
Verifier: fred,
Beneficiary: bob,
}
initMsgBz, err := json.Marshal(initMsg)
require.NoError(t, err)
addr, _, err := keeper.Instantiate(ctx, contractID, creator, nil, initMsgBz, "demo contract 3", deposit)
require.NoError(t, err)
require.Equal(t, "link14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sgf2vn8", addr.String())
}

Not good condition to handle MsgStoreCodeAndInstantiateContract

if err != nil && strings.Contains(err.Error(), "MsgStoreCodeAndInstantiateContract") {

This handler case is caused by "x/wasm/handler"'s "ErrorMsg". This condition is true when the message contains "MsgStoreCodeAndInstantiateContract" even if the message kind is not "MsgStoreCodeAndInstantiateContract".

Change it the condition is true iff the message kind is "MsgStoreCodeAndInstantiateContract".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.