Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into estimate-gas
Browse files Browse the repository at this point in the history
  • Loading branch information
fedekunze authored Jul 17, 2021
2 parents b38f399 + 0a8f02e commit 3d06d8a
Show file tree
Hide file tree
Showing 10 changed files with 282 additions and 38 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release
# This workflow helps with creating releases.
# This job will only be triggered when a tag (vX.X.x) is pushed
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Go
uses: actions/[email protected]
with:
go-version: 1.16
- name: Unshallow
run: git fetch --prune --unshallow
- name: Create release
uses: goreleaser/[email protected]
with:
args: release --rm-dist --release-notes ./RELEASE_CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109 changes: 109 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
before:
hooks:
- go mod download

builds:
- id: "ethermintd-darwin"
main: ./cmd/ethermintd
binary: bin/ethermintd
env:
- CGO_ENABLED=1
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
flags:
- -tags=cgo
ldflags:
- -s -w -X github.com/cosmos/cosmos-sdk/version.Name=ethermint -X github.com/cosmos/cosmos-sdk/version.AppName=ethermintd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
- id: "ethermintd-darwin-arm64"
main: ./cmd/ethermintd
binary: bin/ethermintd
env:
- CGO_ENABLED=1
- CC=oa64-clang
- CXX=oa64-clang++
goos:
- darwin
goarch:
- arm64
flags:
- -tags=cgo
ldflags:
- -s -w -X github.com/cosmos/cosmos-sdk/version.Name=ethermint -X github.com/cosmos/cosmos-sdk/version.AppName=ethermintd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
- id: "ethermintd-linux"
main: ./cmd/ethermintd
binary: bin/ethermintd
env:
- CGO_ENABLED=1
- CC=gcc
- CXX=g++
goos:
- linux
goarch:
- amd64
flags:
- -tags=cgo
ldflags:
- -s -w -X github.com/cosmos/cosmos-sdk/version.Name=ethermint -X github.com/cosmos/cosmos-sdk/version.AppName=ethermintd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
- id: "ethermintd-linux-arm64"
main: ./cmd/ethermintd
binary: bin/ethermintd
env:
- CGO_ENABLED=1
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
goos:
- linux
goarch:
- arm64
flags:
- -tags=cgo
ldflags:
- -s -w -X github.com/cosmos/cosmos-sdk/version.Name=ethermint -X github.com/cosmos/cosmos-sdk/version.AppName=ethermintd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
- id: "ethermintd-windows"
main: ./cmd/ethermintd
binary: bin/ethermintd
env:
- CGO_ENABLED=1
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
flags:
- -tags=cgo
- -buildmode=exe
ldflags:
- -s -w -X github.com/cosmos/cosmos-sdk/version.Name=ethermint -X github.com/cosmos/cosmos-sdk/version.AppName=ethermintd -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}} -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}

archives:
- name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
replacements:
darwin: Darwin
linux: Linux
windows: Windows
amd64: x86_64
format_overrides:
- goos: windows
format: zip
builds:
- ethermintd-darwin
- ethermintd-darwin-arm64
- ethermintd-windows
- ethermintd-linux
- ethermintd-linux-arm64

checksum:
name_template: 'checksums.txt'
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
snapshot:
name_template: "{{ .Tag }}-next"
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -519,3 +519,36 @@ else
endif

.PHONY: build-docker-local-ethermint localnet-start localnet-stop

# release
PACKAGE_NAME:=github.com/tharsis/ethermint
GOLANG_CROSS_VERSION = v1.16.4
release-dry-run:
docker run \
--rm \
--privileged \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v ${GOPATH}/pkg:/go/pkg \
-w /go/src/$(PACKAGE_NAME) \
troian/golang-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate --skip-publish

release:
@if [ ! -f ".release-env" ]; then \
echo "\033[91m.release-env is required for release\033[0m";\
exit 1;\
fi
docker run \
--rm \
--privileged \
-e CGO_ENABLED=1 \
--env-file .release-env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
troian/golang-cross:${GOLANG_CROSS_VERSION} \
release --rm-dist --skip-validate

