osmosis-labs / beaker Goto Github PK
View Code? Open in Web Editor NEWBeaker helps streamlining CosmWasm development workflow.
License: Apache License 2.0
Beaker helps streamlining CosmWasm development workflow.
License: Apache License 2.0
Currently, beaker only has the basic counter example. I believe there is a need to expand scaffolded-dApp variety to encourage more builders to build via a bit more structure. These additional examples can help demonstrate tooling (such as various requests for custom cosmwasm bindings) that you can integrate with beaker.
Current list
For the signer-account
option I think having a few predefined ones works well for localosmosis but for testnet/mainnet it would be best to use:
https://docs.cosmos.network/master/run-node/keyring.html
I guess we could call them:
system-signer-account
&& beaker-signer-account
?
This way we can allow people to request testnet tokens via the faucet for their own addresses, and eventually add an option to the faucet to approve contracts as well as we discussed yesterday.
README.md
refer to the docsThis issue is for tracking the clarification of the path to production (mainnet) for CosmWasm. Since Osmosis implements permissioned CosmWasm, See what are the steps to take, who is involved in order to have clear understanding on what Beaker should support, who else needs to be involved, what system needs to eventually be upgraded and later we can have a clear documentation for the dapps developer.
The following is my attempt to flesh out the understandings along with β questions and π‘ ideas.
According to the wasm gov docs, there are additional proposal types for wasm gov. Grouping by their functions for further reference:
Deployment and Migration (**main focus for this issue)
StoreCodeProposal
InstantiateContractProposal
MigrateContractProposal
Code Permission
UpdateAdminProposal
ClearAdminProposal
UpdateInstantiateConfigProposal
Code Pinning
PinCodes
UnpinCodes
Execution
SudoContractProposal
ExecuteContractProposal
[β 1] on mainnet, which of the above are required to be execute through governance?
π Answer 1 by @czarcas7ic
[π‘ 1] Same wasm gov configuration as mainnet for testnet (stagenet?) and/or localosmosis variation would be ideal for testing. @czarcas7ic @nicolaslara
For Code Pinning and Execution, if the [β 1] is clear, it doesn't seem to be important for this issue. Let's move on to the main topic.
There was a discussion with @ValarDragon @daniel-farina about hash verification and contract-list
This is what I imagine would happen if there is a need to store code:
graph TD
StoreCode[Submit `StoreCodeProposal`]
SubmitRepo[Submit source and metadata]
Val{validate}
Voting[Gov Voting]
StoreCode == wasm byte code ==> Val
SubmitRepo == source code & build metadata ==> Val
Val -->|passed| Voting
[β 2] should we require hash validation before triggering the voting period of the proposal? if so it sounds like a chain upgrade, what else could be an alternative? @ValarDragon
π Answer 2 by @daniel-farina
The StoreCodeProposal
already contains wasm byte code, one can get that by querying the proposal.
For Submit source and metadata
this would trigger a question:
[β 3] In what format should we store the source reference & build metadata (for deterministic build)?
π Answer 3 by @daniel-farina
[π‘ 3] Specific & special region in the proposal description for source reference & build metadata
[β 4] Do we require public git repository? or just upload an archive somewhere?
π Answer 4 by @daniel-farina
[β 5] Where does contract list update sits in the process?
π Answer 5 by @daniel-farina
This is normally a 2 steps process of StoreCode -> InitiateContract
, but common pattern of a dapp has the following:
StoreCode -> InitiateContract
tends to happen sequentially.The following graph is a general execution plan for a deploying a dapp.
[π‘ 6] Note that this structure is dependency graph so the process as code @daniel-farina mentioned in #48 could incorporate the whole flow like what terraform does.
[β 7] Is it possible / how hard it is to have multiple related proposals (like in the process above) to go through the gov together as bundled proposal? Does it make sense to do so? I can imagine how this could simplify the flow... @ValarDragon @sunnya97
The following graph is a general execution plan for a migrating multiple contract for a dapp. It shares the same question as for the deployment.
Lastly:
[β 8] Will we use https://commonwealth.im/osmosis/ for wasm governance?
π Answer 8 by @daniel-farina
Let me know your thoughts.
reconstruct this msg in rust https://github.com/CosmWasm/wasmd/blob/ac92fdcf37388cc8dc24535f301f64395f8fb3da/proto/cosmwasm/wasm/v1/proposal.proto
and try rpc-ing it
make gov proposal works
refactor types -> gen types -> get path
expose proposal related stuffs to the interface
check mainnet config with command provided by Dev & see plan about gov
[BLOCKED] try editing genesis.json
remove permission to test the process (with for nico / adam response)
fix state file: non has config for local and shared network
PropsoalStoreCodeResponse
make deposit works (for today: 7 Jun)
check deposit
extract module
update state for proposal
find the hash function for code_hash -> sha256sum
create query for proposal
refactor: extract modules
move ops into their own module
beaker wasm proposal vote store-code counter --amount 10000uosmo {{base_tx}}
beaker wasm proposal store-code sync-state
// ultimately
struct Code {
id: u64,
instances: Map<String, String>
}
struct Proposal {
store_code: Option<u64>
}
struct WasmRef {
code: Option<Code>
proposal: Proposal,
}
console.js
When I made my beaker project, I was quite curious as to what the .beaker folder was for.
A short readme inside of it would be good to help the curious, who are trying out beaker!
When store code, the code stored can have permission of who could instantiate the contract. The permission can be put in the StoreCodeMsg
.
This issue is for tracking the implementation and pose the question of it's priority which depends on the discussion on #59
edit: since instantiation is permissionless, this is now important..
await contract.counter.execute({ increase: {}}).by(account.test1)
await contract.counter.query({ get_count: {} })
await contract.counter.$awesome.execute({ increase: {}}).by(account.test1)
await contract.counter.$awesome.query({ get_count: {} })
--no-optimize
--optimize
-> --no-optimize
--no-optimize
to store non-release target, faster build--no-optimize
The idea here is to get the config struct documentation at runtime to generate md file that has details
md
gen into its own package so that md package only focus on generating md and use cli and get_docs as depsREADME.md
get_docs
-> get_data_docs
;derive_get_doc
-> data_doc_derive
, get_docs
-> data_doc
struct Docs(Vec<Doc>);
struct DataDoc {
ident: String,
desc: Vec<String>,
sub_docs: Vec<DataDoc>
};
trait GetDataDocs {
get_data_docs() -> Vec<DataDoc>;
}
The deployment process = code => [build, optimize, store-code, instantiate]
, which can have multiple instantiation.
Assumption is, if they use this method, they will just use the same signer...
$ beaker deploy counter --signing-account test1
$ beaker deploy counter --signing-account test1
$ beaker deploy counter --signing-account test1 --no-rebuild
args:
contract_name,
raw
chain_id,
signer_args,
gas_args,
timeout_height,
label
chain_id
(change chain_id to network once working on #15 )--no-rebuild
and impl the logicObject.assign(globol, account)
option with renaming to avoid scope polutionawait contract.counter.increase().by(account.test1)
await contract.counter.getCount()
with global
await counter.increase().by(test1)
await counter.getCount()
interactive console has the following purposes:
.beaker
an npm packagebeaker
npm modulecw
to wasm
support::state
module
$WORKSPACE_ROOT/.membrane/state.local.json
Defaulted to local network ( = --network local
but not implemented at the moment)
$ membrane wasm store-code counter
|-- .membrane
| |-- state.json
| |-- state.local.json // if chain-id is defined to be local (localosmosis)
use latest only until the need arise...
{
"<chain-id>": {
"counter": {
"code-id": 1,
"address": {
"default": "..",
}
}
}
}
state file utils:
.beaker
: remove packageWriting getting started guide to guide through the process user needs to go through.
This serves 2 purpose:
Mark work in progress section as WIP and link to the issue.
Narrate through the process of
Changes are expected but this must serves as a skeleton for further modification
tips
beaker[local] β contract.counter.query({ get_count: {} })
Promise {
<pending>,
[Symbol(async_id_symbol)]: 396,
[Symbol(trigger_async_id_symbol)]: 97
}
beaker[local] β await _
{ count: 101 }
Submitting a proposal is currently done this way:
beaker wasm proposal store-code --title "Testnet Contract" --description "Testnet Contract" --signer-account test1 --network testnet counter --gas 25000000uosmo --gas-limit 25000000
I think we could simplify this by making a yaml file instead or json. This will be really useful as the description can be quite long.
beaker wasm proposal store-code --proposal proposal_407.yaml counter
Example proposal.yml idea
title: Proposal to allow DappName to be enabled in Osmosis
description: |
A lengthy proposal description
goes here
we expect this to be many lines...
code:
github: https://github.com/osmosis-labs/beaker/
reviewed_by: https://....
settings:
gas: 25000000uosmo
network: testnet
code
part as a metadata structure in the proposal descriptioncargo generate
with local git)beaker wasm ts-gen <contract_name>
: leverage https://www.npmjs.com/package/cosmwasm-typescript-gen
cargo schema
cosmwasm-typescript-gen generate \ --schema ./path/to/schema \ --out ./path/to/ts/sdk \ --name MyContractName
cargo schema
schema gen commandops
await account.test1.sign(contract.counter).increase()
await contract.counter.getCount()
with global
await counter.with(test1).increase()
await counter.getCount()
path
to store localosmosis codeWe need to define the upgrade process for a contract. What are the requirements and steps to accomplish this? We should do this via CLI first.
This is currently blocked by #58 [it's closed, no longer blocked]
Nice to have adding to backlog
Currently a project generated from beaker new counter-dapp
has a blank gitignore, this is one step we should automate out!
artifacts
(for wasm artifacts)**/state.local.json
This should be done once #56 is complete. Good item for the backlog since we can do this via CLI first.
Is there a reason why the CI generated for contracts right now is circleCI vs github actions? (e.g. speed?)
Would be nice to have the normal flow "just work" when put on github, whereas circleCI requires some extra configuring.
Hitting this error when using mainnet (an account with no funds on mainnet) test1.
beaker wasm proposal store-code --title "Mainner Contract" --description "Official Contract for" --signer-account test1 --network mainnet counter --gas 100000uosmo --gas-limit 100000
The expected result should be something about not having enough funds.
Output:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: serde parse error
Caused by:
expected value at line 1 column 1
Location:
/Users/web/.cargo/registry/src/github.com-1ecc6299db9ec823/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9
Caused by:
0: serde parse error
1: expected value at line 1 column 1
Location:
/Users/web/.cargo/registry/src/github.com-1ecc6299db9ec823/cosmrs-0.7.1/src/tx/raw.rs:34:12', /Users/web/.cargo/registry/src/github.com-1ecc6299db9ec823/beaker-0.0.4/src/support/cosmos.rs:246:77
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
refs:
https://github.com/cosmos/cosmjs/blob/main/packages/stargate/src/fee.ts
impl to_fee
impl From for Gas
add Option<gas_config>: gas_price, gas_adjustment
change Fee::from(gas_args) to Gas::from(gas_args)
change type signature and name in sign_and_broadcast
fix type errors
test out
https://docs.osmosis.zone/developing/dapps/get_started/cosmwasm-testnet.html
Once the contract is created we can check query the contract information. Assuming you are connected to the testnet.
osmosisd query wasm contract osmo1mpf0guu0t363xrshhedandypq003ahzaxvsxzgu69n3ej03mh2zqx5gk8l
osmosisd query wasm contract-state raw osmo1mpf0guu0t363xrshhedandypq003ahzaxvsxzgu69n3ej03mh2zqx5gk8l 636F6E74726163745F696E666F --node https://rpc-test.osmosis.zone:443 --output json | jq -r .data | base64 -d | jq
What in the world is 636F6E74726163745F696E666F
? π
ContractInfo is must be stored under "contract_info" key which translates to "636F6E74726163745F696E666F" in hex format. As documented here.
osmosisd query wasm code 205 205_code.wasm --node https://rpc-test.osmosis.zone:443
sha256sum 205_code.wasm
0b662785042cd938d0f0e8142f69d2d23fdf0addec965d1fbeacf44080330016
Now it's time to verify the hash with the source repos. All contracts should provide a repository with a hash for their contracts the same way that cw-plus does on their checksum as shown below:
10bc1a8cf82055106b26136f26137d6bf132df99c2d2098a75d03b64e7fe75a5 cw1155_base.wasm
539b62678532596c73b27764186623a2bb868f5e67c3e588508c4a28e105e8c9 cw1_subkeys.wasm
b67bc69fef770c28d48730feb800ea9c91eaae1a608e3ea7819aac64a6e99d92 cw1_whitelist.wasm
704890409d0e82f33951f0f4d06e42b27082d91b5c8c98853969296191244baf cw1_whitelist_ng.wasm
db366741dcbad5f2e4933cda49133cd2a11fdb32b08c67cb1d22379bd392448e cw20_base.wasm
ac452ac5c96ac843cad0267a0f465d39f6dd43d4e47631e6deefd23a4cf77a61 cw20_ics20.wasm
b3d44429dfb1e445a7ea3c0125b71efdc85185666f35e4e62581ffc1310905bd cw3_fixed_multisig.wasm
62131b508b448dad7d7878188f55b674c24a1b705791179b87e85e0854538837 cw3_flex_multisig.wasm
163566b6f65819c2ea6cadddc847cbaaa59f5218dbbd895bcc2fcefe1afd7d0e cw4_group.wasm
0c44f17035eb51c0115d95f14e83ce2cdfbcb804ffa95e1f8203d22300d6ba90 cw4_stake.wasm
test
In docs.osmosis.zone, we note that users need to run
rustup target add wasm32-unknown-unknown
cargo install cargo-generate --features vendored-openssl
cargo install cargo-run-script
It'd be cool if any beaker command could set these up for you, if its not already handled. (Reduces the amount of installation steps folks have to do)
If deposit data is included in the YAML proposal file then execute the deposit command else if empty allow user to do the deposit as a secondary step.
pre:
$ membrane wasm instantiate counter --raw '{ "counter": 0 }' # imply --label default
$ membrane wasm instantiate counter --raw '{ "counter": 0 }' --label "sth"
# won't work with --code-id
$ membrane wasm instantiate counter # use counter/instantiate-msgs/default.json
$ membrane wasm instantiate counter one # use counter/instantiate-msgs/one.json, imply --name "one"
SignerArg
SignerArg
methodGasArg
GasArg
methodcoin.rs
support/format
)ibc_port_id
could be separated part, IBC support)I believe we need beaker wasm instantiate
to support admin since it's required during the contract upgrade process.
This was pointed out in the source code here:
Just calling it out as a blocker for mainnet deployments as contracts would become immutable without an admin.
Purpose:
when in console, if you want to keep the state and update stuffs without leaving console, you can hit .redeploy
, it will just rebuild, store-code, instantiate everything that exists
.redeploy
.deploy counter test1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.