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(x/asset): Custom mintable, burnable precompiles [WIP] #17

Draft
wants to merge 32 commits into
base: trinity/msg-for-new-asset-module
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
eeee227
no more token distributor
hieuvubk Jan 21, 2025
b9b235c
port denom into precompile, no more tokenPair
hieuvubk Jan 21, 2025
c77a57c
basic mint/burn
hieuvubk Jan 21, 2025
8173a0b
basic test
hieuvubk Jan 31, 2025
566e811
update state.md
hieuvubk Jan 31, 2025
797ce54
remove distribution
hieuvubk Jan 31, 2025
67d9b00
update
hieuvubk Jan 31, 2025
492d5b0
remove allow new extension
hieuvubk Jan 31, 2025
8cd94d5
init supply
hieuvubk Jan 31, 2025
f2d7ba3
new image
hieuvubk Jan 31, 2025
d9e1986
update msgs.md
hieuvubk Jan 31, 2025
33a8b33
note
hieuvubk Jan 31, 2025
1b17d07
update the spec
catShaark Jan 31, 2025
b07b0f2
readme
hieuvubk Jan 31, 2025
409aa5c
Merge pull request #18 from decentrio/spec-update-hieu
hieuvubk Jan 31, 2025
fd8c617
base logic
hieuvubk Jan 31, 2025
8eb943d
precompiles
hieuvubk Jan 31, 2025
5cd7e5d
update spec
catShaark Feb 1, 2025
05875c4
Merge branch 'hieu/asset-module' into spec-update-2
catShaark Feb 1, 2025
b7965a4
Merge pull request #19 from decentrio/spec-update-2
catShaark Feb 1, 2025
d605b22
Update 02_state.md
catShaark Feb 1, 2025
9bc990c
Update 02_state.md
catShaark Feb 1, 2025
55fc974
Update 02_state.md
catShaark Feb 1, 2025
d38b45c
Update 04_msgs.md
catShaark Feb 1, 2025
383a9ce
Update README.md
catShaark Feb 1, 2025
0cf3400
setup test framework & test mint
hieuvubk Feb 4, 2025
cd74210
fix burn, burnFrom & test
hieuvubk Feb 6, 2025
8448f46
freeze logic
hieuvubk Feb 7, 2025
ca63777
clean up example chain
hieuvubk Feb 10, 2025
1b6c0ce
test transfer with freeze
hieuvubk Feb 10, 2025
c6c86fa
no need
hieuvubk Feb 10, 2025
6b39b76
remove distributor
hieuvubk Feb 10, 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 app/ante/handler_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (suite *AnteTestSuite) TestValidateHandlerOptions() {
SignModeHandler: encoding.MakeConfig().TxConfig.SignModeHandler(),
SigGasConsumer: evmosante.SigVerificationGasConsumer,
MaxTxGasWanted: 40000000,
TxFeeChecker: evmosanteevm.NewDynamicFeeChecker(suite.app.EvmKeeper),
TxFeeChecker: evmosanteevm.NewDynamicFeeChecker(suite.app.FeeMarketKeeper),
},
true,
},
Expand Down
4 changes: 2 additions & 2 deletions app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import (

"github.com/evmos/os/encoding"
"github.com/evmos/os/ethereum/eip712"
tests "github.com/evmos/os/testutil/tx"
"github.com/evmos/os/types"
evmtypes "github.com/evmos/os/x/evm/types"
tests "github.com/realiotech/realio-network/testutil/tx"

feemarkettypes "github.com/evmos/os/x/feemarket/types"

Expand Down Expand Up @@ -185,7 +185,7 @@ func (suite *AnteTestSuite) BuildTestEthTx(
gasTipCap *big.Int,
accesses *ethtypes.AccessList,
) *evmtypes.MsgEthereumTx {
chainID := suite.app.EvmKeeper.ChainID()
chainID := evmtypes.GetEthChainConfig().ChainID
nonce := suite.app.EvmKeeper.GetNonce(
suite.ctx,
common.BytesToAddress(from.Bytes()),
Expand Down
4 changes: 2 additions & 2 deletions app/mock_erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func NewEmptyMockErc20Keeper() MockErc20Keeper {

func (k MockErc20Keeper) GetERC20PrecompileInstance(ctx sdk.Context, addr common.Address) (contract vm.PrecompiledContract, found bool, err error) {
// Check if contract address in list
exist, err := k.assetKeeper.EVMContractExist(ctx, addr)
exist, denom, err := k.assetKeeper.EVMContractExist(ctx, addr)
if err != nil || !exist {
return nil, false, nil
}

precompile, err := erc20.NewPrecompile(addr, k.bankKeeper, k.authzKeeper, *k.transferKeeper, k.assetKeeper)
precompile, err := erc20.NewPrecompile(denom, addr, k.bankKeeper, k.authzKeeper, *k.transferKeeper, k.assetKeeper)
if err != nil {
return nil, false, nil
}
Expand Down
103 changes: 103 additions & 0 deletions example_chain/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/make -f

VERSION ?= $(shell echo $(shell git describe --tags --always) | sed 's/^v//')
TMVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
COMMIT := $(shell git log -1 --format='%H')
BINDIR ?= $(GOPATH)/bin
EXAMPLE_BINARY = osd
BUILDDIR ?= $(CURDIR)/build

export GO111MODULE = on

# Default target executed when no arguments are given to make.
default_target: all

.PHONY: default_target

# process build tags
build_tags = netgo

ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
build_tags += gcc
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

# process linker flags

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=os \
-X github.com/cosmos/cosmos-sdk/version.AppName=$(EXAMPLE_BINARY) \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(TMVERSION)

# DB backend selection
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif

# add build tags to linker flags
whitespace := $(subst ,, )
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
ldflags += -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"

ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
ldflags += -w -s
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
# check for nostrip option
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
BUILD_FLAGS += -trimpath
endif

# check if no optimization option is passed
# used for remote debugging
ifneq (,$(findstring nooptimization,$(COSMOS_BUILD_OPTIONS)))
BUILD_FLAGS += -gcflags "all=-N -l"
endif

# # The below include contains the tools and runsim targets.
# include contrib/devtools/Makefile

###############################################################################
### Build ###
###############################################################################

BUILD_TARGETS := build install

build: BUILD_ARGS=-o $(BUILDDIR)/
build-linux:
GOOS=linux GOARCH=amd64 $(MAKE) build

$(BUILD_TARGETS): go.sum $(BUILDDIR)/
CGO_ENABLED="1" go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./...

$(BUILDDIR)/:
mkdir -p $(BUILDDIR)/

distclean: clean tools-clean

clean:
rm -rf \
$(BUILDDIR)/ \
artifacts/ \
tmp-swagger-gen/

all: build

build-all: build lint test vulncheck

.PHONY: distclean clean build-all

###############################################################################
### Tools & Dependencies ###
###############################################################################

go.sum: go.mod
echo "Ensure dependencies have not been modified ..." >&2
go mod verify
go mod tidy
58 changes: 58 additions & 0 deletions example_chain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Example evmOS Chain

This directory contains an example chain that uses the evmOS modules.
It is based on the simapp implementation on the Cosmos SDK repository,
which itself is a simplified version of a Cosmos SDK-based blockchain.

This chain implementation is used to demonstrate the integration of evmOS
as well as to provide a chain object for testing purposes within the repository.

## Config

By default, this chain has the following configuration:

| Option | Value |
|---------------------|------------------------|
| Binary | `osd` |
| Chain ID | `os_9005-1` |
| Custom Opcodes | - |
| Default Token Pairs | 1 for the native token |
| Denomination | `aevmos` |
| EVM flavor | permissionless |
| Enabled Precompiles | all |

## Running The Chain

To run the example, execute the local node script found within this repository:

```bash
./local_node.sh [FLAGS]
```

Available flags are:

- `-y`: Overwrite previous database
- `-n`: Do **not** overwrite previous database
- `--no-install`: Skip installation of the binary
- `--remote-debugging`: Build a binary suitable for remote debugging

## Available Cosmos SDK Modules

As mentioned above, this exemplary chain implementation is a reduced version of `simapp`.
Specifically, instead of offering access to all Cosmos SDK modules, it just includes the following:

- `auth`
- `authz`
- `bank`
- `capability`
- `consensus`
- `distribution`
- `evidence`
- `feegrant`
- `genutil`
- `gov`
- `mint`
- `params`
- `slashing`
- `staking`
- `upgrade`
Loading
Loading