Skip to content

Commit

Permalink
Merge branch 'dev' into committer-module
Browse files Browse the repository at this point in the history
  • Loading branch information
Stonepapa authored Feb 26, 2024
2 parents 159eed2 + b22833d commit 9557684
Show file tree
Hide file tree
Showing 129 changed files with 29,135 additions and 131 deletions.
3 changes: 2 additions & 1 deletion .gitleaks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ paths = [
'''(go.mod|go.sum)$''',
'''node_modules''',
'''vendor''',
'''init.sh'''
'''init.sh''',
'''init.bat'''
]

[[rules]]
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ WORKDIR /
# Copy over binaries from the build-env
COPY --from=build-env /go/src/github.com/evmos/ethermint/build/ethermintd /usr/bin/ethermintd

EXPOSE 26656 26657 9090 1317 8545 8546

# Run ethermintd by default
CMD ["ethermintd","start"]
35 changes: 27 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ benchmark:
### Linting ###
###############################################################################

lint-all: lint yaml-lint markdown-lint dockerfile-lint gosec lint-cosmos-gosec proto-lint

lint:
@@test -n "$$golangci-lint version | awk '$4 >= 1.42')"
golangci-lint run --out-format=tab -n
Expand All @@ -385,6 +387,23 @@ format-fix:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' -not -name '*.pb.gw.go' | xargs misspell -w
.PHONY: format

lint-cosmos-gosec:
gosec -include=G701,G703,G704 ./...

gosec:
gosec -exclude-dir=localnet* ./...
.PHONY: gosec lint-cosmos-gosec

yaml-lint:
yamllint -c .yamllint -s .

markdown-lint:
markdownlint -c .markdownlint.yml .

dockerfile-lint:
hadolint Dockerfile
.PHONY: yaml-lint markdown-lint dockerfile-lint

###############################################################################
### Protobuf ###
###############################################################################
Expand Down Expand Up @@ -454,20 +473,20 @@ proto-check-breaking:
localnet-build:
@$(MAKE) -C networks/local

# Generate 4 nodes config
localnet-config:
@bash ./init-multi-nodes.sh

# Start a 4-node testnet locally
localnet-start: localnet-stop
ifeq ($(OS),Windows_NT)
mkdir localnet-setup &
@$(MAKE) localnet-build

IF not exist "build/node0/$(ETHERMINT_BINARY)/config/genesis.json" docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "./ethermintd testnet --v 4 -o /ethermint --keyring-backend=test --ip-addresses ethermintdnode0,ethermintdnode1,ethermintdnode2,ethermintdnode3"
docker-compose up -d
IF not exist "build/node0/$(ETHERMINT_BINARY)/config/genesis.json" docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "/usr/bin/ethermintd testnet init-files --v 4 -o /ethermint --keyring-backend=test --starting-ip-address 192.167.10.2"
docker-compose -f networks/local/ethermintnode/docker-compose.yml up -d
else
mkdir -p localnet-setup
@$(MAKE) localnet-build

