diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..76b0367 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ + +FROM golang:1.20-alpine AS builder +RUN apk update && apk add --no-cache make git gcc libc-dev linux-headers python3-dev +WORKDIR /nucleus +COPY . /nucleus +RUN make clean +RUN go mod tidy && go mod download +RUN make build +RUN python3 ./init.py -b /nucleus/build/nucleusd -c /root/.nucleus --overwrite + +FROM alpine:latest +WORKDIR /nucleus +COPY --from=builder /nucleus/build/nucleusd /usr/bin/nucleusd +COPY --from=builder /root/.nucleus /root/.nucleus +# COPY --from=builder /nucleus/nucleus_conf.yaml /root/.nucleus/config.yaml + +CMD ["nucleusd", "start"] diff --git a/app/app.go b/app/app.go index aa63072..759088f 100644 --- a/app/app.go +++ b/app/app.go @@ -17,7 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/simapp" + "cosmos/cosmos-sdk/simapp" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" diff --git a/app/simulation_test.go b/app/simulation_test.go index 4ea6921..454445f 100644 --- a/app/simulation_test.go +++ b/app/simulation_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/simapp" + "cosmos/cosmos-sdk/simapp" simulationtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" "github.com/stretchr/testify/require" diff --git a/init.py b/init.py index 7b42980..a1a3b46 100755 --- a/init.py +++ b/init.py @@ -5,22 +5,7 @@ import pathlib import shutil import subprocess - -NUCLEUS_BIN = "nucleusd" -NUCLEUS_SYSROOT = str(pathlib.Path.home().joinpath(".nucleus")) - -CHAIN_ID = "nucleus-1" -PAIR1 = "alice" -PAIR2 = "bob" -MONIKER = "nimda" - -DEV_ADDRESS = "nuc1llp0f6qxemgh4g4m5ewk0ew0hxj76avukahzwu" - -PAIR1_MNEMONIC = "explain chalk inch snake snack fade news bus horn grant stereo surface panic sister absurd lens speed never inhale element junk senior bubble return" -# PAIR1_ADDRESS="nuc15d4sf4z6y0vk9dnum8yzkvr9c3wq4q89hzvgjk" - -PAIR2_MNEMONIC = "young twist cube soldier sorry false dry actor assault roast mosquito brain fix seat wrong sauce impact smoke expect donkey hard decline polar dinosaur" -# PAIR2_ADDRESS="nuc1yfygf0zr5s69ces9r0h72hqv23nkqz9nej732n" +import argparse def check_if_already_initialized(): @@ -147,7 +132,34 @@ def add_htlc_genesis_config(data): data["app_state"]["htlc"] = htlc_genesis_config if __name__ == "__main__": - check_if_already_initialized() + + CHAIN_ID = "nucleus-1" + PAIR1 = "alice" + PAIR2 = "bob" + MONIKER = "nimda" + + DEV_ADDRESS = "nuc1llp0f6qxemgh4g4m5ewk0ew0hxj76avukahzwu" + + PAIR1_MNEMONIC = "explain chalk inch snake snack fade news bus horn grant stereo surface panic sister absurd lens speed never inhale element junk senior bubble return" + # PAIR1_ADDRESS="nuc15d4sf4z6y0vk9dnum8yzkvr9c3wq4q89hzvgjk" + + PAIR2_MNEMONIC = "young twist cube soldier sorry false dry actor assault roast mosquito brain fix seat wrong sauce impact smoke expect donkey hard decline polar dinosaur" + # PAIR2_ADDRESS="nuc1yfygf0zr5s69ces9r0h72hqv23nkqz9nej732n" + + parser = argparse.ArgumentParser(description="Download API module file for specified version and platform.") + # Optional arguments + parser.add_argument("-b", "--bin", help="path to nucleusd binary", default="nucleusd") + parser.add_argument("-c", "--config", help="path to nucleusd configs", default=str(pathlib.Path.home().joinpath(".nucleus"))) + parser.add_argument("--overwrite", help="overwrites existing configs", action="store_true") + args = parser.parse_args() + + NUCLEUS_BIN = args.bin + NUCLEUS_SYSROOT = args.config + + # TODO: Add argparse support for custom chain id, moniker, mnemonic, dev address + + if not args.overwrite: + check_if_already_initialized() init_genesis() update_app_toml() update_rpc_host() diff --git a/testutil/network/network.go b/testutil/network/network.go index 5d3a9b4..4aa3f5a 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -7,12 +7,13 @@ import ( "github.com/komodoplatform/nucleus/app" + "cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" servertypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/htlc/simulation/operation.go b/x/htlc/simulation/operation.go index b0b41b4..9193bd0 100644 --- a/x/htlc/simulation/operation.go +++ b/x/htlc/simulation/operation.go @@ -7,10 +7,11 @@ import ( tmbytes "github.com/tendermint/tendermint/libs/bytes" + "cosmos/cosmos-sdk/simapp/helpers" + simappparams "cosmos/cosmos-sdk/simapp/params" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/simapp/helpers" - simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -84,12 +85,12 @@ func SimulateMsgCreateHtlc(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban maxLock := int(assert.MaxBlockLock) timeLock := uint64(simtypes.RandIntBetween(r, minLock, maxLock)) msg := &types.MsgCreateHTLC{ - Sender: sender.Address.String(), - To: to.Address.String(), - Amount: amount, - HashLock: hashLock, - Timestamp: timestamp, - TimeLock: timeLock, + Sender: sender.Address.String(), + To: to.Address.String(), + Amount: amount, + HashLock: hashLock, + Timestamp: timestamp, + TimeLock: timeLock, } fees, err := simtypes.RandomFees(r, ctx, balance) diff --git a/x/nucleus/module_simulation.go b/x/nucleus/module_simulation.go index 5a1e21d..517fc52 100644 --- a/x/nucleus/module_simulation.go +++ b/x/nucleus/module_simulation.go @@ -7,8 +7,9 @@ import ( nucleussimulation "github.com/komodoplatform/nucleus/x/nucleus/simulation" "github.com/komodoplatform/nucleus/x/nucleus/types" + simappparams "cosmos/cosmos-sdk/simapp/params" + "github.com/cosmos/cosmos-sdk/baseapp" - simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation"