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

Manually test all contract interfaces with wasmi in SGX #139

Closed
8 tasks done
assafmo opened this issue Apr 12, 2020 · 1 comment
Closed
8 tasks done

Manually test all contract interfaces with wasmi in SGX #139

assafmo opened this issue Apr 12, 2020 · 1 comment
Assignees
Labels
dev Critical path development tasks testing

Comments

@assafmo
Copy link
Member

assafmo commented Apr 12, 2020

  • read_db
  • write_db
  • humanize_address
  • canonicalize_address
  • gas
  • init
  • handle
  • query
@assafmo assafmo added the dev Critical path development tasks label Apr 12, 2020
@assafmo assafmo closed this as completed Apr 14, 2020
@assafmo
Copy link
Member Author

assafmo commented Apr 14, 2020

Terminal 1:

# from inside EnigmaBlockchain
make build_linux
cp ./cosmwasm/lib/wasmi-runtime/librust_cosmwasm_enclave.signed.so .

rm -rf ~/.enigma*

./enigmacli config chain-id enigma-testnet # now we won't need to type --chain-id enigma-testnet every time
./enigmacli config output json
./enigmacli config indent true
./enigmacli config trust-node true # true if you trust the full-node you are connecting to, false otherwise

./enigmad init banana --chain-id enigma-testnet # banana==moniker==user-agent of this node
perl -i -pe 's/"stake"/"uscrt"/g' ~/.enigmad/config/genesis.json # change the default staking denom from stake to uscrt

yes | ./enigmacli keys add a

./enigmad add-genesis-account $(./enigmacli keys show -a a) 1000000000000uscrt # 1 SCRT == 10^6 uSCRT

./enigmad validate-genesis # make sure genesis file is correct
# `./enigmad export` to send genesis.json to validators

./enigmad gentx --name a --amount 1000000uscrt # generate a genesis transaction - this makes a a validator on genesis which stakes 1000000uscrt (1 SCRT)

./enigmad collect-gentxs # input the genTx into the genesis file, so that the chain is aware of the validators

./enigmad validate-genesis

RUST_BACKTRACE=1 ./enigmad start

Terminal 2:

# get erc20 wasm from https://raw.githubusercontent.com/CosmWasm/cosmwasm-examples/f5ea00a85247abae8f8cbcba301f94ef21c66087/erc20/contract.wasm

yes | ./enigmacli tx compute store ~/contract.wasm --from a --gas 6037498

# get XXX with `./enigmacli keys show -a a`

# this command may take a few minutes to execute because SGX is initializing its memory
yes | ./enigmacli tx compute instantiate 1 '{"decimals":10,"initial_balances":[{"address":"XXX","amount":"108"},{"address":"enigma1f395p0gg67mmfd5zcqvpnp9cxnu0hg6rp5vqd4","amount":"53"}],"name":"ReuvenPersonalRustCoin","symbol":"RVN"}' --label RVNCoin --from a
# this^ calls write_db, canonicalize_address

./enigmacli q compute contract-state smart $(./enigmacli q compute list-contract-by-code 1 | jq -r '.[].address' | tail -1) '{"balance":{"address":"enigma1f395p0gg67mmfd5zcqvpnp9cxnu0hg6rp5vqd4"}}' # returns 53
# this^ calls read_db, canonicalize_address

./enigmacli q compute contract-state smart $(./enigmacli q compute list-contract-by-code 1 | jq -r '.[].address' | tail -1) '{"balance":{"address":"XXX"}}' # returns 108

./enigmacli tx compute execute enigma1hqrdl6wstt8qzshwc6mrumpjk9338k0lja5ur0 '{"transfer":{"amount":"10","recipient":"enigma1f395p0gg67mmfd5zcqvpnp9cxnu0hg6rp5vqd4"}}' --from a
# this^ calls read_db, write_db, humanize_address, canonicalize_address

./enigmacli q compute contract-state smart $(./enigmacli q compute list-contract-by-code 1 | jq -r '.[].address' | tail -1) '{"balance":{"address":"enigma1f395p0gg67mmfd5zcqvpnp9cxnu0hg6rp5vqd4"}}' # returns 63

./enigmacli q compute contract-state smart $(./enigmacli q compute list-contract-by-code 1 | jq -r '.[].address' | tail -1) '{"balance":{"address":"XXX"}}' # returns 98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev Critical path development tasks testing
Projects
None yet
Development

No branches or pull requests

3 participants