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

feat: add cosmwasm #118

Merged
merged 61 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
c54b1eb
feat!: add cosmwasm
chalabi2 Feb 7, 2025
b6ba005
fix: fix determinism simulation test
chalabi2 Feb 7, 2025
7f50a53
fix: sim-full-app test
chalabi2 Feb 7, 2025
c0477ee
WIP: attempt to fix sim-import* and sim-after* simulation tests
chalabi2 Feb 7, 2025
befe1f9
feat: add cosmwasm interchain test
chalabi2 Feb 7, 2025
bcfbe75
fix: make local-image
chalabi2 Feb 7, 2025
895e8a7
fix: use ARCH version for libwasm url in Dockerfile
chalabi2 Feb 7, 2025
421a649
fix: docker and heighliner w/ wasm
fmorency Feb 7, 2025
daa15f5
fix: go.sum
fmorency Feb 7, 2025
6047b6f
fix: format & cosmwasm_2_0
fmorency Feb 7, 2025
0ef41a5
fix: make test
fmorency Feb 7, 2025
f26ca43
fix: revert sim_test changes
fmorency Feb 7, 2025
4ccdf4a
fix: simulation
fmorency Feb 7, 2025
4d49cd6
fix: lint
fmorency Feb 7, 2025
3a1c93e
fix: lint
fmorency Feb 7, 2025
c24a5b9
fix: interchaintest cosmwasm_test
chalabi2 Feb 7, 2025
82c48df
chore: add cosmwasm upgrade handler
chalabi2 Feb 9, 2025
0ceabf4
chore: bump to cosmos-sdk v0.50.11-lifted.1
fmorency Feb 10, 2025
5b315f0
fix: coverage
fmorency Feb 10, 2025
c0d11ba
docs: fix wasm execute
fmorency Feb 10, 2025
08fab80
fix: handler wasm store key
fmorency Feb 10, 2025
5ca8c28
fix: builtin wasm capabilities
fmorency Feb 10, 2025
e3bbf56
fix: use home path for wasm keeper
fmorency Feb 10, 2025
52fc64b
chore(deps): bumps
fmorency Feb 10, 2025
e55694c
fix: wasm mm init
fmorency Feb 10, 2025
776949c
fix: go 1.23
fmorency Feb 10, 2025
992ccb6
fix: lint
fmorency Feb 10, 2025
461f89c
fix: wasm param in script
fmorency Feb 10, 2025
aa5c788
chore: bump wasmvm to v2.2.2
fmorency Feb 10, 2025
77a21ce
setup poa wasm testing
chalabi2 Feb 10, 2025
df6cc93
Merge remote-tracking branch 'origin/chalabi/add-cosmwasm' into chala…
chalabi2 Feb 10, 2025
4aa6ca2
add wasm group proposal test
chalabi2 Feb 11, 2025
9717020
add upgrade test
chalabi2 Feb 11, 2025
d3f8201
fix: gas adjustment
fmorency Feb 11, 2025
ef36d7d
test: only poa admin can upload/instantiate contracts
fmorency Feb 11, 2025
3152445
test: use known addresses
fmorency Feb 11, 2025
6210313
chore: remove heighliner
fmorency Feb 11, 2025
a1bbd94
chore: bump interchaintest
fmorency Feb 11, 2025
6cabd46
fix: chain upgrade test
fmorency Feb 11, 2025
fb4a01d
add wasm permissions to upgrade handler
chalabi2 Feb 11, 2025
fa82df4
use proposal for wasm test in upgrade
chalabi2 Feb 11, 2025
cc3ce71
fix: delay between stop and upgrade
fmorency Feb 11, 2025
6092372
fix: delta
fmorency Feb 11, 2025
d31aa1e
Merge branch 'chalabi/add-cosmwasm' of https://github.com/liftedinit/…
chalabi2 Feb 11, 2025
130d4bf
fix: lint & upgrade name
fmorency Feb 11, 2025
67a28f7
fix: dry & cyclic deps
fmorency Feb 11, 2025
eb8e250
fix: lint
fmorency Feb 11, 2025
139a33e
fix: forgot file
fmorency Feb 11, 2025
b1059ea
fix: imports
fmorency Feb 11, 2025
a96181f
fix: serial coverage tests & verbosity
fmorency Feb 11, 2025
4a521d3
fix: proposal id
fmorency Feb 11, 2025
3ccbf81
fix: increase timers...
fmorency Feb 11, 2025
373c3dd
chore: update set-genesis-params.sh with wasm
fmorency Feb 12, 2025
dde5567
fix: upgrade name and bump version
fmorency Feb 12, 2025
3b96b9f
ci: enable cgo in goreleaser
fmorency Feb 12, 2025
6c0d06a
fix: wasm requires cgo - disable cross compilation for now
fmorency Feb 12, 2025
0259e9b
ci: build release on ubuntu 22.04
fmorency Feb 12, 2025
13b2cfe
fix: upgrade test
fmorency Feb 12, 2025
455960a
fix: init wasm
fmorency Feb 17, 2025
4245243
fix: lint
fmorency Feb 17, 2025
daf5967
fix: gas config
fmorency Feb 18, 2025
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: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: 1.22.11
GO_VERSION: 1.23.6

