Skip to content
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

next branch #894

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions Dockerfile
Expand Up @@ -125,7 +125,6 @@ RUN curl -o /usr/bin/minio https://dl.min.io/server/minio/release/linux-$TARGETA
&& mc --version

COPY ./scripts /usr/local/bin
COPY ./config/full-stack.json /etc/livepeer/full-stack.json

ENV CATALYST_DOWNLOADER_PATH=/usr/local/bin \
CATALYST_DOWNLOADER_MANIFEST=/etc/livepeer/manifest.yaml \
Expand All @@ -134,7 +133,7 @@ ENV CATALYST_DOWNLOADER_PATH=/usr/local/bin \

RUN mkdir /data

CMD ["/usr/local/bin/catalyst", "--", "/usr/local/bin/MistController", "-c", "/etc/livepeer/full-stack.json"]
CMD ["/usr/local/bin/catalyst"]

FROM ${FROM_LOCAL_PARENT} AS box-local

Expand Down
31 changes: 20 additions & 11 deletions Makefile
Expand Up @@ -11,6 +11,7 @@ FROM_LOCAL_PARENT ?= scratch # for `make docker-local` and `make box-local`
DOCKER_TARGET ?= catalyst
BUILD_TARGET ?= full
export KILL ?= true
export FRONTEND ?= false
export GOOS ?= linux

ifeq ($(shell uname), Darwin)
Expand Down Expand Up @@ -95,19 +96,16 @@ livepeer-api:
cd ../studio/packages/api \
&& yarn run esbuild \
&& cd - \
&& mv ../studio/packages/api/dist-esbuild/api.js ./bin/livepeer-api \
&& mv ../studio/packages/api/dist-esbuild/livepeer-api ./bin/livepeer-api \
&& $(MAKE) box-kill BIN=livepeer-api

# same as livepeer-api but uses pkg instead of esbuild
# pros: bundles the frontend too
# cons: takes four minutes to build
.PHONY: livepeer-api-pkg
livepeer-api-pkg:
cd ../studio \
&& yarn run pkg:local \
# builds a new frontend prior to booting the API server
.PHONY: livepeer-api
livepeer-www:
cd ../studio/packages/www \
&& yarn run static \
&& cd - \
&& mv ../studio/packages/api/bin/api ./bin/livepeer-api \
&& $(MAKE) box-kill BIN=livepeer-api
&& $(MAKE) livepeer-api

