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

evm rpc update release v0.9.1 #219

Merged
merged 33 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6a68989
Merge pull request #139 from stratosnet/release
jinzuo-qsn Mar 21, 2022
3e3a089
fix query total ozone supply
alexstratos Mar 21, 2022
48e571d
Merge pull request #140 from stratosnet/hotfix/query-total-ozone
alexstratos Mar 21, 2022
1a1db22
Merge pull request #169 from stratosnet/release
jinzuo-qsn Jul 22, 2022
6c28e86
doc/update README.md
hong-pang Jul 22, 2022
9f9eec0
Merge pull request #170 from stratosnet/hong-pang-patch-1
alexstratos Jul 24, 2022
16ca882
QB-1532 Add Dockerfile for integration test
Jan 16, 2023
6b3207e
Merge branch 'main' into fix/merge-conflicts-for-hotfix
alexstratos Jan 17, 2023
2857608
Merge pull request #198 from stratosnet/fix/merge-conflicts-for-hotfix
jinzuo-qsn Jan 17, 2023
74f7ba4
Update README.md
hong-pang Jan 17, 2023
400f57b
Merge pull request #199 from stratosnet/update-tropos-5
alexstratos Jan 17, 2023
a0bf29a
add uid and gid args
Jan 18, 2023
e439d8e
Merge pull request #200 from stratosnet/main
jinzuo-qsn Jan 19, 2023
bf66b06
Optimize queries
Xiong-stratos Jan 19, 2023
f9a6b69
- qb1586: fix improper error handling in pot/endBlocker to print deta…
jialbai Jan 20, 2023
5fb27c1
fix: gwei denom not working with gas-price flag
Xiong-stratos Jan 20, 2023
cc6d6f0
chore/QB-1578 Update btcd dependencies
mdumais-stratos Jan 20, 2023
7e7d421
chore/QB-1578 fix go-ethereum update
mdumais-stratos Jan 24, 2023
95772e1
- qb1596: fix eaten error in some rare cases during prepay
jialbai Jan 24, 2023
747791e
Merge pull request #205 from stratosnet/chore/QB-1578_fix_dependency_…
jinzuo-qsn Jan 24, 2023
e256e0b
Merge pull request #206 from stratosnet/qb1596_fix-eaten-err-in-rare-…
jinzuo-qsn Jan 24, 2023
974d765
Merge pull request #203 from stratosnet/qb1586_fix-pot-endblocker-err…
jinzuo-qsn Jan 24, 2023
87d16c8
Merge pull request #201 from stratosnet/QB-1577_optimize_queries
jinzuo-qsn Jan 24, 2023
4c76be4
Merge pull request #196 from stratosnet/QB-1532.integration.test
alexstratos Jan 27, 2023
b36d134
updatestake to restore sp's ppstore
WangLiStratos Jan 27, 2023
5578b44
test/QB-1603 Fix unit tests
mdumais-stratos Jan 30, 2023
31fdb88
test/QB-1603 remove push trigger
mdumais-stratos Jan 31, 2023
33d1715
Merge pull request #202 from stratosnet/qb1582_gas-prices_flag_suppor…
alexstratos Jan 31, 2023
393398c
Merge pull request #208 from stratosnet/QB-1573_refactor_pp_fsm
alexstratos Jan 31, 2023
56f181f
Merge pull request #213 from stratosnet/test/QB-1603_fix_unit_tests
alexstratos Jan 31, 2023
2856820
QB-1574: update to TM calls, refactor ws (#211)
BoThe1K Feb 13, 2023
7681d40
bump version to v0.9.1
alexstratos Feb 13, 2023
6285455
attribute current stake is not added now (#220)
WangLiStratos Feb 13, 2023
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
23 changes: 23 additions & 0 deletions .github/workflows/pull-request
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Go

on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
branches: [main, release, dev]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Build
run: go build -v ./...

- name: Test
run: go test ./...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ vendor/
playground.go
/tmp-swagger-gen/
/github.com/
.DS_Store
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
BUILDDIR ?= $(CURDIR)/build

APP_VER := v0.9.0
APP_VER := v0.9.1
COMMIT := $(GIT_COMMIT_HASH)
TEST_DOCKER_REPO=stratos-chain-e2e

ifeq ($(COMMIT),)
VERSION := $(APP_VER)
Expand Down Expand Up @@ -37,6 +38,12 @@ build-windows: go.sum
clean:
rm -rf $(BUILDDIR)/

coverage:
go test ./... -coverprofile cover.out -coverpkg=./...
go tool cover -html cover.out -o cover.html
go tool cover -func cover.out | grep total:
rm cover.out

###############################################################################
### Localnet ###
###############################################################################
Expand All @@ -54,4 +61,9 @@ localnet-start: build-linux localnet-stop
localnet-stop:
docker-compose down

build-docker-e2e:
@docker build -f tests/e2e/Dockerfile -t ${TEST_DOCKER_REPO}:$(shell git rev-parse --short HEAD) --build-arg uid=$(shell id -u) --build-arg gid=$(shell id -g) .
@docker tag ${TEST_DOCKER_REPO}:$(shell git rev-parse --short HEAD) ${TEST_DOCKER_REPO}:$(shell git rev-parse --abbrev-ref HEAD | sed 's#/#_#g')
@docker tag ${TEST_DOCKER_REPO}:$(shell git rev-parse --short HEAD) ${TEST_DOCKER_REPO}:latest

.PHONY: build-linux build-mac build clean
94 changes: 22 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,85 +20,26 @@
- <b>Software(tested version)</b>

* Ubuntu 18.04+
* Go 1.16+ linux/amd64
* Go 1.18+ linux/amd64


- <b>Platform</b>

* Linux(tested on Ubuntu18.04 and 20.04)
* Mac OS
* Windows
* Linux(tested on Ubuntu18.04 and 20.04)
* Mac OS
* Windows

It is possible to build and run the software on Windows. However, we did not test it on Windows completely.
It may give you unexpected results, or it may require additional setup.
It is possible to build and run the software on Windows. However, we did not test it on Windows completely.
It may give you unexpected results, or it may require additional setup.

An alternative option is to install a separate virtual Linux system using [VirtualBox](https://www.virtualbox.org/wiki/Downloads) or [VMware Workstation](https://www.vmware.com/ca/products/workstation-player/workstation-player-evaluation.html)

--- ---

## Executables

The `Stratos-Chain` comes with 2 types of executables that can be found in `stratos/stratos-chain/build` directory.

| Command | Description |
| :-----------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `stchaincli` | the client end. It is the command line interface for interacting with `stchaind`. It is the entry point into the Stratos network (main-, test- or private net), capable of running as a full node (default), archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Stratos network via JSON RPC endpoints. |
| `stchaind` | the app Daemon (server)|


### `stchaincli`

```
Usage:
stchaincli [command]

Available Commands:
status Query remote node for status
config Create or query an application CLI configuration file
query Querying subcommands
tx Transactions subcommands
rest-server Start LCD (light-client daemon), a local REST server
keys Add or view local private keys
version Print the app version
help Help about any command
```

Each `stchaincli` command may contain a set of flags or parameters. for more details, please refer to [Stratos Chain `stchaincli` Commands(Part1)](https://github.com/stratosnet/stratos-chain/wiki/Stratos-Chain-%60stchaincli%60-Commands(Part1)) and [Stratos Chain `stchaincli` Commands(Part2)](https://github.com/stratosnet/stratos-chain/wiki/Stratos-Chain-%60stchaincli%60-Commands(Part2))

### `stchaind`

```
Usage:
stchaind [command]

Available Commands:
init Initialize private validator, p2p, genesis, and application configuration files
collect-gentxs Collect genesis txs and output a genesis.json file
migrate Migrate genesis to a specified target version
gentx Generate a genesis tx carrying a self delegation
validate-genesis validates the genesis file at the default location or at the location passed as an arg
add-genesis-account Add a genesis account to genesis.json
faucet Run a faucet cmd
debug Tool for helping with debugging your application
start Run the full node
unsafe-reset-all Resets the blockchain database, removes address book files, and resets priv_validator.json to the genesis state
tendermint Tendermint subcommands
export Export state to JSON
version Print the app version
help Help about any command
```

Each `stchaind` command may contain a set of flags or parameters. for more details, please refer to [Stratos-chain `stchaind` Commands](https://github.com/stratosnet/stratos-chain/wiki/Stratos-Chain-%60stchaind%60-Commands)
An alternative option is to install a separate virtual Linux system using [VirtualBox](https://www.virtualbox.org/wiki/Downloads) or [VMware Workstation](https://www.vmware.com/ca/products/workstation-player/workstation-player-evaluation.html)

--- ---

## Connect to `Stratos` Network

Going through all the possible command line flags is out of scope here,
but we've enumerated a few common parameter combos to get you up to speed quickly on how you can run your own `Stratos` instance.

### A Full node on the test Stratos network
For prerequisites and detailed instructions of connecting to `Tropos Incentive Testnet` network, please read the [Tropos Incentive Testnet](https://github.com/stratosnet/sds/wiki/Tropos-Incentive-Testnet).
For prerequisites and detailed instructions of connecting to `Tropos Incentive Testnet` network, please refer to [Tropos Incentive Testnet](https://github.com/stratosnet/sds/wiki/Tropos-Incentive-Testnet).

### Full node on the main Stratos network - TBA
Prerequisites and detailed instructions of main network will be added later.
Expand All @@ -113,17 +54,26 @@ Prerequisites and detailed instructions of main network will be added later.

## References

* [`stchaincli` Commands(Part1)](https://github.com/stratosnet/stratos-chain/wiki/Stratos-Chain-%60stchaincli%60-Commands(Part1))
<details>
<summary><b><code>Stratos-chain</code> document List</b></summary>

* [`stchaincli` Commands(Part2)](https://github.com/stratosnet/stratos-chain/wiki/Stratos-Chain-%60stchaincli%60-Commands(Part2))
<br>

* [`stchaind` Commands](https://github.com/stratosnet/stratos-chain/wiki/Stratos-Chain-%60stchaind%60-Commands)
* [Tropos Incentive Testnet](https://github.com/stratosnet/sds/wiki/Tropos-Incentive-Testnet)

* ['stchaind' Commands(part1)](https://github.com/stratosnet/stratos-chain/wiki/Stratos-Chain-%60stchaind%60-Commands(part1))

* [stchaind' Commands(part2)](https://github.com/stratosnet/stratos-chain/wiki/Stratos-Chain-%60stchaind%60-Commands(part2))

* [gRPC Queries](https://github.com/stratosnet/stratos-chain/wiki/Stratos-Chain-gRPC-Queries)

* [REST APIs](https://github.com/stratosnet/stratos-chain/wiki/Stratos-Chain-REST-APIs)

* [How to become a validator](https://github.com/stratosnet/stratos-chain/wiki/How-to-Become-a-Validator)

* [`ppd terminal` subcommands](https://github.com/stratosnet/sds/wiki/%60ppd-terminal%60--subcommands)
* [`ppd terminal` subcommand](https://github.com/stratosnet/sds/wiki/%60ppd-terminal%60--subcommands)

</details>

--- ---

Expand All @@ -149,7 +99,7 @@ Please make sure your contributions adhere to our coding guidelines:

## License

Copyright 2022 Stratos
Copyright 2023 Stratos

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
35 changes: 35 additions & 0 deletions app/ante/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,41 @@ import (
evmtypes "github.com/stratosnet/stratos-chain/x/evm/types"
)

// EthTxPayloadVerificationDecorator validates base tx payload and check some limitations
type EthTxPayloadVerificationDecorator struct {
}

func NewEthTxPayloadVerificationDecorator() EthTxPayloadVerificationDecorator {
return EthTxPayloadVerificationDecorator{}
}

// AnteHandle validates msgs count, some signature protection and applied limitations
func (tpvd EthTxPayloadVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
if len(tx.GetMsgs()) > 1 {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "evm transactions only operates with 1 msg")
}

for _, msg := range tx.GetMsgs() {
msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx)
if !ok {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil))
}

ethTx := msgEthTx.AsTransaction()
// EIP-155 only allowed
if !ethTx.Protected() {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrNotSupported, "legacy pre-eip-155 transactions not supported")
}

// forbid EIP-2930 update with access list
if len(ethTx.AccessList()) > 0 {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrNotSupported, "eip-2930 transactions not supported")
}
}

return next(ctx, tx, simulate)
}

// EthSigVerificationDecorator validates an ethereum signatures
type EthSigVerificationDecorator struct {
evmKeeper EVMKeeper
Expand Down
149 changes: 149 additions & 0 deletions app/ante/fee.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package ante

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)

// MempoolFeeDecorator will check if the transaction's fee is at least as large
// as the local validator's minimum gasFee (defined in validator config).
// If fee is too low, decorator returns error and tx is rejected from mempool.
// Note this only applies when ctx.CheckTx = true
// If fee is high enough or not CheckTx, then call next AnteHandler
// CONTRACT: Tx must implement FeeTx to use MempoolFeeDecorator
type MempoolFeeDecorator struct{}

func NewMempoolFeeDecorator() MempoolFeeDecorator {
return MempoolFeeDecorator{}
}

func (mfd MempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
feeTx, ok := tx.(sdk.FeeTx)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
}

feeCoins, err := sdk.ParseCoinsNormalized(feeTx.GetFee().String())
if err != nil {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "fee parsing error: %s", feeCoins)
}
gas := feeTx.GetGas()

// Ensure that the provided fees meet a minimum threshold for the validator,
// if this is a CheckTx. This is only for local mempool purposes, and thus
// is only ran on check tx.
if ctx.IsCheckTx() && !simulate {
minGasPrices := ctx.MinGasPrices()
if !minGasPrices.IsZero() {
requiredFees := make(sdk.Coins, len(minGasPrices))

// Determine the required fees by multiplying each required minimum gas
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
glDec := sdk.NewDec(int64(gas))
for i, gp := range minGasPrices {
fee := gp.Amount.Mul(glDec)
requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt())
}

if !feeCoins.IsAnyGTE(requiredFees) {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
}
}
}

return next(ctx, tx, simulate)
}

// DeductFeeDecorator deducts fees from the first signer of the tx
// If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error
// Call next AnteHandler if fees successfully deducted
// CONTRACT: Tx must implement FeeTx interface to use DeductFeeDecorator
type DeductFeeDecorator struct {
ak AccountKeeper
bankKeeper types.BankKeeper
feegrantKeeper FeegrantKeeper
}

func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper) DeductFeeDecorator {
return DeductFeeDecorator{
ak: ak,
bankKeeper: bk,
feegrantKeeper: fk,
}
}

func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
feeTx, ok := tx.(sdk.FeeTx)
if !ok {
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
}

if addr := dfd.ak.GetModuleAddress(types.FeeCollectorName); addr == nil {
return ctx, fmt.Errorf("fee collector module account (%s) has not been set", types.FeeCollectorName)
}

fee, err := sdk.ParseCoinsNormalized(feeTx.GetFee().String())
if err != nil {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "fee parsing error: %s", fee)
}
feePayer := feeTx.FeePayer()
feeGranter := feeTx.FeeGranter()

deductFeesFrom := feePayer

// if feegranter set deduct fee from feegranter account.
// this works with only when feegrant enabled.
if feeGranter != nil {
if dfd.feegrantKeeper == nil {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "fee grants are not enabled")
} else if !feeGranter.Equals(feePayer) {
err := dfd.feegrantKeeper.UseGrantedFees(ctx, feeGranter, feePayer, fee, tx.GetMsgs())
if err != nil {
return ctx, sdkerrors.Wrapf(err, "%s not allowed to pay fees from %s", feeGranter, feePayer)
}
}

deductFeesFrom = feeGranter
}

deductFeesFromAcc := dfd.ak.GetAccount(ctx, deductFeesFrom)
if deductFeesFromAcc == nil {
return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", deductFeesFrom)
}

// deduct the fees
if !fee.IsZero() {
err = DeductFees(dfd.bankKeeper, ctx, deductFeesFromAcc, fee)
if err != nil {
return ctx, err
}
}

events := sdk.Events{
sdk.NewEvent(
sdk.EventTypeTx,
sdk.NewAttribute(sdk.AttributeKeyFee, fee.String()),
sdk.NewAttribute(sdk.AttributeKeyFeePayer, deductFeesFrom.String()),
),
}
ctx.EventManager().EmitEvents(events)

return next(ctx, tx, simulate)
}

// DeductFees deducts fees from the given account.
func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI, fees sdk.Coins) error {
if !fees.IsValid() {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees)
}

err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.FeeCollectorName, fees)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error())
}

return nil
}
Loading