diff --git a/.gitignore b/.gitignore index 6bda0f322e..4133f1bf93 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,8 @@ nitro-replayer/target nitro-replayer/Cargo.lock # nitro mac artifact x/nitro/replay/libnitro_replayer.dylib + +# parallelization test build artifact +parallelization/**/artifacts/ +parallelization/**/target/ +parallelization/**/Cargo.lock \ No newline at end of file diff --git a/aclmapping/bank/mappings.go b/aclmapping/bank/mappings.go index 283099197b..047c9092a1 100644 --- a/aclmapping/bank/mappings.go +++ b/aclmapping/bank/mappings.go @@ -81,6 +81,12 @@ func MsgSendDependencyGenerator(keeper aclkeeper.Keeper, ctx sdk.Context, msg sd IdentifierTemplate: hex.EncodeToString(authtypes.CreateAddressStoreKeyFromBech32(msgSend.FromAddress)), }, + { + AccessType: sdkacltypes.AccessType_READ, + ResourceType: sdkacltypes.ResourceType_KV_AUTH_GLOBAL_ACCOUNT_NUMBER, + IdentifierTemplate: hex.EncodeToString(authtypes.GlobalAccountNumberKey), + }, + { ResourceType: sdkacltypes.ResourceType_ANY, AccessType: sdkacltypes.AccessType_COMMIT, @@ -88,5 +94,29 @@ func MsgSendDependencyGenerator(keeper aclkeeper.Keeper, ctx sdk.Context, msg sd }, } + // check if the account exists and add additional write dependency if it doesn't + toAddr, err := sdk.AccAddressFromBech32(msgSend.ToAddress) + if err != nil { + // let msg server handle it + accessOperations = append(accessOperations, sdkacltypes.AccessOperation{ + ResourceType: sdkacltypes.ResourceType_ANY, + AccessType: sdkacltypes.AccessType_COMMIT, + IdentifierTemplate: utils.DefaultIDTemplate, + }) + return accessOperations, nil + } + if !keeper.AccountKeeper.HasAccount(ctx, toAddr) { + accessOperations = append(accessOperations, sdkacltypes.AccessOperation{ + AccessType: sdkacltypes.AccessType_WRITE, + ResourceType: sdkacltypes.ResourceType_KV_AUTH_GLOBAL_ACCOUNT_NUMBER, + IdentifierTemplate: hex.EncodeToString(authtypes.GlobalAccountNumberKey), + }) + } + accessOperations = append(accessOperations, sdkacltypes.AccessOperation{ + ResourceType: sdkacltypes.ResourceType_ANY, + AccessType: sdkacltypes.AccessType_COMMIT, + IdentifierTemplate: utils.DefaultIDTemplate, + }) + return accessOperations, nil } diff --git a/aclmapping/dex/mappings.go b/aclmapping/dex/mappings.go index 3f5085d90e..0098d4009c 100644 --- a/aclmapping/dex/mappings.go +++ b/aclmapping/dex/mappings.go @@ -25,25 +25,6 @@ func GetDexDependencyGenerators() aclkeeper.DependencyGeneratorMap { return dependencyGeneratorMap } -func GetDexMemReadWrite(contract string) []sdkacltypes.AccessOperation { - if contract == "" { - return []sdkacltypes.AccessOperation{} - } - - return []sdkacltypes.AccessOperation{ - { - AccessType: sdkacltypes.AccessType_READ, - ResourceType: sdkacltypes.ResourceType_DexMem, - IdentifierTemplate: hex.EncodeToString([]byte(contract)), - }, - { - AccessType: sdkacltypes.AccessType_WRITE, - ResourceType: sdkacltypes.ResourceType_DexMem, - IdentifierTemplate: hex.EncodeToString([]byte(contract)), - }, - } -} - func GetLongShortOrderBookOps(contractAddr string, priceDenom string, assetDenom string) []sdkacltypes.AccessOperation { return []sdkacltypes.AccessOperation{ { @@ -68,9 +49,7 @@ func DexPlaceOrdersDependencyGenerator(keeper aclkeeper.Keeper, ctx sdk.Context, contractAddr := placeOrdersMsg.ContractAddr - aclOps := GetDexMemReadWrite(contractAddr) - - aclOps = append(aclOps, []sdkacltypes.AccessOperation{ + aclOps := []sdkacltypes.AccessOperation{ { AccessType: sdkacltypes.AccessType_READ, ResourceType: sdkacltypes.ResourceType_KV_DEX_NEXT_ORDER_ID, @@ -86,7 +65,33 @@ func DexPlaceOrdersDependencyGenerator(keeper aclkeeper.Keeper, ctx sdk.Context, ResourceType: sdkacltypes.ResourceType_KV_DEX_REGISTERED_PAIR, IdentifierTemplate: hex.EncodeToString(dextypes.RegisteredPairPrefix(contractAddr)), }, - }...) + { + AccessType: sdkacltypes.AccessType_READ, + ResourceType: sdkacltypes.ResourceType_KV_DEX_MEM_DEPOSIT, + IdentifierTemplate: hex.EncodeToString(append( + dextypes.MemDepositPrefix(contractAddr), + []byte(placeOrdersMsg.Creator)..., + )), + }, + { + AccessType: sdkacltypes.AccessType_WRITE, + ResourceType: sdkacltypes.ResourceType_KV_DEX_MEM_DEPOSIT, + IdentifierTemplate: hex.EncodeToString(append( + dextypes.MemDepositPrefix(contractAddr), + []byte(placeOrdersMsg.Creator)..., + )), + }, + { + AccessType: sdkacltypes.AccessType_READ, + ResourceType: sdkacltypes.ResourceType_KV_DEX_MEM_ORDER, + IdentifierTemplate: hex.EncodeToString(dextypes.MemOrderPrefix(contractAddr)), + }, + { + AccessType: sdkacltypes.AccessType_WRITE, + ResourceType: sdkacltypes.ResourceType_KV_DEX_MEM_ORDER, + IdentifierTemplate: hex.EncodeToString(dextypes.MemOrderPrefix(contractAddr)), + }, + } // Last Operation should always be a commit aclOps = append(aclOps, *acltypes.CommitAccessOp()) @@ -100,7 +105,18 @@ func DexCancelOrdersDependencyGenerator(keeper aclkeeper.Keeper, ctx sdk.Context } contractAddr := cancelOrdersMsg.ContractAddr - aclOps := GetDexMemReadWrite(contractAddr) + aclOps := []sdkacltypes.AccessOperation{ + { + AccessType: sdkacltypes.AccessType_READ, + ResourceType: sdkacltypes.ResourceType_KV_DEX_MEM_CANCEL, + IdentifierTemplate: hex.EncodeToString(dextypes.MemCancelPrefix(contractAddr)), + }, + { + AccessType: sdkacltypes.AccessType_WRITE, + ResourceType: sdkacltypes.ResourceType_KV_DEX_MEM_CANCEL, + IdentifierTemplate: hex.EncodeToString(dextypes.MemCancelPrefix(contractAddr)), + }, + } for _, order := range cancelOrdersMsg.GetCancellations() { priceDenom := order.GetPriceDenom() diff --git a/aclmapping/utils/resource_type.go b/aclmapping/utils/resource_type.go index 6d13a3e628..4bfeffa279 100644 --- a/aclmapping/utils/resource_type.go +++ b/aclmapping/utils/resource_type.go @@ -5,8 +5,11 @@ import ( aclsdktypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" acltypes "github.com/cosmos/cosmos-sdk/x/accesscontrol/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + authztypes "github.com/cosmos/cosmos-sdk/x/authz/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" dextypes "github.com/sei-protocol/sei-chain/x/dex/types" epochtypes "github.com/sei-protocol/sei-chain/x/epoch/types" @@ -46,6 +49,10 @@ var StoreKeyToResourceTypePrefixMap = aclsdktypes.StoreKeyToResourceTypePrefixMa // SETTLEMENT keys are prefixed with account and order id aclsdktypes.ResourceType_KV_DEX_SETTLEMENT_ORDER_ID: aclsdktypes.EmptyPrefix, aclsdktypes.ResourceType_KV_DEX_SETTLEMENT: aclsdktypes.EmptyPrefix, + // mem + aclsdktypes.ResourceType_KV_DEX_MEM_ORDER: dextypes.KeyPrefix(dextypes.MemOrderKey), + aclsdktypes.ResourceType_KV_DEX_MEM_CANCEL: dextypes.KeyPrefix(dextypes.MemCancelKey), + aclsdktypes.ResourceType_KV_DEX_MEM_DEPOSIT: dextypes.KeyPrefix(dextypes.MemDepositKey), }, banktypes.StoreKey: { aclsdktypes.ResourceType_KV_BANK: aclsdktypes.EmptyPrefix, @@ -58,6 +65,9 @@ var StoreKeyToResourceTypePrefixMap = aclsdktypes.StoreKeyToResourceTypePrefixMa aclsdktypes.ResourceType_KV_AUTH_ADDRESS_STORE: authtypes.AddressStoreKeyPrefix, aclsdktypes.ResourceType_KV_AUTH_GLOBAL_ACCOUNT_NUMBER: authtypes.GlobalAccountNumberKey, }, + authztypes.StoreKey: { + aclsdktypes.ResourceType_KV_AUTHZ: aclsdktypes.EmptyPrefix, + }, distributiontypes.StoreKey: { aclsdktypes.ResourceType_KV_DISTRIBUTION: aclsdktypes.EmptyPrefix, aclsdktypes.ResourceType_KV_DISTRIBUTION_FEE_POOL: distributiontypes.FeePoolKey, @@ -70,6 +80,10 @@ var StoreKeyToResourceTypePrefixMap = aclsdktypes.StoreKeyToResourceTypePrefixMa aclsdktypes.ResourceType_KV_DISTRIBUTION_VAL_ACCUM_COMMISSION: distributiontypes.ValidatorAccumulatedCommissionPrefix, aclsdktypes.ResourceType_KV_DISTRIBUTION_SLASH_EVENT: distributiontypes.ValidatorSlashEventPrefix, }, + feegranttypes.StoreKey: { + aclsdktypes.ResourceType_KV_FEEGRANT: aclsdktypes.EmptyPrefix, + aclsdktypes.ResourceType_KV_FEEGRANT_ALLOWANCE: feegranttypes.FeeAllowanceKeyPrefix, + }, oracletypes.StoreKey: { aclsdktypes.ResourceType_KV_ORACLE: aclsdktypes.EmptyPrefix, aclsdktypes.ResourceType_KV_ORACLE_VOTE_TARGETS: oracletypes.VoteTargetKey, @@ -97,6 +111,11 @@ var StoreKeyToResourceTypePrefixMap = aclsdktypes.StoreKeyToResourceTypePrefixMa aclsdktypes.ResourceType_KV_STAKING_VALIDATOR_QUEUE: stakingtypes.ValidatorQueueKey, aclsdktypes.ResourceType_KV_STAKING_HISTORICAL_INFO: stakingtypes.HistoricalInfoKey, }, + slashingtypes.StoreKey: { + aclsdktypes.ResourceType_KV_SLASHING: aclsdktypes.EmptyPrefix, + aclsdktypes.ResourceType_KV_SLASHING_VAL_SIGNING_INFO: slashingtypes.ValidatorSigningInfoKeyPrefix, + aclsdktypes.ResourceType_KV_SLASHING_ADDR_PUBKEY_RELATION_KEY: slashingtypes.AddrPubkeyRelationKeyPrefix, + }, tokenfactorytypes.StoreKey: { aclsdktypes.ResourceType_KV_TOKENFACTORY: aclsdktypes.EmptyPrefix, aclsdktypes.ResourceType_KV_TOKENFACTORY_DENOM: []byte(tokenfactorytypes.DenomsPrefixKey), diff --git a/go.mod b/go.mod index ef0355fc6a..1f0c33b8ad 100644 --- a/go.mod +++ b/go.mod @@ -267,7 +267,7 @@ require ( replace ( github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.1.376 + github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.1.377 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.1.132 diff --git a/go.sum b/go.sum index 2cf55d4f4b..a097393d22 100644 --- a/go.sum +++ b/go.sum @@ -1067,8 +1067,8 @@ github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod github.com/securego/gosec/v2 v2.11.0 h1:+PDkpzR41OI2jrw1q6AdXZCbsNGNGT7pQjal0H0cArI= github.com/securego/gosec/v2 v2.11.0/go.mod h1:SX8bptShuG8reGC0XS09+a4H2BoWSJi+fscA+Pulbpo= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= -github.com/sei-protocol/sei-cosmos v0.1.376 h1:94X4TWRK+wfq0BK7JRj+cu0Vx903EDiKBJVEG5NaIek= -github.com/sei-protocol/sei-cosmos v0.1.376/go.mod h1:lX+jDZ9u+afukL4Gc76YtKFEeCe9HfrAOCYAzSevAPw= +github.com/sei-protocol/sei-cosmos v0.1.377 h1:WGLoFwgvUOf30URiOTibeOBNwUvr0NkxezaP3nmPckg= +github.com/sei-protocol/sei-cosmos v0.1.377/go.mod h1:lX+jDZ9u+afukL4Gc76YtKFEeCe9HfrAOCYAzSevAPw= github.com/sei-protocol/sei-tendermint v0.1.132 h1:bGzvArngcXgZ0PZSif2Qqp7p/YLd+fBxsYnH6Lqc0E4= github.com/sei-protocol/sei-tendermint v0.1.132/go.mod h1:ubqjn2T/nvqmQYjgpOTV7uSyUvdfvJCepc7zNYL2mkw= github.com/sei-protocol/sei-tm-db v0.0.5 h1:3WONKdSXEqdZZeLuWYfK5hP37TJpfaUa13vAyAlvaQY= diff --git a/parallelization/bank/Cargo.toml b/parallelization/bank/Cargo.toml new file mode 100644 index 0000000000..04f381d71e --- /dev/null +++ b/parallelization/bank/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "bank" +version = "0.1.0" +edition = "2018" + +[lib] +crate-type = ["cdylib", "rlib"] +doctest = false + +[dependencies] +cosmwasm-std = { version = "1.0.0" } +cosmwasm-storage = { version = "1.0.0" } +cw-storage-plus = "0.13.2" +serde-json-wasm = "0.4.1" +cw2 = "0.13.2" +cw20 = "0.13.2" +schemars = "0.8.3" +serde = { version = "1.0.127", default-features = false, features = ["derive"] } +serde_json = { version = "1.0", default-features = false, features = ["alloc"] } +thiserror = { version = "1.0.26" } +base64 = { version = "0.13.0" } + +[dependencies.forward_ref] +version = "1" + +[dev-dependencies] +cosmwasm-schema = { version = "1.0.0" } diff --git a/parallelization/bank/deps.json b/parallelization/bank/deps.json new file mode 100644 index 0000000000..29478d971b --- /dev/null +++ b/parallelization/bank/deps.json @@ -0,0 +1,26 @@ +{ + "wasm_dependency_mapping": + { + "enabled": true, + "contract_address": "sei14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sh9m79m", + "access_ops": [ + { + "operation": { + "access_type": "WRITE", + "resource_type": "KV_BANK_BALANCES", + "identifier_template": "02%s" + }, + "selector_type": "JQ_LENGTH_PREFIXED_ADDRESS", + "selector": ".send.destination" + }, + { + "operation": { + "access_type": "COMMIT", + "resource_type": "ANY", + "identifier_template": "*" + }, + "selector_type": "NONE" + } + ] + } +} diff --git a/parallelization/bank/src/contract.rs b/parallelization/bank/src/contract.rs new file mode 100644 index 0000000000..6444396355 --- /dev/null +++ b/parallelization/bank/src/contract.rs @@ -0,0 +1,32 @@ +use cosmwasm_std::{ + entry_point, BankMsg, DepsMut, Env, MessageInfo, + Response, StdError, +}; +use crate::msg::{InstantiateMsg, ExecuteMsg}; + +#[entry_point] +pub fn instantiate( + _: DepsMut, + _env: Env, + _: MessageInfo, + _: InstantiateMsg, +) -> Result { + Ok(Response::default()) +} + +#[entry_point] +pub fn execute( + _: DepsMut, + _: Env, + info: MessageInfo, + msg: ExecuteMsg, +) -> Result { + match msg { + ExecuteMsg::Send { destination } => send(info, destination), + } +} + +fn send(info: MessageInfo, destination: String) -> Result { + let msg = BankMsg::Send { to_address: destination, amount: info.funds }; + Ok(Response::new().add_message(msg)) +} \ No newline at end of file diff --git a/parallelization/bank/src/lib.rs b/parallelization/bank/src/lib.rs new file mode 100644 index 0000000000..112ecadc84 --- /dev/null +++ b/parallelization/bank/src/lib.rs @@ -0,0 +1,2 @@ +pub mod contract; +pub mod msg; diff --git a/parallelization/bank/src/msg.rs b/parallelization/bank/src/msg.rs new file mode 100644 index 0000000000..a5c9cc3eb6 --- /dev/null +++ b/parallelization/bank/src/msg.rs @@ -0,0 +1,13 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, JsonSchema)] +pub struct InstantiateMsg {} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum ExecuteMsg { + Send { + destination: String, + }, +} \ No newline at end of file diff --git a/parallelization/staking/Cargo.toml b/parallelization/staking/Cargo.toml new file mode 100644 index 0000000000..d4c9d58edd --- /dev/null +++ b/parallelization/staking/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "staking" +version = "0.1.0" +edition = "2018" + +[lib] +crate-type = ["cdylib", "rlib"] +doctest = false + +[dependencies] +cosmwasm-std = { version = "1.0.0", features = ["staking"] } +cosmwasm-storage = { version = "1.0.0" } +cw-storage-plus = "0.13.2" +serde-json-wasm = "0.4.1" +cw2 = "0.13.2" +cw20 = "0.13.2" +schemars = "0.8.3" +serde = { version = "1.0.127", default-features = false, features = ["derive"] } +serde_json = { version = "1.0", default-features = false, features = ["alloc"] } +thiserror = { version = "1.0.26" } +base64 = { version = "0.13.0" } + +[dependencies.forward_ref] +version = "1" + +[dev-dependencies] +cosmwasm-schema = { version = "1.0.0" } diff --git a/parallelization/staking/src/contract.rs b/parallelization/staking/src/contract.rs new file mode 100644 index 0000000000..c24898bcf4 --- /dev/null +++ b/parallelization/staking/src/contract.rs @@ -0,0 +1,32 @@ +use cosmwasm_std::{ + entry_point, StakingMsg, DepsMut, Env, MessageInfo, + Response, StdError, +}; +use crate::msg::{InstantiateMsg, ExecuteMsg}; + +#[entry_point] +pub fn instantiate( + _: DepsMut, + _env: Env, + _: MessageInfo, + _: InstantiateMsg, +) -> Result { + Ok(Response::default()) +} + +#[entry_point] +pub fn execute( + _: DepsMut, + _: Env, + info: MessageInfo, + msg: ExecuteMsg, +) -> Result { + match msg { + ExecuteMsg::Delegate { validator } => delegate(info, validator), + } +} + +fn delegate(info: MessageInfo, validator: String) -> Result { + let msg = StakingMsg::Delegate { validator: validator, amount: info.funds[0].clone() }; + Ok(Response::new().add_message(msg)) +} \ No newline at end of file diff --git a/parallelization/staking/src/lib.rs b/parallelization/staking/src/lib.rs new file mode 100644 index 0000000000..112ecadc84 --- /dev/null +++ b/parallelization/staking/src/lib.rs @@ -0,0 +1,2 @@ +pub mod contract; +pub mod msg; diff --git a/parallelization/staking/src/msg.rs b/parallelization/staking/src/msg.rs new file mode 100644 index 0000000000..bd53843327 --- /dev/null +++ b/parallelization/staking/src/msg.rs @@ -0,0 +1,13 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, JsonSchema)] +pub struct InstantiateMsg {} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum ExecuteMsg { + Delegate { + validator: String, + }, +} \ No newline at end of file diff --git a/parallelization/wasm/Cargo.toml b/parallelization/wasm/Cargo.toml new file mode 100644 index 0000000000..0446a2023c --- /dev/null +++ b/parallelization/wasm/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "wasm" +version = "0.1.0" +edition = "2018" + +[lib] +crate-type = ["cdylib", "rlib"] +doctest = false + +[dependencies] +cosmwasm-std = { version = "1.0.0" } +cosmwasm-storage = { version = "1.0.0" } +cw-storage-plus = "0.13.2" +serde-json-wasm = "0.4.1" +cw2 = "0.13.2" +cw20 = "0.13.2" +schemars = "0.8.3" +serde = { version = "1.0.127", default-features = false, features = ["derive"] } +serde_json = { version = "1.0", default-features = false, features = ["alloc"] } +thiserror = { version = "1.0.26" } +base64 = { version = "0.13.0" } + +[dependencies.forward_ref] +version = "1" + +[dev-dependencies] +cosmwasm-schema = { version = "1.0.0" } diff --git a/parallelization/wasm/src/contract.rs b/parallelization/wasm/src/contract.rs new file mode 100644 index 0000000000..349e4fa95b --- /dev/null +++ b/parallelization/wasm/src/contract.rs @@ -0,0 +1,39 @@ +use cosmwasm_std::{ + entry_point, WasmMsg, DepsMut, Env, MessageInfo, + Response, StdError, to_binary, +}; +use crate::msg::{InstantiateMsg, ExecuteMsg, BankExecuteMsg}; + +#[entry_point] +pub fn instantiate( + _: DepsMut, + _env: Env, + _: MessageInfo, + _: InstantiateMsg, +) -> Result { + Ok(Response::default()) +} + +#[entry_point] +pub fn execute( + _: DepsMut, + _: Env, + info: MessageInfo, + msg: ExecuteMsg, +) -> Result { + match msg { + ExecuteMsg::Send { bank_address, destination } => send(info, bank_address, destination), + } +} + +fn send(info: MessageInfo, bank_address: String, destination: String) -> Result { + let bank_msg = BankExecuteMsg::Send { + destination: destination, + }; + let msg = WasmMsg::Execute { + contract_addr: bank_address, + msg: to_binary(&bank_msg).unwrap(), + funds: info.funds, + }; + Ok(Response::new().add_message(msg)) +} \ No newline at end of file diff --git a/parallelization/wasm/src/lib.rs b/parallelization/wasm/src/lib.rs new file mode 100644 index 0000000000..112ecadc84 --- /dev/null +++ b/parallelization/wasm/src/lib.rs @@ -0,0 +1,2 @@ +pub mod contract; +pub mod msg; diff --git a/parallelization/wasm/src/msg.rs b/parallelization/wasm/src/msg.rs new file mode 100644 index 0000000000..134ba4d2eb --- /dev/null +++ b/parallelization/wasm/src/msg.rs @@ -0,0 +1,22 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, JsonSchema)] +pub struct InstantiateMsg {} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum ExecuteMsg { + Send { + bank_address: String, + destination: String, + }, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum BankExecuteMsg { + Send { + destination: String, + }, +} \ No newline at end of file diff --git a/x/dex/cache/deposit.go b/x/dex/cache/deposit.go index 874f88da00..0c5f5c4878 100644 --- a/x/dex/cache/deposit.go +++ b/x/dex/cache/deposit.go @@ -31,7 +31,7 @@ func (d *DepositInfo) Get() (list []*types.DepositInfoEntry) { } func (d *DepositInfo) Add(newItem *types.DepositInfoEntry) { - key := append([]byte(newItem.Creator), []byte(newItem.Denom)...) + key := types.MemDepositSubprefix(newItem.Creator, newItem.Denom) if val, err := newItem.Marshal(); err != nil { panic(err) } else if existing := d.store.Get(key); existing == nil { diff --git a/x/dex/types/keys.go b/x/dex/types/keys.go index 51b7c40328..be0ac62f0e 100644 --- a/x/dex/types/keys.go +++ b/x/dex/types/keys.go @@ -147,10 +147,18 @@ func MemOrderPrefix(contractAddr string) []byte { return append(KeyPrefix(MemOrderKey), KeyPrefix(contractAddr)...) } +func MemCancelPrefix(contractAddr string) []byte { + return append(KeyPrefix(MemCancelKey), KeyPrefix(contractAddr)...) +} + func MemDepositPrefix(contractAddr string) []byte { return append(KeyPrefix(MemDepositKey), KeyPrefix(contractAddr)...) } +func MemDepositSubprefix(creator, denom string) []byte { + return append([]byte(creator), []byte(denom)...) +} + const ( DefaultPriceDenom = "usei" DefaultAssetDenom = "dummy"