jobs:
build:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: 'stable'
- name: Get heighliner
run: |
wget -c https://github.com/strangelove-ventures/heighliner/releases/download/v1.5.4/heighliner_1.5.4_linux_amd64.tar.gz -O - | tar -xz heighliner
mv heighliner /usr/local/bin
- name: Make local image
run: make local-image
- name: Run coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: 1.22.11
GO_VERSION: 1.23.6

jobs:
analyze:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ permissions:
packages: write

env:
GO_VERSION: 1.22.11
GO_VERSION: 1.23.6
TAR_PATH: /tmp/manifest-docker-image.tar
IMAGE_NAME: manifest-docker-image

Expand Down Expand Up @@ -66,6 +66,8 @@ jobs:
- "ictest-tokenfactory"
- "ictest-manifest"
- "ictest-group-poa"
- "ictest-cosmwasm"
- "ictest-chain-upgrade"
fail-fast: false

steps:
Expand All @@ -89,4 +91,4 @@ jobs:
docker image ls -a

- name: Run Test
run: make ${{ matrix.test }}
run: make ${{ matrix.test }}
2 changes: 1 addition & 1 deletion .github/workflows/release-bin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: actions/setup-go@v2
with:
go-version: '1.22.11'
go-version: '1.23.6'

- name: Clean up dist directory
run: rm -rf dist
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
types: [opened, reopened, synchronize]

env:
GO_VERSION: 1.22.11
GO_VERSION: 1.23.6

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
types: [opened, reopened, synchronize]

env:
GO_VERSION: 1.22.11
GO_VERSION: 1.23.6

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ linters-settings:
- prefix(github.com/cosmos/cosmos-sdk)
- prefix(github.com/strangelove-ventures/poa)
- prefix(github.com/strangelove-ventures/tokenfactory)
- prefix(github.com/CosmWasm/wasmd)
- prefix(github.com/CosmWasm/wasmvm)
- prefix(github.com/liftedinit/manifest-ledger)
gosec:
excludes:
Expand Down
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22-alpine AS go-builder
FROM golang:1.23-alpine AS go-builder
ARG BUILD_CMD=build

SHELL ["/bin/sh", "-ecuxo", "pipefail"]
Expand All @@ -10,9 +10,13 @@ WORKDIR /code
ADD go.mod go.sum ./
RUN set -eux; \
export ARCH=$(uname -m); \
WASM_VERSION=$(go list -m all | grep github.com/CosmWasm/wasmvm | awk '{print $2}'); \
WASM_VERSION=$(go list -m all | grep github.com/CosmWasm/wasmvm/v2); \
if [ ! -z "${WASM_VERSION}" ]; then \
wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.${ARCH}.a; \
WASMVM_REPO=$(echo $WASM_VERSION | awk '{print $1}'); \
WASMVM_VERS=$(echo $WASM_VERSION | awk '{print $2}'); \
wget -O /lib/libwasmvm_muslc.a https://${WASMVM_REPO%/v2}/releases/download/${WASMVM_VERS}/libwasmvm_muslc.${ARCH}.a; \
chmod +x /lib/libwasmvm_muslc.a; \
ln -s /lib/libwasmvm_muslc.a /lib/libwasmvm_muslc.${ARCH}.a; \
fi; \
go mod download;

Expand Down
128 changes: 99 additions & 29 deletions MODULE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,42 @@
## Table of Contents

