Skip to content

Commit

Permalink
Merge pull request #317 from multiversx/add-docker-image-for-sc-calls…
Browse files Browse the repository at this point in the history
…-executor

Added docker image for sc calls executor
  • Loading branch information
iulianpascalau authored Aug 12, 2024
2 parents 46546ad + 4fa6039 commit 33fe9d5
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
/esdata
.env
*.log
# prevent accidental commit of key files
*.pem

mytestnet/**

Expand Down
2 changes: 1 addition & 1 deletion cmd/scCallsExecutor/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ NetworkAddress = "127.0.0.1:8085"
ProxyMaxNoncesDelta = 7
ProxyFinalityCheck = true
ProxyCacherExpirationSeconds = 600
ProxyRestAPIEntityType = "observer"
ProxyRestAPIEntityType = "proxy"
IntervalToResendTxsInSeconds = 60
PrivateKeyFile = "keys/multiversx.pem"
PollingIntervalInMillis = 6000
Expand Down
18 changes: 18 additions & 0 deletions cmd/scCallsExecutor/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ var (
Name: "log-logger-name",
Usage: "Boolean option for logger name in the logs.",
}
// networkAddress is used to specify the network address used
networkAddress = cli.StringFlag{
Name: "network-address",
Usage: "The network address (gateway) to be used. Example: 'https://testnet-explorer.multiversx.com'",
}
// scProxyBech32Address is the smart contract address used to interact with this tool
scProxyBech32Address = cli.StringFlag{
Name: "sc-proxy-address",
Usage: "The smart contract address in bech32 format to interact with",
}
// privateKeyFile is the MultiversX private key file used to issue transaction for the SC calls
privateKeyFile = cli.StringFlag{
Name: "private-key-file",
Usage: "The MultiversX private key file used to issue transaction for the SC calls",
}
)

func getFlags() []cli.Flag {
Expand All @@ -80,6 +95,9 @@ func getFlags() []cli.Flag {
logWithLoggerName,
profileMode,
restApiInterface,
networkAddress,
scProxyBech32Address,
privateKeyFile,
}
}
func getFlagsConfig(ctx *cli.Context) config.ContextFlagsConfig {
Expand Down
15 changes: 14 additions & 1 deletion cmd/scCallsExecutor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func startRelay(ctx *cli.Context, version string) error {
return errLogger
}

log.Info("starting bridge node", "version", version, "pid", os.Getpid())
log.Info("starting SC calls executor node", "version", version, "pid", os.Getpid())

err := logger.SetLogLevel(flagsConfig.LogLevel)
if err != nil {
Expand All @@ -93,6 +93,19 @@ func startRelay(ctx *cli.Context, version string) error {
}
}

if ctx.IsSet(scProxyBech32Address.Name) {
cfg.ScProxyBech32Address = ctx.GlobalString(scProxyBech32Address.Name)
log.Info("using flag-defined SC proxy address", "address", cfg.ScProxyBech32Address)
}
if ctx.IsSet(networkAddress.Name) {
cfg.NetworkAddress = ctx.GlobalString(networkAddress.Name)
log.Info("using flag-defined network address", "address", cfg.NetworkAddress)
}
if ctx.IsSet(privateKeyFile.Name) {
cfg.PrivateKeyFile = ctx.GlobalString(privateKeyFile.Name)
log.Info("using flag-defined private key file", "filename", cfg.PrivateKeyFile)
}

if len(cfg.NetworkAddress) == 0 {
return fmt.Errorf("empty NetworkAddress in config file")
}
Expand Down
17 changes: 17 additions & 0 deletions docker/scCallsExecutor-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.9"

services:
sc-calls-executor:
build:
context: ..
dockerfile: scCallsExecutor.Dockerfile
restart: unless-stopped
volumes:
- "../keys:/multiversx/keys"
# change the `network-address`, `sc-proxy-address` and `private-key-file` accordingly
entrypoint: "./scCallsExecutor \
-log-level *:DEBUG \
-log-save \
-network-address https://devnet-gateway.multiversx.com \
-sc-proxy-address erd1qqqqqqqqqqqqqpgq5l0743nyv45vdptmfh3jydkqtyzjqpgsrcjq8yuzxk \
-private-key-file ./keys/walletKey.pem"
26 changes: 26 additions & 0 deletions scCallsExecutor.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM golang:1.20.7-bookworm AS builder
LABEL description="This Docker image builds the SC calls executor binary."

WORKDIR /multiversx
COPY . .

RUN go mod tidy

WORKDIR /multiversx/cmd/scCallsExecutor

RUN APPVERSION=$(git describe --tags --long --always | tail -c 11) && echo "package main\n\nfunc init() {\n\tappVersion = \"${APPVERSION}\"\n}" > local.go
RUN go mod tidy
RUN go build

FROM ubuntu:22.04 AS runner
LABEL description="This Docker image runs SC calls executor binary."

RUN apt-get update \
&& apt-get -y install git \
&& apt-get clean

COPY --from=builder /multiversx/cmd/scCallsExecutor /multiversx

WORKDIR /multiversx

ENTRYPOINT ["./scCallsExecutor"]

0 comments on commit 33fe9d5

Please sign in to comment.