.PHONY: box-kill
box-kill:
Expand Down Expand Up @@ -206,14 +204,16 @@ scripts:
cp -Rv ./scripts/* ./bin

.PHONY: box-dev
box-dev: scripts
box-dev: scripts catalyst
ulimit -c unlimited \
&& exec docker run \
-v $$(realpath bin):/usr/local/bin \
-v $$(realpath data):/data \
-v $$(realpath config):/etc/livepeer:ro \
-v $$(realpath ./coredumps):$$(realpath ./coredumps) \
-e CORE_DUMP_DIR=$$(realpath ./coredumps) \
-v /home/iameli/.ethereum/keystore:/keystore \
-e CATALYST_SECRET=f61b3cdb-d173-4a7a-a0d3-547b871a56f9 \
$(shell for line in $$(cat .env 2>/dev/null || echo ''); do printf -- "-e $$line "; done) \
--rm \
-it \
Expand Down Expand Up @@ -246,3 +246,12 @@ snapshot:
&& cd data \
&& rm -rf cockroach/auxiliary/EMERGENCY_BALLAST \
&& tar czvf ../livepeer-studio-bootstrap.tar.gz cockroach

.PHONY: sql-schema-dump
sql-schema-dump:
cockroach sql --format=raw \
--url 'postgresql://root@localhost:5432/defaultdb?sslmode=disable' \
--execute "show create all tables" \
| grep -v '#' \
| grep -v 'Time' \
> ./config/full-stack.sql
77 changes: 61 additions & 16 deletions cmd/catalyst/catalyst.go
@@ -1,13 +1,15 @@
package main

import (
"flag"
"os"
"os/exec"
"syscall"

"github.com/livepeer/catalyst/cmd/downloader/cli"
"github.com/livepeer/catalyst/cmd/downloader/downloader"
"github.com/livepeer/catalyst/cmd/downloader/types"
glog "github.com/magicsong/color-glog"
"github.com/golang/glog"
"github.com/livepeer/catalyst/cmd/catalyst/config"
"github.com/livepeer/catalyst/cmd/downloader/constants"
"github.com/peterbourgon/ff/v3"
)

var Version = "undefined"
Expand All @@ -16,26 +18,69 @@ var Version = "undefined"
// but that one will stay just a downloader and this binary may gain other functionality

func main() {
cliFlags, err := cli.GetCliFlags(types.BuildFlags{Version: Version})
cli := config.Cli{}
flag.Set("logtostderr", "true")
// vFlag := flag.Lookup("v")
fs := flag.NewFlagSet(constants.AppName, flag.ExitOnError)
// fs.StringVar(&cli.Verbosity, "v", "3", "Log verbosity. Integer value from 0 to 9")
fs.StringVar(&cli.PublicURL, "public-url", "http://localhost:8888", "Public-facing URL of your Catalyst node, including protocol and port")
fs.StringVar(&cli.Secret, "secret", "", "Secret UUID to secure your Catalyst node")
fs.StringVar(&cli.ConfOutput, "conf-output", "/tmp/catalyst-generated.json", "Path where we will place generated MistServer configuration")
fs.StringVar(&cli.SQLOutput, "sql-output", "/tmp/catalyst-fixtures.sql", "Path where we will generate SQL fixtures")
fs.StringVar(&cli.Network, "network", "offchain", "Network to use for transcoding. Allowed values: offchain, arbitrum-one-mainnet")
fs.StringVar(&cli.EthURL, "eth-url", "", "HTTPS URL of an Ethereum RPC provider for your selected network")
fs.StringVar(&cli.EthKeystorePath, "eth-keystore-path", "/keystore", "Path to an Ethereum keystore")
fs.StringVar(&cli.EthPassword, "eth-password", "", "Ethereum password or path to password file")
fs.StringVar(&cli.MaxTicketEV, "max-ticket-ev", "50000000001", "The maximum acceptable expected value for one PM ticket")
fs.StringVar(&cli.MaxTotalEV, "max-total-ev", "20000000000000", "The maximum acceptable expected value for one PM payment")
fs.StringVar(&cli.MaxPricePerUnit, "max-price-per-unit", "700", "The maximum transcoding price (in wei) per 'pixelsPerUnit' a broadcaster is willing to accept. If not set explicitly, broadcaster is willing to accept ANY price")

ff.Parse(
fs, os.Args[1:],
ff.WithConfigFileFlag("config"),
ff.WithConfigFileParser(ff.PlainParser),
ff.WithEnvVarPrefix("CATALYST"),
ff.WithEnvVarSplit(","),
)
flag.CommandLine.Parse(nil)
conf, sql, err := config.GenerateConfig(&cli)
if err != nil {
panic(err)
}
err = os.WriteFile(cli.ConfOutput, conf, 0600)
if err != nil {
glog.Fatalf("error parsing cli flags: %s", err)
return
panic(err)
}
err = downloader.Run(cliFlags)
err = os.WriteFile(cli.SQLOutput, sql, 0600)
if err != nil {
glog.Fatalf("error running downloader: %s", err)
panic(err)
}
execNext(cliFlags)
execNext(cli)
}

// Archiving for when we want to introduce auto-updating:

// func main() {
// cliFlags, err := cli.GetCliFlags(types.BuildFlags{Version: Version})
// if err != nil {
// glog.Fatalf("error parsing cli flags: %s", err)
// return
// }
// err = downloader.Run(cliFlags)
// if err != nil {
// glog.Fatalf("error running downloader: %s", err)
// }
// execNext(cliFlags)
// }

// Done! Move on to the provided next application, if it exists.
func execNext(cliFlags types.CliFlags) {
if len(cliFlags.ExecCommand) == 0 {
// Nothing to do.
return
func execNext(cli config.Cli) {
fname, err := exec.LookPath("MistController")
if err != nil {
glog.Fatalf("error finding MistController: %s", fname)
}
glog.Infof("downloader complete, now we will exec %v", cliFlags.ExecCommand)
execErr := syscall.Exec(cliFlags.ExecCommand[0], cliFlags.ExecCommand, os.Environ())
glog.Infof("config file written, now we will exec MistController")
execErr := syscall.Exec(fname, []string{"MistController", "-c", cli.ConfOutput}, os.Environ())
if execErr != nil {
glog.Fatalf("error running next command: %s", execErr)
}
Expand Down