<!-- TOC -->
* [Manifest Module](#manifest-module)
* [Module Functionality](#module-functionality)
* [Commands](#commands)
* [Mint and disburse native tokens (payout):](#mint-and-disburse-native-tokens-payout)
* [Burn native tokens (burn-coins):](#burn-native-tokens-burn-coins)
* [Proof of Authority Module](#proof-of-authority-module)
* [Module Functionality](#module-functionality-1)
* [Validator Management:](#validator-management)
* [Administrative Rights:](#administrative-rights)
* [Commands](#commands-1)
* [Update Staking Parameters (update-staking-params):](#update-staking-parameters-update-staking-params)
* [Set Voting Power (set-power):](#set-voting-power-set-power)
* [Remove Pending Validator (remove-pending):](#remove-pending-validator-remove-pending)
* [Remove Validator (remove):](#remove-validator-remove)
* [Token Factory Module](#token-factory-module)
* [Module Functionality](#module-functionality-2)
* [Token Minting:](#token-minting)
* [Token Burning:](#token-burning)
* [Token Administration:](#token-administration)
* [Metadata Management:](#metadata-management)
* [Commands](#commands-2)
* [Burn (burn):](#burn-burn)
* [Burn From (burn-from):](#burn-from-burn-from)
* [Mint (mint):](#mint-mint)
* [Change Admin (change-admin):](#change-admin-change-admin)
* [Create Denom (create-denom):](#create-denom-create-denom)
* [Force Transfer (force-transfer):](#force-transfer-force-transfer)
* [Modify Metadata (modify-metadata):](#modify-metadata-modify-metadata)

- [Manifest Module](#manifest-module)
- [Module Functionality](#module-functionality)
- [Commands](#commands)
- [Mint and disburse native tokens (payout):](#mint-and-disburse-native-tokens-payout)
- [Burn native tokens (burn-coins):](#burn-native-tokens-burn-coins)
- [Proof of Authority Module](#proof-of-authority-module)
- [Module Functionality](#module-functionality-1)
- [Validator Management:](#validator-management)
- [Administrative Rights:](#administrative-rights)
- [Commands](#commands-1)
- [Update Staking Parameters (update-staking-params):](#update-staking-parameters-update-staking-params)
- [Set Voting Power (set-power):](#set-voting-power-set-power)
- [Remove Pending Validator (remove-pending):](#remove-pending-validator-remove-pending)
- [Remove Validator (remove):](#remove-validator-remove)
- [Token Factory Module](#token-factory-module)
- [Module Functionality](#module-functionality-2)
- [Token Minting:](#token-minting)
- [Token Burning:](#token-burning)
- [Token Administration:](#token-administration)
- [Metadata Management:](#metadata-management)
- [Commands](#commands-2)
- [Burn (burn):](#burn-burn)
- [Burn From (burn-from):](#burn-from-burn-from)
- [Mint (mint):](#mint-mint)
- [Change Admin (change-admin):](#change-admin-change-admin)
- [Create Denom (create-denom):](#create-denom-create-denom)
- [Force Transfer (force-transfer):](#force-transfer-force-transfer)
- [Modify Metadata (modify-metadata):](#modify-metadata-modify-metadata)
- [COSM WASM Module](#cosm-wasm-module)
- [Module Functionality](#module-functionality-3)
- [Commands](#commands-3)
- [Upload Contract (upload-contract):](#upload-contract-upload-contract)
- [Instantiate Contract (instantiate-contract):](#instantiate-contract-instantiate-contract)
- [Execute Contract (execute-contract):](#execute-contract-execute-contract)

<!-- TOC -->

## Manifest Module
Expand Down Expand Up @@ -146,7 +154,7 @@ If the PoA admin decides they no longer wish for a validator to be signing block

The Token Factory module as it is implemented on the Manifest Network, allows any user to have granular control over the creation and management of tokens on the Manifest Network. The creator can mint, burn, edit, and transfer tokens to other accounts from any account.

>_note:_ The module is designed to work with tokens created by the module itself.
> _note:_ The module is designed to work with tokens created by the module itself.

### Module Functionality

Expand Down Expand Up @@ -243,3 +251,65 @@ The Token Factory module as it is implemented on the Manifest Network, allows an
- `exponent`: The exponent for the token e.g. how many zeros.

**Example:** `manifestd tx tokenfactory modify-metadata utoken TOKEN "A token" 6`

## COSM WASM Module

The WASM module is responsible for handling the deployment and execution of WASM contracts on the Manifest Network.

### Module Functionality

The WASM module provides several key functionalities for managing smart contracts:

#### Contract Deployment:

- Upload WASM contract code to the blockchain
- Instantiate contracts with initial parameters
- Support for predictable contract addresses using instantiate2

#### Contract Administration:

- Set and clear contract administrators
- Migrate contracts to new code versions
- Update contract labels and configurations
- Manage instantiation permissions

#### Contract Execution:

- Execute contract functions with custom messages
- Support for contract-to-contract calls
- Handle contract queries and responses

#### Commands

##### Upload Contract (upload-contract):

- Syntax: `manifestd tx wasm store [wasm-file] [flags]`

- Parameters:
- `wasm-file`: Path to the .wasm contract file to upload
- Optional flags for instantiation permissions and access control

**Example:** `manifestd tx wasm store contract.wasm --from mykey`

##### Instantiate Contract (instantiate-contract):

- Syntax: `manifestd tx wasm instantiate [code-id] [json-encoded-args] --label [text] [flags]`

- Parameters:
- `code-id`: The ID of the uploaded contract code
- `json-encoded-args`: Init message for the contract in JSON format
- `label`: Human-readable label for the contract instance
- Optional flags for admin, funds, and other parameters

**Example:** `manifestd tx wasm instantiate 1 '{"count": 0}' --label "counter" --from mykey`

##### Execute Contract (execute-contract):

- Syntax: `manifestd tx wasm execute [contract-addr] [json-encoded-args] [flags]`

- Parameters:
- `contract-addr`: The address of the instantiated contract
- `json-encoded-args`: Execute message in JSON format
- Optional flags for sending funds with execution

**Example:** `manifestd tx wasm execute manifest14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s0phg4d '{"increment":{}}' --from mykey`
23 changes: 11 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,23 @@ ictest-poa:
ictest-group-poa:
cd interchaintest && go test -race -v -run TestGroupPOA . -count=1

ictest-cosmwasm:
cd interchaintest && go test -race -v -run TestCosmWasm . -count=1

ictest-chain-upgrade:
cd interchaintest && go test -race -v -run TestBasicManifestUpgrade . -count=1

.PHONY: ictest-ibc ictest-tokenfactory
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update .PHONY declaration to include new targets.

The new test targets should be included in the .PHONY declaration to ensure proper Make behavior.

-.PHONY: ictest-ibc ictest-tokenfactory
+.PHONY: ictest-ibc ictest-tokenfactory ictest-cosmwasm ictest-chain-upgrade
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.PHONY: ictest-ibc ictest-tokenfactory
.PHONY: ictest-ibc ictest-tokenfactory ictest-cosmwasm ictest-chain-upgrade


###############################################################################
### Build Image ###
###############################################################################

get-heighliner:
git clone https://github.com/strangelove-ventures/heighliner.git
cd heighliner && go install

local-image:
ifeq (,$(shell which heighliner))
echo 'heighliner' binary not found. Consider running `make get-heighliner`
else
heighliner build -c manifest --local -f ./chains.yaml --alpine-version 3.20
endif
@echo "--> Building local image"
docker build . -t manifest:local

.PHONY: get-heighliner local-image
.PHONY: local-image

#################
### Test ###
Expand Down Expand Up @@ -170,7 +169,7 @@ coverage: ## Run coverage report
@echo " --> Running App State Determinism Simulation"
@${COV_SIM_CMD} -test.run TestAppStateDeterminism ${COV_SIM_COMMON} > /dev/null 2>&1
@echo "--> Running unit & e2e tests coverage"
@go test -timeout 30m -race -covermode=atomic -v -cpu=$$(nproc) -cover $$(go list ./...) ./interchaintest/... -coverpkg=${COV_PKG} -args -test.gocoverdir="${COV_UNIT_E2E}" > /dev/null 2>&1
@go test -p 1 -timeout 30m -race -covermode=atomic -v -cpu=$$(nproc) -cover $$(go list ./...) ./interchaintest/... -coverpkg=${COV_PKG} -args -test.gocoverdir="${COV_UNIT_E2E}"
@echo "--> Merging coverage reports"
@go tool covdata merge -i=${COV_UNIT_E2E},${COV_SIMULATION} -o ${COV_ROOT}
@echo "--> Converting binary coverage report to text format"
Expand Down Expand Up @@ -217,7 +216,7 @@ proto-lint:
#################

golangci_lint_cmd=golangci-lint
golangci_version=v1.58.0
golangci_version=v1.63.4

lint:
@echo "--> Running linter"
Expand Down
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ While PoA offers immediate stability and control, the Manifest Network aspires f

**Operating System**

- Linux (x86_64) or Linux (arm64)
- Linux (x86_64 with SSSE3 support) or Linux (arm64 with NEON support)

> Note: CosmWasm requires x86-64 processors to support SSSE3 instructions (Intel Core 2 or newer) or ARM64 processors with NEON support.

**Arch Linux:**

Expand Down Expand Up @@ -126,13 +128,25 @@ make ictest-ibc
make ictest-group-poa
```

**To test the chain upgrade run:**

```bash
make ictest-chain-upgrade
```

**To Test cosmwasm functionality run:**

```bash
make ictest-cosmwasm
```

## Simulation

**To execute the full application simulation run:**

```bash
make sim-full-app
````
```

**To execute the application simulation after state import run:**

Expand All @@ -155,7 +169,7 @@ To generate a coverage report for the modules run:
```bash
make local-image
make coverage
````
```

## Helper

Expand All @@ -175,3 +189,13 @@ CHAIN_ID="local-2" HOME_DIR="~/.manifest2" CLEAN=true RPC=36657 REST=2317 PROFF=
```

The succesful executation of these commands will result in 2 ibc connected instances of manifestd running on your local machine.

#### Upload Contract script

`scripts/upload_contract.sh`

This script is used to upload a contract to the network. It is used to upload the cosmwasm template contract to the network.

`sh scripts/upload_contract.sh`

> Running this script with no arguments will utilize the same environment variables as the test_node.sh script.
Loading
Loading