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

docs: replace links to Cosmos's repository with ours #245

Merged
merged 15 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x/wasm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Add tests for managing max contract size (#51)

### Changed
- Replace links to original CosmWasm code with ours (#244)
- Change used marshal/unmarshal from json.(Un)Marshal -> codec.(Un)Marshal (#37)
- Change the max size of contract managed with the parameter module (#44)
- Update linkwasmd to follow CosmWasm's wasmd v0.11.1 (#65)
Expand Down
4 changes: 0 additions & 4 deletions x/wasm/alias.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// nolint
// autogenerated code using github.com/rigelrozanski/multitool
// aliases generated for the following subdirectories:
// ALIASGEN: github.com/cosmwasm/wasmd/x/wasm/internal/types
// ALIASGEN: github.com/cosmwasm/wasmd/x/wasm/internal/keeper
package wasm

import (
Expand Down
4 changes: 2 additions & 2 deletions x/wasm/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestInitGenesis(t *testing.T) {
msg := MsgStoreCode{
Sender: creator.String(),
WASMByteCode: testContract,
Source: "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/hackatom.wasm",
Source: "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm",
Builder: "confio/cosmwasm-opt:0.7.0",
}
err := msg.ValidateBasic()
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestInitGenesis(t *testing.T) {
}
res, err = h(data.ctx, &execCmd)
require.NoError(t, err)
// from https://github.com/CosmWasm/cosmwasm/blob/master/contracts/hackatom/src/contract.rs#L167
// executing https://github.com/line/cosmwasm/blob/main/contracts/hackatom/src/contract.rs do_release
assertExecuteResponse(t, res.Data, []byte{0xf0, 0x0b, 0xaa})

// ensure all contract state is as after init
Expand Down
4 changes: 2 additions & 2 deletions x/wasm/internal/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ func setupKeeper(t *testing.T) (*Keeper, sdk.Context, []sdk.StoreKey) {
require.NoError(t, err)
t.Cleanup(func() { os.RemoveAll(tempDir) })
var (
keyParams = sdk.NewKVStoreKey(paramtypes.StoreKey)
keyWasm = sdk.NewKVStoreKey(wasmTypes.StoreKey)
keyParams = sdk.NewKVStoreKey(paramtypes.StoreKey)
keyWasm = sdk.NewKVStoreKey(wasmTypes.StoreKey)
)

db := memdb.NewDB()
Expand Down
8 changes: 4 additions & 4 deletions x/wasm/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import (
wasmvmtypes "github.com/line/wasmvm/types"
)

// MaxGas for a contract is 10 billion wasmer gas (enforced in rust to prevent overflow)
// The limit for v0.9.3 is defined here: https://github.com/CosmWasm/cosmwasm/blob/v0.9.3/packages/vm/src/backends/singlepass.rs#L15-L23
// (this will be increased in future releases)
// MaxGas was restriction is increased to 0x7FFFFFFFFFFFFFFF in CosmWasm 0.10.
// This const is not needed now and we can manage it in another way.
const MaxGas = 10_000_000_000

// contractMemoryLimit is the memory limit of each contract execution (in MiB)
Expand Down Expand Up @@ -1079,7 +1078,8 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
}

// CoinTransferrer replicates the cosmos-sdk behaviour as in
// https://github.com/cosmos/cosmos-sdk/blob/v0.41.4/x/bank/keeper/msg_server.go#L26
// lfb-sdk's x/bank/keeper/msg_server.go Send
// (https://github.com/line/lfb-sdk/blob/2a5a2d2c885b03e278bcd67546d4f21e74614ead/x/bank/keeper/msg_server.go#L26)
type CoinTransferrer struct {
keeper types.BankKeeper
}
Expand Down
24 changes: 12 additions & 12 deletions x/wasm/internal/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestCreate(t *testing.T) {
wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm")
require.NoError(t, err)

contractID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/escrow.wasm", "any/builder:tag", nil)
contractID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm", "any/builder:tag", nil)
require.NoError(t, err)
require.Equal(t, uint64(1), contractID)
// and verify content
Expand Down Expand Up @@ -92,7 +92,7 @@ func TestCreateStoresInstantiatePermission(t *testing.T) {
})
fundAccounts(t, ctx, accKeeper, bankKeeper, myAddr, deposit)

codeID, err := keeper.Create(ctx, myAddr, wasmCode, "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/escrow.wasm", "any/builder:tag", nil)
codeID, err := keeper.Create(ctx, myAddr, wasmCode, "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm", "any/builder:tag", nil)
require.NoError(t, err)

codeInfo := keeper.GetCodeInfo(ctx, codeID)
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestCreateWithParamPermissions(t *testing.T) {
params := types.DefaultParams()
params.CodeUploadAccess = spec.srcPermission
keeper.setParams(ctx, params)
_, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/escrow.wasm", "any/builder:tag", nil)
_, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm", "any/builder:tag", nil)
require.True(t, spec.expError.Is(err), err)
if spec.expError != nil {
return
Expand All @@ -160,12 +160,12 @@ func TestCreateDuplicate(t *testing.T) {
require.NoError(t, err)

// create one copy
contractID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/escrow.wasm", "any/builder:tag", nil)
contractID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm", "any/builder:tag", nil)
require.NoError(t, err)
require.Equal(t, uint64(1), contractID)

// create second copy
duplicateID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/escrow.wasm", "any/builder:tag", nil)
duplicateID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm", "any/builder:tag", nil)
require.NoError(t, err)
require.Equal(t, uint64(2), duplicateID)

Expand All @@ -192,14 +192,14 @@ func TestCreateWithSimulation(t *testing.T) {
require.NoError(t, err)

// create this once in simulation mode
contractID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/escrow.wasm", "any/builder:tag", nil)
contractID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm", "any/builder:tag", nil)
require.NoError(t, err)
require.Equal(t, uint64(1), contractID)

// then try to create it in non-simulation mode (should not fail)
ctx, keepers = CreateTestInput(t, false, SupportedFeatures, nil, nil)
accKeeper, keeper = keepers.AccountKeeper, keepers.WasmKeeper
contractID, err = keeper.Create(ctx, creator, wasmCode, "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/escrow.wasm", "any/builder:tag", nil)
contractID, err = keeper.Create(ctx, creator, wasmCode, "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm", "any/builder:tag", nil)
require.NoError(t, err)
require.Equal(t, uint64(1), contractID)

Expand Down Expand Up @@ -244,7 +244,7 @@ func TestCreateWithGzippedPayload(t *testing.T) {
wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm.gzip")
require.NoError(t, err)

contractID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/escrow.wasm", "", nil)
contractID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm", "", nil)
require.NoError(t, err)
require.Equal(t, uint64(1), contractID)
// and verify content
Expand All @@ -265,7 +265,7 @@ func TestInstantiate(t *testing.T) {
wasmCode, err := ioutil.ReadFile("./testdata/hackatom.wasm")
require.NoError(t, err)

codeID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/escrow.wasm", "", nil)
codeID, err := keeper.Create(ctx, creator, wasmCode, "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm", "", nil)
require.NoError(t, err)

_, _, bob := keyPubAddr()
Expand All @@ -287,7 +287,7 @@ func TestInstantiate(t *testing.T) {

gasAfter := ctx.GasMeter().GasConsumed()
if types.EnableGasVerification {
require.Equal(t, uint64(0x11b90), gasAfter-gasBefore)
require.Equal(t, uint64(0x11bba), gasAfter-gasBefore)
}

// ensure it is stored properly
Expand Down Expand Up @@ -349,7 +349,7 @@ func TestInstantiateWithDeposit(t *testing.T) {
if spec.fundAddr {
fundAccounts(t, ctx, accKeeper, bankKeeper, spec.srcActor, sdk.NewCoins(sdk.NewInt64Coin("denom", 200)))
}
contractID, err := keeper.Create(ctx, spec.srcActor, wasmCode, "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/escrow.wasm", "", nil)
contractID, err := keeper.Create(ctx, spec.srcActor, wasmCode, "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm", "", nil)
require.NoError(t, err)

// when
Expand Down Expand Up @@ -417,7 +417,7 @@ func TestInstantiateWithPermissions(t *testing.T) {
accKeeper, bankKeeper, keeper := keepers.AccountKeeper, keepers.BankKeeper, keepers.WasmKeeper
fundAccounts(t, ctx, accKeeper, bankKeeper, spec.srcActor, deposit)

contractID, err := keeper.Create(ctx, myAddr, wasmCode, "https://github.com/CosmWasm/wasmd/blob/master/x/wasm/testdata/escrow.wasm", "", &spec.srcPermission)
contractID, err := keeper.Create(ctx, myAddr, wasmCode, "https://github.com/line/lfb-sdk/blob/main/x/wasm/internal/keeper/testdata/hackatom.wasm", "", &spec.srcPermission)
require.NoError(t, err)

_, _, err = keeper.Instantiate(ctx, contractID, spec.srcActor, nil, initMsgBz, "demo contract 1", nil)
Expand Down
5 changes: 3 additions & 2 deletions x/wasm/internal/keeper/query_plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ func sdkToDelegations(ctx sdk.Context, keeper types.StakingKeeper, delegations [
}

// shares to amount logic comes from here:
// https://github.com/cosmos/cosmos-sdk/blob/v0.38.3/x/staking/keeper/querier.go#L404
// x/staking/keeper/querier.go DelegationToDelegationResponse
/// https://github.com/line/lfb-sdk/blob/3ccf3913f53e2a9ccb4be8429bee32e67669e89a/x/staking/keeper/querier.go#L450
val, found := keeper.GetValidator(ctx, valAddr)
if !found {
return nil, sdkerrors.Wrap(stakingtypes.ErrNoValidatorFound, "can't load validator for delegation")
Expand Down Expand Up @@ -387,7 +388,7 @@ func sdkToFullDelegation(ctx sdk.Context, keeper types.StakingKeeper, distKeeper
delegationCoins := convertSdkCoinToWasmCoin(amount)

// FIXME: this is very rough but better than nothing...
// https://github.com/CosmWasm/wasmd/issues/282
// https://github.com/line/lfb-sdk/issues/225
// if this (val, delegate) pair is receiving a redelegation, it cannot redelegate more
// otherwise, it can redelegate the full amount
// (there are cases of partial funds redelegated, but this is a start)
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/internal/keeper/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func createTestInput(
distKeeper.SetFeePool(ctx, distributiontypes.InitialFeePool())

// set some funds ot pay out validatores, based on code from:
// https://github.com/cosmos/cosmos-sdk/blob/fea231556aee4d549d7551a6190389c4328194eb/x/distribution/keeper/keeper_test.go#L50-L57
// https://github.com/line/lfb-sdk/blob/95b22d3a685f7eb531198e0023ef06873835e632/x/distribution/keeper/keeper_test.go#L49-L56
distrAcc := distKeeper.GetDistributionAccount(ctx)
err := bankKeeper.SetBalances(ctx, distrAcc.GetAddress(), sdk.NewCoins(
sdk.NewCoin("stake", sdk.NewInt(2000000)),
Expand Down
3 changes: 2 additions & 1 deletion x/wasm/internal/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const (
// DefaultMaxWasmCodeSize limit max bytes read to prevent gzip bombs
DefaultMaxWasmCodeSize = 600 * 1024
// GasMultiplier is how many cosmwasm gas points = 1 sdk gas point
// SDK reference costs can be found here: https://github.com/cosmos/cosmos-sdk/blob/02c6c9fafd58da88550ab4d7d494724a477c8a68/store/types/gas.go#L153-L164
// SDK reference costs is defined in x/store/types/gas.go KVGasConfig()
// https://github.com/line/lfb-sdk/blob/main/store/types/gas.go
// A write at ~3000 gas and ~200us = 10 gas per us (microsecond) cpu/io
// Rough timing have 88k gas at 90us, which is equal to 1k sdk gas... (one read)
//
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/linkwasmd/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ var (
ProposalsEnabled = "false"
// If set to non-empty string it must be comma-separated list of values that are all a subset
// of "EnableAllProposals" (takes precedence over ProposalsEnabled)
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
// "EnableAllProposals" is defined in internal/types/proposal.go
EnableSpecificProposals = ""
)

Expand Down
2 changes: 1 addition & 1 deletion x/wasm/linkwasmd/app/params/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Package params defines the simulation parameters in the gaia.
Package params defines the simulation parameters in the lfb.
It contains the default weights used for each transaction used on the module's
simulation. These weights define the chance for a transaction to be simulated at
any gived operation.
Expand Down
4 changes: 2 additions & 2 deletions x/wasm/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func TestHandleExecute(t *testing.T) {
}
res, err = h(data.ctx, &execCmd)
require.NoError(t, err)
// from https://github.com/CosmWasm/cosmwasm/blob/master/contracts/hackatom/src/contract.rs#L167
// executing https://github.com/line/cosmwasm/blob/main/contracts/hackatom/src/contract.rs do_release
assertExecuteResponse(t, res.Data, []byte{0xf0, 0x0b, 0xaa})

// this should be standard x/wasm init event, plus 2 bank send event, plus a special event from the contract
Expand Down Expand Up @@ -544,7 +544,7 @@ func TestHandleExecuteEscrow(t *testing.T) {
}
res, err = h(data.ctx, &execCmd)
require.NoError(t, err)
// from https://github.com/CosmWasm/cosmwasm/blob/master/contracts/hackatom/src/contract.rs#L167
// executing https://github.com/line/cosmwasm/blob/main/contracts/hackatom/src/contract.rs do_release
assertExecuteResponse(t, res.Data, []byte{0xf0, 0x0b, 0xaa})

// ensure bob now exists and got both payments released
Expand Down