Skip to content

Commit

Permalink
Merge pull request #197 from aura-nw/euphoria
Browse files Browse the repository at this point in the history
Merge from Euphoria
  • Loading branch information
kienvc authored May 23, 2024
2 parents abe5d81 + e49a285 commit 447c7da
Show file tree
Hide file tree
Showing 151 changed files with 50,272 additions and 856 deletions.
2 changes: 1 addition & 1 deletion .VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.7.3
v0.8.1
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: '1.20'
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
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 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: '1.20'

- name: Build
run: go build -v ./...
Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ Ref: https://keepachangelog.com/en/1.0.0/

## Unreleased

## [v0.7.3] - 2024-01-18
## [v0.8.1] - 2024-05-22
### Improvements
- Clean unused code in evmutil module
- Adapt Evmos precompiles

## [v0.8.0] - 2024-04-06
### Features
- Add EVM module

## [v0.7.2] - 2024-01-18

### Improvements
- Enhance flow of post handle verify tx from smart account module
- Bump wasmd version to v0.42.0 to support long term
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ BUILD_FLAGS := -tags "$(BUILD_TAGS)" -ldflags '$(ldflags)' -trimpath
GO_MAJOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1
MINIMUM_SUPPORTED_GO_MINOR_VERSION = 19
MINIMUM_SUPPORTED_GO_MINOR_VERSION = 20
GO_VERSION_VALIDATION_ERR_MSG = Golang version is not supported, please update to at least $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION).$(MINIMUM_SUPPORTED_GO_MINOR_VERSION)

GORELEASER_VERSION = v1.20.0
Expand Down
57 changes: 45 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,95 @@
# Aura