.PHONY: release-dry-run release
28 changes: 3 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ parent:
<a href="https://goreportcard.com/report/github.com/tharsis/ethermint">
<img alt="Go report card" src="https://goreportcard.com/badge/github.com/tharsis/ethermint"/>
</a>
<a href="https://bestpractices.coreinfrastructure.org/projects/5018">
<img src="https://bestpractices.coreinfrastructure.org/projects/5018/badge">
</a>
</div>
<div align="center">
<a href="https://discord.gg/AzefAFd">
Expand Down Expand Up @@ -49,31 +52,6 @@ To learn how the Ethermint works from a high-level perspective, go to the [Intro

For more, please refer to the [Ethermint Docs](./docs/), which are also hosted on [docs.ethermint.zone](https://docs.ethermint.zone/).

## Tests

Unit tests are invoked via:

```bash
make test
```

To run JSON-RPC tests, execute:

```bash
make test-rpc
```

There is also an included Ethereum mainnet exported blockchain file in `importer/blockchain`
that includes blocks up to height `97638`. To execute and test a full import of
these blocks using the EVM module, execute:

```bash
make test-import
```

You may also provide a custom blockchain export file to test importing more blocks
via the `--blockchain` flag. See `TestImportBlocks` for further documentation.

### Community

The following chat channels and forums are a great spot to ask questions about Ethermint:
Expand Down
5 changes: 0 additions & 5 deletions cmd/ethermintd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ var (
statsdAddress string
statsdStuckFunc string
evmDebug bool
logJSON bool
logLevel string
)

// addTxFlags adds common flags for commands to post tx
Expand All @@ -59,10 +57,7 @@ func addTxFlags(cmd *cobra.Command) *cobra.Command {
cmd.PersistentFlags().String(flags.FlagNode, "tcp://localhost:26657", "<host>:<port> to tendermint rpc interface for this chain")
cmd.PersistentFlags().Float64(flags.FlagGasAdjustment, flags.DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ")
cmd.PersistentFlags().StringP(flags.FlagBroadcastMode, "b", flags.BroadcastSync, "Transaction broadcasting mode (sync|async|block)")
cmd.PersistentFlags().BoolVar(&logJSON, "log-json", false, "Use JSON as the output format of the own logger (default: text)")
cmd.PersistentFlags().BoolVar(&evmDebug, "evm-debug", false, "Enable EVM debug traces")
cmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "Sets the level of the own logger (error, warn, info, debug)")
// cmd.PersistentFlags().Bool(flags.FlagTrustNode, true, "Trust connected full node (don't verify proofs for responses)")
cmd.PersistentFlags().String(flags.FlagKeyringBackend, keyring.BackendFile, "Select keyring's backend")

// --gas can accept integers and "simulate"
Expand Down
24 changes: 23 additions & 1 deletion ethereum/rpc/namespaces/eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ func (e *PublicAPI) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Ui

resBlock, err := e.clientCtx.Client.BlockByHash(e.ctx, hash.Bytes())
if err != nil {
e.logger.Debug("block not found", "hash", hash.Hex(), "error", err.Error())
return nil
}

if resBlock.Block == nil {
e.logger.Debug("block not found", "hash", hash.Hex())
return nil
}

Expand All @@ -282,9 +288,15 @@ func (e *PublicAPI) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Ui

// GetBlockTransactionCountByNumber returns the number of transactions in the block identified by number.
func (e *PublicAPI) GetBlockTransactionCountByNumber(blockNum rpctypes.BlockNumber) *hexutil.Uint {
e.logger.Debug("eth_getBlockTransactionCountByNumber", "block number", blockNum)
e.logger.Debug("eth_getBlockTransactionCountByNumber", "height", blockNum.Int64())
resBlock, err := e.clientCtx.Client.Block(e.ctx, blockNum.TmHeight())
if err != nil {
e.logger.Debug("block not found", "height", blockNum.Int64(), "error", err.Error())
return nil
}

if resBlock.Block == nil {
e.logger.Debug("block not found", "height", blockNum.Int64())
return nil
}

Expand Down Expand Up @@ -688,6 +700,11 @@ func (e *PublicAPI) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexu
return nil, nil
}

if resBlock.Block == nil {
e.logger.Debug("block not found", "hash", hash.Hex())
return nil, nil
}

i := int(idx)
if i >= len(resBlock.Block.Txs) {
e.logger.Debug("block txs index out of bound", "index", i)
Expand Down Expand Up @@ -726,6 +743,11 @@ func (e *PublicAPI) GetTransactionByBlockNumberAndIndex(blockNum rpctypes.BlockN
return nil, nil
}

if resBlock.Block == nil {
e.logger.Debug("block not found", "height", blockNum.Int64())
return nil, nil
}

i := int(idx)
if i >= len(resBlock.Block.Txs) {
e.logger.Debug("block txs index out of bound", "index", i)
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ require (
replace google.golang.org/grpc => google.golang.org/grpc v1.33.2

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

// FIXME: update after PR merged: https://github.com/bugsnag/panicwrap/pull/23
replace github.com/bugsnag/panicwrap => github.com/yihuang/panicwrap v1.3.4-0.20210716032932-61c0a7c0cd05
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46f
github.com/bugsnag/bugsnag-go v1.5.3/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
github.com/bugsnag/bugsnag-go v2.1.0+incompatible h1:SuqsBHDutts2rZh4swHEWTexxi0F/JZ/6j1rR9BFe7I=
github.com/bugsnag/bugsnag-go v2.1.0+incompatible/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
github.com/bugsnag/panicwrap v1.3.2 h1:pNcbtPtH4Y6VwK+oZVNV/2H6Hh3jOL0ZNVFZEfd/eA4=
github.com/bugsnag/panicwrap v1.3.2/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
Expand Down Expand Up @@ -1014,6 +1012,8 @@ github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:
github.com/xtaci/kcp-go v5.4.20+incompatible/go.mod h1:bN6vIwHQbfHaHtFpEssmWsN45a+AZwO7eyRCmEIbtvE=
github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae/go.mod h1:gXtu8J62kEgmN++bm9BVICuT/e8yiLI2KFobd/TRFsE=
github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE=
github.com/yihuang/panicwrap v1.3.4-0.20210716032932-61c0a7c0cd05 h1:pAujDEt8f+lZIOOfVXpkoMemkOi0e6On1aaZWK4dxSM=
github.com/yihuang/panicwrap v1.3.4-0.20210716032932-61c0a7c0cd05/go.mod h1:AeUysGSIOPvhV1BZNplN56n5EEm3YfgYc/X3mhpjRiA=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
13 changes: 8 additions & 5 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
KEY="mykey"
CHAINID="ethermint-2"
MONIKER="localtestnet"
KEYRING="test"
KEYALGO="eth_secp256k1"
LOGLEVEL="info"

# remove existing daemon and client
rm -rf ~/.ethermintd*

make install

ethermintd config keyring-backend test
ethermintd config keyring-backend $KEYRING
ethermintd config chain-id $CHAINID

# if $KEY exists it should be deleted
ethermintd keys add $KEY --keyring-backend test --algo "eth_secp256k1"
ethermintd keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO

# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
ethermintd init $MONIKER --chain-id $CHAINID
Expand Down Expand Up @@ -58,10 +61,10 @@ if [[ $1 == "pending" ]]; then
fi

# Allocate genesis accounts (cosmos formatted addresses)
ethermintd add-genesis-account $KEY 100000000000000000000000000aphoton --keyring-backend test
ethermintd add-genesis-account $KEY 100000000000000000000000000aphoton --keyring-backend $KEYRING

# Sign genesis transaction
ethermintd gentx $KEY 1000000000000000000000aphoton --keyring-backend test --chain-id $CHAINID
ethermintd gentx $KEY 1000000000000000000000aphoton --keyring-backend $KEYRING --chain-id $CHAINID

# Collect genesis tx
ethermintd collect-gentxs
Expand All @@ -74,4 +77,4 @@ if [[ $1 == "pending" ]]; then
fi

# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
ethermintd start --pruning=nothing --trace --log_level info --minimum-gas-prices=0.0001aphoton
ethermintd start --pruning=nothing --trace --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton
Loading

0 comments on commit 3d06d8a

Please sign in to comment.