if ! [ -f localnet-setup/node0/$(ETHERMINT_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/localnet-setup:/ethermint:Z ethermintd/node "./ethermintd testnet --v 4 -o /ethermint --keyring-backend=test --ip-addresses ethermintdnode0,ethermintdnode1,ethermintdnode2,ethermintdnode3"; fi
docker-compose up -d
if ! [ -f build/node0/$(ETHERMINT_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/ethermint:Z ethermintd/node "/usr/bin/ethermintd testnet init-files --v 4 -o /ethermint --keyring-backend=test --starting-ip-address 192.167.10.2"; fi
docker-compose -f networks/local/ethermintnode/docker-compose.yml up -d
endif

# Stop testnet
Expand Down
45 changes: 44 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ import (
"os"
"path/filepath"

"github.com/cosmos/cosmos-sdk/x/group"
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
bridgemoduletypes "github.com/evmos/ethermint/x/bridge/types"

"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
Expand Down Expand Up @@ -125,6 +130,8 @@ import (
"github.com/evmos/ethermint/ethereum/eip712"
srvflags "github.com/evmos/ethermint/server/flags"
ethermint "github.com/evmos/ethermint/types"
"github.com/evmos/ethermint/x/bridge"
bridgemodulekeeper "github.com/evmos/ethermint/x/bridge/keeper"
"github.com/evmos/ethermint/x/evm"
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
evmtypes "github.com/evmos/ethermint/x/evm/types"
Expand Down Expand Up @@ -174,6 +181,7 @@ var (
ibc.AppModuleBasic{},
authzmodule.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
groupmodule.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
Expand All @@ -183,6 +191,7 @@ var (
feemarket.AppModuleBasic{},
// Committer module
committer.AppModuleBasic{},
bridge.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -235,6 +244,7 @@ type EthermintApp struct {
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
EvidenceKeeper evidencekeeper.Keeper
Expand All @@ -249,6 +259,7 @@ type EthermintApp struct {
FeeMarketKeeper feemarketkeeper.Keeper
// Committer keeper
CommitterKeeper *committerkeeper.Keeper
BridgeKeeper bridgemodulekeeper.Keeper

// the module manager
mm *module.Manager
Expand Down Expand Up @@ -296,11 +307,12 @@ func NewEthermintApp(
evidencetypes.StoreKey, capabilitytypes.StoreKey,
feegrant.StoreKey, authzkeeper.StoreKey,
// ibc keys
ibchost.StoreKey, ibctransfertypes.StoreKey,
ibchost.StoreKey, ibctransfertypes.StoreKey, group.StoreKey,
// ethermint keys
evmtypes.StoreKey, feemarkettypes.StoreKey,
// committer key
committertypes.StoreKey,
evmtypes.StoreKey, feemarkettypes.StoreKey, bridgemoduletypes.StoreKey,
)

// Add the EVM transient store key
Expand Down Expand Up @@ -378,6 +390,18 @@ func NewEthermintApp(
&stakingKeeper,
authtypes.FeeCollectorName,
)
groupConfig := group.DefaultConfig()
/*
Example of setting group params:
groupConfig.MaxMetadataLen = 1000
*/
app.GroupKeeper = groupkeeper.NewKeeper(
keys[group.StoreKey],
appCodec,
app.MsgServiceRouter(),
app.AccountKeeper,
groupConfig,
)
app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec,
keys[slashingtypes.StoreKey],
Expand Down Expand Up @@ -468,6 +492,16 @@ func NewEthermintApp(
),
)

app.BridgeKeeper = *bridgemodulekeeper.NewKeeper(
appCodec,
keys[bridgemoduletypes.StoreKey],
keys[bridgemoduletypes.MemStoreKey],
app.GetSubspace(bridgemoduletypes.ModuleName),

app.GroupKeeper,
)
bridgeModule := bridge.NewAppModule(appCodec, app.BridgeKeeper, app.AccountKeeper, app.BankKeeper)

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
Expand Down Expand Up @@ -508,6 +542,7 @@ func NewEthermintApp(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
Expand All @@ -527,6 +562,7 @@ func NewEthermintApp(
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmSs),
// Committer module
committer.NewAppModule(appCodec, *app.CommitterKeeper, app.AccountKeeper, app.BankKeeper),
bridgeModule,
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -556,8 +592,10 @@ func NewEthermintApp(
genutiltypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
group.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
bridgemoduletypes.ModuleName,
)

// NOTE: fee market module must go last in order to retrieve the block gas used.
Expand All @@ -581,9 +619,11 @@ func NewEthermintApp(
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
group.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
bridgemoduletypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -614,11 +654,13 @@ func NewEthermintApp(
ibctransfertypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
group.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
// NOTE: crisis module must go at the end to check for invariants on each module
crisistypes.ModuleName,
bridgemoduletypes.ModuleName,
)

// Uncomment if you want to set a custom migration order here.
Expand Down Expand Up @@ -890,5 +932,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable())
// Committer subspaces
paramsKeeper.Subspace(committertypes.ModuleName).WithKeyTable(committertypes.ParamKeyTable())
paramsKeeper.Subspace(bridgemoduletypes.ModuleName)
return paramsKeeper
}
75 changes: 48 additions & 27 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,75 @@
version: "3"
version: '3'

services:
node0:
container_name: b2-node0
image: ${ETHERMINT_IMAGE}
ports:
- "26657:26657"
- "8545:8545"
- "8546:8546"
- "8125:8125"
- "26656-26657:26656-26657"
volumes:
- ./client-data/node0/ethermintd:/root/.ethermintd
- ./build/node0/ethermintd:/ethermint:Z
command:
- ethermintd
- start
- --home
- /ethermint
networks:
- ethermint
localnet:
ipv4_address: 192.167.10.2

node1:
container_name: b2-node1
image: ${ETHERMINT_IMAGE}
ports:
- "26658:26657"
- "8555:8545"
- "8556:8546"
- "8126:8125"
- "26659-26660:26656-26657"
volumes:
- /root/.ethermintd:/root/.ethermintd
# - ./client-data/node1/ethermintd:/root/.ethermintd
- ./build/node1/ethermintd:/ethermint:Z
command:
- ethermintd
- start
- --home
- /ethermint
networks:
- ethermint
localnet:
ipv4_address: 192.167.10.3

node2:
container_name: b2-node2
image: ${ETHERMINT_IMAGE}
ports:
- "26659:26657"
- "8565:8545"
- "8566:8546"
- "8127:8125"
- "26661-26662:26656-26657"
volumes:
- ./client-data/node2/ethermintd:/root/.ethermintd
- ./build/node2/ethermintd:/ethermint:Z
command:
- ethermintd
- start
- --home
- /ethermint
networks:
- ethermint
localnet:
ipv4_address: 192.167.10.4

node3:
container_name: b2-node3
image: ${ETHERMINT_IMAGE}
ports:
- "26660:26657"
- "8575:8545"
- "8576:8546"
- "8128:8125"
- "26663-26664:26656-26657"
volumes:
- ./client-data/node3/ethermintd:/root/.ethermintd
- ./build/node3/ethermintd:/ethermint:Z
command:
- ethermintd
- start
- --home
- /ethermint
networks:
- ethermint
localnet:
ipv4_address: 192.167.10.5

networks:
ethermint:
localnet:
driver: bridge
ipam:
driver: default
config:
-
subnet: 192.167.10.0/16
8 changes: 6 additions & 2 deletions helper.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
set -x

init() {
apt install pipx
pipx install toml-cli
cargo install toml-cli
}

info() {
Expand Down Expand Up @@ -58,4 +57,9 @@ probeBal(){
ethermintd keys parse ethm17w0adeg64ky0daxwd2ugyuneellmjgnxcn4sgz
# ethermintd keys list --keyring-backend test
}

initChain(){
exec >"$FUNCNAME.log" 2>&1
bash tests/solidity/init-test-node.sh init
}
$@
Loading

0 comments on commit 9557684

Please sign in to comment.