[![Release](https://github.com/aura-nw/aura/actions/workflows/release.yml/badge.svg?branch=main)](https://github.com/aura-nw/aura/actions/workflows/release.yml)

This repository contains source code for Aurad (Aura Daemon). Aurad binary is the official client for Aura Network. Aurad is built using Cosmos SDK

Aura Network is a NFT-centric blockchain platform that provides infrastructure assisting to bring user assets to the crypto market.

## Prerequisite
- Go 1.18

- Go 1.20

## Install Aura daemon

Using Makefile
```

```bash
make
```
The **aurad** bin file is located on **${source_directory}/build/** or **GO_PATH** (default ~/go/bin/)

The **aurad** bin file is located on **${source_directory}/build/** or **GO_PATH** (default ~/go/bin/)

## Setup a LocalNet

### Initialize the Chain
```

```bash
# <moniker> is the custom username of the node
# <chain-id> is the identity of the chain
aurad init <moniker> --chain-id <chain-id>
```

This command will initialize the home folder containing necessary components for your chain
(default: ~/.aura)

### Customize the genesis file

A genesis file is a JSON file which defines the initial state of your blockchain. It can be seen as height 0 of your blockchain. The first block, at height 1, will reference the genesis file as its parent.

The docs about genesis customization: https://hub.cosmos.network/main/resources/genesis.html
The docs about genesis customization: <https://hub.cosmos.network/main/resources/genesis.html>

### Create your validator

Create a local key pair for creating validator:
```

```bash
aurad keys add <key_name>
```

Add some tokens to the wallet:
```

```bash
aurad add-genesis-account <key_name> <amount><denom>
```

Create a validtor generation transaction:
```

```bash
aurad gentx <key_name> <amount><denom> --chain-id <chain-id>
```

Collect the gentx to genesis file:
```

```bash
aurad collect-gentxs
```

### Run a node
```

```bash
aurad start
```

## Run a local test node

```bash
sh scripts/testnode.sh
```

## Setup testnet using testnetCmd

## Contribution
The Aurad is still in development by the Aura Network team. For more information on how to contribute to this project, please contact us at [email protected]

The Aurad is still in development by the Aura Network team. For more information on how to contribute to this project, please contact us at <[email protected]>

## License
Aurad project source code files are made available under Apache-2.0 License, located in the LICENSE file. Basically, you can do whatever you want as long as you include the original copyright and license notice in any copy of the software/source.

Aura project source code files are made available under Apache-2.0 License, located in the LICENSE file. Basically, you can do whatever you want as long as you include the original copyright and license notice in any copy of the software/source.

## Acknowledgments

Aura project is built using [Cosmos SDK](https://github.com/cosmos/cosmos-sdk) and uses additional modules:
- ```github.com/evmos/evmos/v16``` by Tharsis Labs Ltd.(Evmos). This EVM library is distributed under [ENCL-1.0](https://github.com/evmos/evmos/blob/v16.0.3/LICENSE).

- ```x/evmutil``` by Kava Labs, Inc. This module is distributed under [Apache v2 License](https://github.com/Kava-Labs/kava/blob/master/LICENSE.md).
129 changes: 107 additions & 22 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
package app

import (
"fmt"

errorsmod "cosmossdk.io/errors"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
smartaccountkeeper "github.com/aura-nw/aura/x/smartaccount/keeper"
"github.com/spf13/cast"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"

ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
keeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

// ethermint ante
sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
evmosante "github.com/evmos/evmos/v16/app/ante"
cosmosante "github.com/evmos/evmos/v16/app/ante/cosmos"
"github.com/evmos/evmos/v16/app/ante/evm"
evmante "github.com/evmos/evmos/v16/app/ante/evm"
evmostypes "github.com/evmos/evmos/v16/types"
evmtypes "github.com/evmos/evmos/v16/x/evm/types"

// stargazeante "github.com/public-awesome/stargaze/v4/internal/ante"
smartaccount "github.com/aura-nw/aura/x/smartaccount"
smartaccountkeeper "github.com/aura-nw/aura/x/smartaccount/keeper"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
Expand All @@ -24,42 +39,109 @@ type HandlerOptions struct {
ante.HandlerOptions
WasmKeeper wasmkeeper.Keeper
SmartAccountKeeper smartaccountkeeper.Keeper
IBCKeeper *keeper.Keeper
IBCKeeper *ibckeeper.Keeper
WasmConfig *wasmTypes.WasmConfig
TXCounterStoreKey storetypes.StoreKey
Codec codec.BinaryCodec
EvmKeeper evm.EVMKeeper
FeeMarketKeeper evm.FeeMarketKeeper
}

// NewAnteHandler returns an AnteHandler that checks and increments sequence
// numbers, checks signatures & account numbers, and deducts fees from the first
// signer.
func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder")
}
func (app *App) NewAnteHandler(txConfig client.TxConfig, wasmConfig wasmTypes.WasmConfig, wasmKey storetypes.StoreKey) (sdk.AnteHandler, error) {
// return auraAnteHandler(options)
return func(
ctx sdk.Context, tx sdk.Tx, sim bool,
) (newCtx sdk.Context, err error) {
var anteHandler sdk.AnteHandler

if options.BankKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder")
}
ext, ok := tx.(authante.HasExtensionOptionsTx)
opts := ext.GetExtensionOptions()
if ok && len(opts) > 0 {
// TODO: add config for max gas wanted
ctx.Logger().Info(fmt.Sprintf("tx: %v", tx))
maxGasWanted := cast.ToUint64(100000000)
var evmosoptions = evmosante.HandlerOptions{
Cdc: app.appCodec,
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
ExtensionOptionChecker: evmostypes.HasDynamicFeeExtensionOption,
EvmKeeper: app.EvmKeeper,
StakingKeeper: app.StakingKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
DistributionKeeper: app.DistrKeeper, // what is this
IBCKeeper: app.IBCKeeper,
FeeMarketKeeper: app.FeeMarketKeeper,
SignModeHandler: txConfig.SignModeHandler(),
SigGasConsumer: evmosante.SigVerificationGasConsumer,
MaxTxGasWanted: maxGasWanted,
TxFeeChecker: evmante.NewDynamicFeeChecker(app.EvmKeeper),
}
anteHandler = evmosante.NewAnteHandler(evmosoptions)
return anteHandler(ctx, tx, sim)
}

if options.SignModeHandler == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
}
// handle as totally normal Cosmos SDK tx
switch tx.(type) {
case sdk.Tx:
var options = HandlerOptions{
HandlerOptions: ante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
SignModeHandler: txConfig.SignModeHandler(),
FeegrantKeeper: app.FeeGrantKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer},
WasmKeeper: app.WasmKeeper,
SmartAccountKeeper: app.SaKeeper,
IBCKeeper: app.IBCKeeper,
WasmConfig: &wasmConfig,
TXCounterStoreKey: wasmKey,
Codec: app.appCodec,
}
anteHandler = auraAnteHandler(options)
default:
return ctx, errorsmod.Wrapf(errortypes.ErrUnknownRequest, "invalid transaction type: %T", tx)
}

if options.WasmConfig == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder")
}
return anteHandler(ctx, tx, sim)
}, nil
}

if options.TXCounterStoreKey == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder")
}
func auraAnteHandler(options HandlerOptions) sdk.AnteHandler {
// if options.AccountKeeper == nil {
// return nil, errorsmod.Wkrap(sdkerrors.ErrLogic, "account keeper is required for ante builder")
// }

// if options.BankKeeper == nil {
// return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder")
// }

// if options.SignModeHandler == nil {
// return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
// }

// if options.WasmConfig == nil {
// return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder")
// }

// if options.TXCounterStoreKey == nil {
// return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder")
// }

var sigGasConsumer = options.SigGasConsumer
if sigGasConsumer == nil {
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
}

anteDecorators := []sdk.AnteDecorator{
cosmosante.RejectMessagesDecorator{}, // reject MsgEthereumTx
cosmosante.NewAuthzLimiterDecorator( // disable the Msg types that cannot be included on an authz.MsgExec msgs field
sdk.MsgTypeURL(&evmtypes.MsgEthereumTx{}),
sdk.MsgTypeURL(&sdkvesting.MsgCreateVestingAccount{}),
),

ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
// limit simulation gas
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit),
Expand All @@ -82,7 +164,10 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
smartaccount.NewValidateAuthzTxDecorator(options.SmartAccountKeeper),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),

// ethermint ante
// evmante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),
}

return sdk.ChainAnteDecorators(anteDecorators...), nil
return sdk.ChainAnteDecorators(anteDecorators...)
}
Loading

0 comments on commit 447c7da

Please sign in to comment.