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

Override cw default compile costs #90

Merged
merged 3 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ func GetWasmOpts(appOpts servertypes.AppOptions) []wasm.Option {
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
}

wasmOpts = append(wasmOpts, wasmkeeper.WithGasRegister(NewJunoWasmGasRegister()))

return wasmOpts
}

Expand Down
27 changes: 27 additions & 0 deletions app/wasm_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package app

import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
)

const (
DefaultJunoCompileCost uint64 = 4
JakeHartnell marked this conversation as resolved.
Show resolved Hide resolved
JakeHartnell marked this conversation as resolved.
Show resolved Hide resolved
)

// JunoGasRegisterConfig is defaults plus a custom compile amount
func JunoGasRegisterConfig() wasmkeeper.WasmGasRegisterConfig {
return wasmkeeper.WasmGasRegisterConfig{
InstanceCost: wasmkeeper.DefaultInstanceCost,
CompileCost: DefaultJunoCompileCost,
GasMultiplier: wasmkeeper.DefaultGasMultiplier,
EventPerAttributeCost: wasmkeeper.DefaultPerAttributeCost,
CustomEventCost: wasmkeeper.DefaultPerCustomEventCost,
EventAttributeDataCost: wasmkeeper.DefaultEventAttributeDataCost,
EventAttributeDataFreeTier: wasmkeeper.DefaultEventAttributeDataFreeTier,
ContractMessageDataCost: wasmkeeper.DefaultContractMessageDataCost,
}
giansalex marked this conversation as resolved.
Show resolved Hide resolved
}

func NewJunoWasmGasRegister() wasmkeeper.WasmGasRegister {
return wasmkeeper.NewWasmGasRegister(JunoGasRegisterConfig())
}
4 changes: 4 additions & 0 deletions docker/setup_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

./setup_junod.sh
./run_junod.sh
27 changes: 19 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,30 @@ Network incentives would primarily come from smart contract usage and regular tx

## Get started

```
starport serve
```
If you have [Docker](https://www.docker.com/) installed, then you can run a local node with a single command.

`serve` command installs dependencies, builds, initializes and starts your blockchain in development.
This assumes you will connect to it via `junod` from outside the container. You could also use `docker exec`, if you prefer, which eliminates the need to

## Configure
1. Open two terminal tabs at the root of this repo.
2. In tab one, build and run Juno in blocking mode: `./scripts/build_and_run_blocking.sh`. Once it has compiled, you should see blocks appearing.

Your blockchain in development can be configured with `config.yml`. To learn more see the [reference](https://github.com/tendermint/starport#documentation).
### Option 1: Using Docker

## Launch
3. Switch to tab two and exec into the container: `docker exec -it juno-local /bin/sh`
4. Run `junod status`. You should see JSON status for the Juno node running in Docker.

To launch your blockchain live on mutliple nodes use `starport network` commands. Learn more about [Starport Network](https://github.com/tendermint/spn).
### Option 2: Using junod (advanced/dev use)

3. Switch to tab two and build juno outside the container if you haven't already: `make build && make install`.
4. Run `junod status`. You should see JSON status for the Juno node running in Docker.

The RPC port for Juno is forwarded to your host, so as long as Docker is correctly set up, you can send it commands via the Juno binary, `junod` on your host.

Protip: running this script is also a decent sense-check that:

1. The build is still working
2. The Docker build is still working
3. The code is in a runnable state

## Learn more

Expand Down
9 changes: 9 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

GIT_TAG=$(git describe --tags)

echo "> Building $GIT_TAG..."

docker build . -t cosmoscontracts/juno:$GIT_TAG
6 changes: 6 additions & 0 deletions scripts/build_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

./scripts/build.sh
./scripts/run.sh
6 changes: 6 additions & 0 deletions scripts/build_and_run_blocking.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

./scripts/build.sh
./scripts/run_blocking.sh
9 changes: 9 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

GIT_TAG=$(git describe --tags)

echo "> Running $GIT_TAG..."

docker run --rm -it -p 26657:26657 --name juno-local cosmoscontracts/juno:$GIT_TAG /bin/sh
9 changes: 9 additions & 0 deletions scripts/run_blocking.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

GIT_TAG=$(git describe --tags)

echo "> Running $GIT_TAG..."

docker run --rm -it -p 26657:26657 --name juno-local cosmoscontracts/juno:$GIT_TAG /bin/sh -c "./setup_and_run.sh"