-
Notifications
You must be signed in to change notification settings - Fork 133
feat: 4 node localnet infra #301
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
Merged
+975
−12
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4b44f9c
localnet
technicallyty 6ca9dde
remove that'
technicallyty 73a1a32
some fixes
technicallyty 3cde782
expose json rpc from container
technicallyty 54d786b
json rpc metrics
technicallyty cd3101d
Merge branch 'main' into technicallyty/localnet
eddd769
Merge branch 'main' into technicallyty/localnet
technicallyty 72532ac
Merge branch 'main' into technicallyty/localnet
technicallyty dcdf9a6
Merge branch 'main' into technicallyty/localnet
technicallyty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,3 +33,5 @@ contracts/@openzeppelin/* | |
| evmd/build/ | ||
|
|
||
| build/ | ||
|
|
||
| .testnets | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| all: evmd-env | ||
|
|
||
| evmd-env: evmd-rmi | ||
| docker build --tag cosmos/evmd -f evmd-env/Dockerfile \ | ||
| $(shell git rev-parse --show-toplevel) | ||
|
|
||
| evmd-rmi: | ||
| docker rmi cosmos/evmd 2>/dev/null; true | ||
|
|
||
| .PHONY: all evmd-env evmd-rmi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Info on how to use this docker image can be found in DOCKER_README.md | ||
| ARG IMG_TAG=latest | ||
|
|
||
| # Compile the evmd binary | ||
| FROM golang:1.24-alpine AS evmd-builder | ||
| WORKDIR /work | ||
| ENV PACKAGES="curl build-base git bash file linux-headers eudev-dev" | ||
| RUN apk add --no-cache $PACKAGES | ||
|
|
||
| COPY go.mod go.sum* ./ | ||
| RUN go mod download | ||
|
|
||
| COPY . . | ||
| RUN LEDGER_ENABLED=false COSMOS_BUILD_OPTIONS="staticlink" BUILD_TAGS=muslc make build | ||
| RUN echo "Checking binary linkage..." \ | ||
| && file /work/build/evmd \ | ||
| && (file /work/build/evmd | grep -q "statically linked" || echo "Warning: Binary may not be statically linked") | ||
|
|
||
| FROM alpine:$IMG_TAG AS run | ||
| RUN apk add --no-cache build-base jq bash curl | ||
| RUN addgroup -g 1025 nonroot | ||
| RUN adduser -D nonroot -u 1025 -G nonroot | ||
|
|
||
| # Set up the runtime environment | ||
| EXPOSE 26656 26657 1317 9090 | ||
| STOPSIGNAL SIGTERM | ||
| VOLUME /evmd | ||
| WORKDIR /evmd | ||
|
|
||
| # Copy the wrapper script and binary to expected locations | ||
| COPY contrib/images/evmd-env/wrapper.sh /usr/bin/wrapper.sh | ||
| COPY --from=evmd-builder /work/build/evmd /evmd/ | ||
| COPY --from=evmd-builder /work/build/evmd /usr/local/bin/ | ||
|
|
||
| # Set proper ownership and permissions before switching to nonroot user | ||
| RUN chown nonroot:nonroot /usr/bin/wrapper.sh && chmod +x /usr/bin/wrapper.sh | ||
| RUN chown -R nonroot:nonroot /evmd | ||
|
|
||
| USER nonroot | ||
|
|
||
| ENTRYPOINT ["/usr/bin/wrapper.sh"] | ||
| CMD ["start", "--log_format", "plain", "--minimum-gas-prices", "0.0001atest", "--json-rpc.api", "eth,txpool,personal,net,debug,web3", "--chain-id", "local-4221"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/env sh | ||
| set -x | ||
|
|
||
| BINARY=/evmd/${BINARY:-evmd} | ||
| ID=${ID:-0} | ||
| LOG=${LOG:-evmd.log} | ||
|
|
||
| if ! [ -f "${BINARY}" ]; then | ||
| echo "The binary $(basename "${BINARY}") cannot be found. Please add the binary to the shared folder. Please use the BINARY environment variable if the name of the binary is not 'evmd'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| export EVMDHOME="/data/node${ID}/evmd" | ||
|
|
||
| if [ -d "$(dirname "${EVMDHOME}"/"${LOG}")" ]; then | ||
| "${BINARY}" --home "${EVMDHOME}" "$@" | tee "${EVMDHOME}/${LOG}" | ||
| else | ||
| "${BINARY}" --home "${EVMDHOME}" "$@" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| version: "3" | ||
|
|
||
| services: | ||
| evmdnode0: | ||
| container_name: evmdnode0 | ||
| image: "cosmos/evmd" | ||
| environment: | ||
| - DEBUG=0 | ||
| - ID=0 | ||
| - LOG=${LOG:-evmd.log} | ||
| cap_add: | ||
| - SYS_PTRACE | ||
| security_opt: | ||
| - seccomp:unconfined | ||
| ports: | ||
| - "26656-26657:26656-26657" | ||
| - "1317:1317" | ||
| - "9090:9090" | ||
| - "2345:2345" | ||
| - "6065:6065" | ||
| - "8545-8546:8545-8546" | ||
| volumes: | ||
| - ./.testnets:/data:Z | ||
| networks: | ||
| localnet: | ||
| ipv4_address: 192.168.10.2 | ||
|
|
||
| evmdnode1: | ||
| container_name: evmdnode1 | ||
| image: "cosmos/evmd" | ||
| environment: | ||
| - DEBUG=0 | ||
| - ID=1 | ||
| - LOG=${LOG:-evmd.log} | ||
| cap_add: | ||
| - SYS_PTRACE | ||
| security_opt: | ||
| - seccomp:unconfined | ||
| ports: | ||
| - "26666-26667:26656-26657" | ||
| - "1318:1317" | ||
| - "9091:9090" | ||
| - "2346:2345" | ||
| - "6075:6065" | ||
| - "8555-8556:8545-8546" | ||
| volumes: | ||
| - ./.testnets:/data:Z | ||
| networks: | ||
| localnet: | ||
| ipv4_address: 192.168.10.3 | ||
|
|
||
| evmdnode2: | ||
| container_name: evmdnode2 | ||
| image: "cosmos/evmd" | ||
| environment: | ||
| - DEBUG=0 | ||
| - ID=2 | ||
| - LOG=${LOG:-evmd.log} | ||
| cap_add: | ||
| - SYS_PTRACE | ||
| security_opt: | ||
| - seccomp:unconfined | ||
| ports: | ||
| - "26676-26677:26656-26657" | ||
| - "1319:1317" | ||
| - "9092:9090" | ||
| - "2347:2345" | ||
| - "6085:6065" | ||
| - "8565-8566:8545-8546" | ||
| volumes: | ||
| - ./.testnets:/data:Z | ||
| networks: | ||
| localnet: | ||
| ipv4_address: 192.168.10.4 | ||
|
|
||
| evmdnode3: | ||
| container_name: evmdnode3 | ||
| image: "cosmos/evmd" | ||
| environment: | ||
| - DEBUG=0 | ||
| - ID=3 | ||
| - LOG=${LOG:-evmd.log} | ||
| cap_add: | ||
| - SYS_PTRACE | ||
| security_opt: | ||
| - seccomp:unconfined | ||
| ports: | ||
| - "26686-26687:26656-26657" | ||
| - "1320:1317" | ||
| - "9093:9090" | ||
| - "2348:2345" | ||
| - "6095:6065" | ||
| - "8575-8576:8545-8546" | ||
| volumes: | ||
| - ./.testnets:/data:Z | ||
| networks: | ||
| localnet: | ||
| ipv4_address: 192.168.10.5 | ||
|
|
||
| networks: | ||
| localnet: | ||
| driver: bridge | ||
| ipam: | ||
| driver: default | ||
| config: | ||
| - subnet: 192.168.10.0/25 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "errors" | ||
| "io" | ||
| "path/filepath" | ||
|
|
||
| dbm "github.com/cosmos/cosmos-db" | ||
| "github.com/cosmos/cosmos-sdk/baseapp" | ||
| "github.com/cosmos/cosmos-sdk/client/flags" | ||
| "github.com/cosmos/cosmos-sdk/server" | ||
| servertypes "github.com/cosmos/cosmos-sdk/server/types" | ||
| simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" | ||
| genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" | ||
| "github.com/cosmos/evm/evmd" | ||
| evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" | ||
| "github.com/spf13/cast" | ||
| "github.com/spf13/viper" | ||
|
|
||
| "cosmossdk.io/log" | ||
| "cosmossdk.io/store" | ||
| "cosmossdk.io/store/snapshots" | ||
| snapshottypes "cosmossdk.io/store/snapshots/types" | ||
| storetypes "cosmossdk.io/store/types" | ||
| ) | ||
|
|
||
| type appCreator struct{} | ||
|
|
||
| func (a appCreator) newApp( | ||
| logger log.Logger, | ||
| db dbm.DB, | ||
| traceStore io.Writer, | ||
| appOpts servertypes.AppOptions, | ||
| ) servertypes.Application { | ||
| var cache storetypes.MultiStorePersistentCache | ||
| if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) { | ||
| cache = store.NewCommitKVStoreCacheManager() | ||
| } | ||
| pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| skipUpgradeHeights := make(map[int64]bool) | ||
| for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) { | ||
| skipUpgradeHeights[int64(h)] = true | ||
| } | ||
|
|
||
| homeDir := cast.ToString(appOpts.Get(flags.FlagHome)) | ||
| chainID := cast.ToString(appOpts.Get(flags.FlagChainID)) | ||
| if chainID == "" { | ||
| // fallback to genesis chain-id | ||
| genDocFile := filepath.Join(homeDir, cast.ToString(appOpts.Get("genesis_file"))) | ||
| appGenesis, err := genutiltypes.AppGenesisFromFile(genDocFile) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| chainID = appGenesis.ChainID | ||
| } | ||
|
|
||
| snapshotDir := filepath.Join(homeDir, "data", "snapshots") | ||
| snapshotDB, err := dbm.NewDB("metadata", server.GetAppDBBackend(appOpts), snapshotDir) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| // BaseApp Opts | ||
| snapshotOptions := snapshottypes.NewSnapshotOptions( | ||
| cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval)), | ||
| cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)), | ||
| ) | ||
| baseappOptions := []func(*baseapp.BaseApp){ | ||
| baseapp.SetChainID(chainID), | ||
| baseapp.SetPruning(pruningOpts), | ||
| baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), | ||
| baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))), | ||
| baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))), | ||
| baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))), | ||
| baseapp.SetInterBlockCache(cache), | ||
| baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))), | ||
| baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))), | ||
| baseapp.SetSnapshot(snapshotStore, snapshotOptions), | ||
| baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), | ||
| } | ||
|
|
||
| return evmd.NewExampleApp( | ||
| logger, | ||
| db, | ||
| traceStore, | ||
| true, | ||
| simtestutil.EmptyAppOptions{}, | ||
| evmdconfig.EVMChainID, | ||
| evmdconfig.EvmAppOptions, | ||
| baseappOptions..., | ||
| ) | ||
| } | ||
|
|
||
| func (a appCreator) appExport( | ||
| logger log.Logger, | ||
| db dbm.DB, | ||
| traceStore io.Writer, | ||
| height int64, | ||
| forZeroHeight bool, | ||
| jailAllowedAddrs []string, | ||
| appOpts servertypes.AppOptions, | ||
| modulesToExport []string, | ||
| ) (servertypes.ExportedApp, error) { | ||
| var evmApp *evmd.EVMD | ||
|
|
||
| homePath, ok := appOpts.Get(flags.FlagHome).(string) | ||
| if !ok || homePath == "" { | ||
| return servertypes.ExportedApp{}, errors.New("application home is not set") | ||
| } | ||
|
|
||
| // InvCheckPeriod | ||
| viperAppOpts, ok := appOpts.(*viper.Viper) | ||
| if !ok { | ||
| return servertypes.ExportedApp{}, errors.New("appOpts is not viper.Viper") | ||
| } | ||
| // overwrite the FlagInvCheckPeriod | ||
| viperAppOpts.Set(server.FlagInvCheckPeriod, 1) | ||
| appOpts = viperAppOpts | ||
|
|
||
| var loadLatest bool | ||
| if height == -1 { | ||
| loadLatest = true | ||
| } | ||
|
|
||
| evmApp = evmd.NewExampleApp( | ||
| logger, | ||
| db, | ||
| traceStore, | ||
| loadLatest, | ||
| appOpts, | ||
| evmdconfig.EVMChainID, | ||
| evmdconfig.EvmAppOptions, | ||
| ) | ||
|
|
||
| if height != -1 { | ||
| if err := evmApp.LoadHeight(height); err != nil { | ||
| return servertypes.ExportedApp{}, err | ||
| } | ||
| } | ||
|
|
||
| return evmApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.