Skip to content

Commit

Permalink
feat(service): Create a common service type
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolitzer committed Oct 24, 2024
1 parent 1a6f219 commit 7e13845
Show file tree
Hide file tree
Showing 8 changed files with 945 additions and 100 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ machine-snapshot/**
/cartesi-rollups-node
/cartesi-rollups-advancer
/cartesi-rollups-validator
/cartesi-rollups-template
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CLAIMER := cmd/authority-claimer/target/$(BUILD_TYPE)/cartesi-rollups-authority-
RUST_ARTIFACTS := $(CLAIMER)

# Go artifacts
GO_ARTIFACTS := cartesi-rollups-node cartesi-rollups-cli cartesi-rollups-evm-reader cartesi-rollups-advancer cartesi-rollups-validator
GO_ARTIFACTS := cartesi-rollups-node cartesi-rollups-cli cartesi-rollups-evm-reader cartesi-rollups-advancer cartesi-rollups-validator cartesi-rollups-template

# fixme(vfusco): path on all oses
CGO_CFLAGS:= -I$(PREFIX)/include
Expand Down
16 changes: 16 additions & 0 deletions cmd/cartesi-rollups-template/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

package main

import (
"os"
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-template/root"
)

func main() {
err := root.Cmd.Execute()
if err != nil {
os.Exit(1)
}
}
49 changes: 49 additions & 0 deletions cmd/cartesi-rollups-template/root/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

package root

import (
"github.com/cartesi/rollups-node/pkg/service"
"github.com/cartesi/rollups-node/internal/template"
"github.com/spf13/cobra"
)

var (
// Should be overridden during the final release build with ldflags
// to contain the actual version number
buildVersion = "devel"
createInfo = template.CreateInfo{
CreateInfo: service.CreateInfo {
Name: "template",
LogLevel: "debug",
SignalTrapsCreate: true,
},
}
)

var Cmd = &cobra.Command{
Use: createInfo.Name,
Short: "Runs " + createInfo.Name,
Long: "Runs " + createInfo.Name + " in standalone mode",
Run: run,
}

func init() {
//Cmd.Flags().StringVar(&createInfo.TelemetryAddress,
// "telemetry-address", createInfo.TelemetryAddress,
// "health check and metrics address and port")
Cmd.Flags().DurationVar(&createInfo.PollInterval,
"poll-interval", createInfo.PollInterval,
"poll interval")
Cmd.Flags().StringVar(&createInfo.LogLevel,
"log-level", createInfo.LogLevel,
"log level: debug, info, warn, error.")
}

func run(cmd *cobra.Command, args []string) {
s := template.Service{}
err := template.Create(createInfo, &s)
cobra.CheckErr(err)
s.Start(true)
}
70 changes: 41 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/cartesi/rollups-node

go 1.23.2
go 1.22.1

require (
github.com/ethereum/go-ethereum v1.14.11
github.com/ethereum/go-ethereum v1.14.6
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
github.com/tyler-smith/go-bip32 v1.0.0
Expand All @@ -15,13 +15,14 @@ require github.com/BurntSushi/toml v1.4.0
require (
github.com/Khan/genqlient v0.7.0
github.com/deepmap/oapi-codegen/v2 v2.1.0
github.com/golang-migrate/migrate/v4 v4.18.1
github.com/jackc/pgx/v5 v5.7.1
github.com/lmittmann/tint v1.0.5
github.com/golang-migrate/migrate/v4 v4.17.1
github.com/jackc/pgx/v5 v5.6.0
github.com/lmittmann/tint v1.0.4
github.com/mattn/go-isatty v0.0.20
github.com/oapi-codegen/runtime v1.1.1
golang.org/x/sync v0.8.0
golang.org/x/text v0.19.0
github.com/prometheus/client_golang v1.14.0
golang.org/x/sync v0.7.0
golang.org/x/text v0.16.0
)

require (
Expand All @@ -32,58 +33,69 @@ require (
github.com/alexflint/go-arg v1.4.3 // indirect
github.com/alexflint/go-scalar v1.2.0 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/bits-and-blooms/bitset v1.14.3 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/consensys/bavard v0.1.22 // indirect
github.com/consensys/gnark-crypto v0.14.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.3 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v27.0.3+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.2 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getkin/kin-openapi v0.123.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/holiman/uint256 v1.3.1 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/invopop/yaml v0.2.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/supranational/blst v0.3.13 // indirect
github.com/supranational/blst v0.3.12 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.9.0 // indirect
github.com/vektah/gqlparser/v2 v2.5.18 // indirect
github.com/tklauser/numcpus v0.8.0 // indirect
github.com/vektah/gqlparser/v2 v2.5.16 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/tools v0.26.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
Expand Down
Loading

0 comments on commit 7e13845

Please sign in to comment.