diff --git a/Makefile b/Makefile index f36da4c38e..1315326e74 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,7 @@ test: vet ## test-e2e: Running e2e tests test-e2e: build @echo "--> Running e2e tests" - @go test -mod=readonly -failfast -timeout=15m -tags='e2e' ./test/e2e/... --binary=$(CURDIR)/build/rollkit + @go test -mod=readonly -failfast -timeout=15m -tags='e2e' ./test/e2e/... --binary=$(CURDIR)/build/testapp .PHONY: test-e2e ## proto-gen: Generate protobuf files. Requires docker. diff --git a/block/manager.go b/block/manager.go index dfce2e76e2..a339c55ef1 100644 --- a/block/manager.go +++ b/block/manager.go @@ -14,7 +14,6 @@ import ( "cosmossdk.io/log" goheaderstore "github.com/celestiaorg/go-header/store" ds "github.com/ipfs/go-datastore" - "github.com/libp2p/go-libp2p/core/crypto" "google.golang.org/protobuf/proto" "github.com/rollkit/go-sequencing" @@ -26,6 +25,7 @@ import ( "github.com/rollkit/rollkit/pkg/config" "github.com/rollkit/rollkit/pkg/genesis" "github.com/rollkit/rollkit/pkg/queue" + "github.com/rollkit/rollkit/pkg/signer" "github.com/rollkit/rollkit/pkg/store" "github.com/rollkit/rollkit/types" pb "github.com/rollkit/rollkit/types/pb/rollkit/v1" @@ -107,7 +107,7 @@ type Manager struct { config config.Config genesis genesis.Genesis - proposerKey crypto.PrivKey + proposerKey signer.Signer // daHeight is the height of the latest processed DA block daHeight uint64 @@ -221,7 +221,7 @@ func getInitialState(ctx context.Context, genesis genesis.Genesis, store store.S // NewManager creates new block Manager. func NewManager( ctx context.Context, - proposerKey crypto.PrivKey, + proposerKey signer.Signer, config config.Config, genesis genesis.Genesis, store store.Store, @@ -395,7 +395,7 @@ func (m *Manager) SetDALC(dalc coreda.Client) { } // isProposer returns whether or not the manager is a proposer -func isProposer(_ crypto.PrivKey, _ types.State) (bool, error) { +func isProposer(_ signer.Signer, _ types.State) (bool, error) { return true, nil } @@ -1464,6 +1464,10 @@ func (m *Manager) execCommit(ctx context.Context, newState types.State, h *types func (m *Manager) execCreateBlock(_ context.Context, height uint64, lastSignature *types.Signature, lastHeaderHash types.Hash, lastState types.State, batchData *BatchData) (*types.SignedHeader, *types.Data, error) { data := batchData.Data batchdata := convertBatchDataToBytes(data) + key, err := m.proposerKey.GetPublic() + if err != nil { + return nil, nil, err + } header := &types.SignedHeader{ Header: types.Header{ Version: types.Version{ @@ -1483,7 +1487,7 @@ func (m *Manager) execCreateBlock(_ context.Context, height uint64, lastSignatur }, Signature: *lastSignature, Signer: types.Signer{ - PubKey: m.proposerKey.GetPublic(), + PubKey: key, Address: m.genesis.ProposerAddress(), }, } diff --git a/block/manager_test.go b/block/manager_test.go index 25f3cbc808..dc3b16c19c 100644 --- a/block/manager_test.go +++ b/block/manager_test.go @@ -24,6 +24,8 @@ import ( "github.com/rollkit/rollkit/pkg/config" genesispkg "github.com/rollkit/rollkit/pkg/genesis" "github.com/rollkit/rollkit/pkg/queue" + "github.com/rollkit/rollkit/pkg/signer" + noopsigner "github.com/rollkit/rollkit/pkg/signer/noop" "github.com/rollkit/rollkit/pkg/store" "github.com/rollkit/rollkit/test/mocks" "github.com/rollkit/rollkit/types" @@ -173,21 +175,24 @@ func TestSignVerifySignature(t *testing.T) { require := require.New(t) m := getManager(t, coreda.NewDummyDA(100_000, 0, 0), -1, -1) payload := []byte("test") - privKey, pubKey, err := crypto.GenerateKeyPair(crypto.Ed25519, 256) + privKey, _, err := crypto.GenerateKeyPair(crypto.Ed25519, 256) + require.NoError(err) + noopSigner, err := noopsigner.NewNoopSigner(privKey) require.NoError(err) cases := []struct { - name string - privKey crypto.PrivKey - pubKey crypto.PubKey + name string + signer signer.Signer }{ - {"ed25519", privKey, pubKey}, + {"ed25519", noopSigner}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { - m.proposerKey = c.privKey + m.proposerKey = c.signer signature, err := m.proposerKey.Sign(payload) require.NoError(err) - ok, err := c.pubKey.Verify(payload, signature) + pubKey, err := c.signer.GetPublic() + require.NoError(err) + ok, err := pubKey.Verify(payload, signature) require.NoError(err) require.True(ok) }) @@ -358,7 +363,7 @@ func Test_isProposer(t *testing.T) { type args struct { state types.State - signerPrivKey crypto.PrivKey + signerPrivKey signer.Signer } tests := []struct { name string @@ -372,9 +377,11 @@ func Test_isProposer(t *testing.T) { genesisData, privKey, _ := types.GetGenesisWithPrivkey("Test_isProposer") s, err := types.NewFromGenesisDoc(genesisData) require.NoError(err) + signer, err := noopsigner.NewNoopSigner(privKey) + require.NoError(err) return args{ s, - privKey, + signer, } }(), isProposer: true, diff --git a/buf.gen.yaml b/buf.gen.yaml index 3bf3a54bc8..f678a7e8e7 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -1,14 +1,12 @@ version: v2 -# The plugins to run. + plugins: - # The name of the plugin. - remote: buf.build/protocolbuffers/go - # The relative output directory. out: types/pb - # Any options to provide to the plugin. opt: paths=source_relative - - remote: buf.build/connectrpc/go out: types/pb opt: paths=source_relative +inputs: + - directory: proto diff --git a/buf.yaml b/buf.yaml index 5ac36fe320..bf7debf7cc 100644 --- a/buf.yaml +++ b/buf.yaml @@ -1,9 +1,7 @@ -version: v1beta1 +version: v2 -build: - roots: - - proto - - third_party/proto +modules: + - path: proto lint: use: - COMMENTS diff --git a/go.mod b/go.mod index 0358b7e5fe..4884ecb1a3 100644 --- a/go.mod +++ b/go.mod @@ -14,10 +14,9 @@ require ( cosmossdk.io/log v1.5.0 github.com/celestiaorg/go-header v0.6.4 github.com/celestiaorg/utils v0.1.0 - github.com/cometbft/cometbft v0.38.15 + github.com/cosmos/gogoproto v1.7.0 github.com/go-kit/kit v0.13.0 github.com/goccy/go-yaml v1.16.0 - github.com/gogo/protobuf v1.3.2 github.com/ipfs/go-datastore v0.7.0 github.com/ipfs/go-ds-badger4 v0.1.5 github.com/libp2p/go-libp2p v0.40.0 @@ -34,13 +33,13 @@ require ( github.com/spf13/pflag v1.0.6 github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.10.0 + golang.org/x/crypto v0.33.0 golang.org/x/net v0.35.0 google.golang.org/grpc v1.70.0 google.golang.org/protobuf v1.36.5 ) require ( - github.com/DataDog/zstd v1.4.5 // indirect github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bytedance/sonic v1.12.3 // indirect @@ -49,41 +48,26 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cockroachdb/errors v1.11.3 // indirect - github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect - github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v1.1.1 // indirect - github.com/cockroachdb/redact v1.1.5 // indirect - github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect - github.com/cometbft/cometbft-db v0.14.1 // indirect github.com/containerd/cgroups v1.1.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect - github.com/cosmos/gogoproto v1.7.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect - github.com/dgraph-io/badger/v4 v4.2.1-0.20231013074411-fb1b00959581 // indirect - github.com/dgraph-io/ristretto v0.1.1 // indirect - github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect + github.com/dgraph-io/badger/v4 v4.5.1 // indirect + github.com/dgraph-io/ristretto/v2 v2.1.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/elastic/gosigar v0.14.3 // indirect github.com/flynn/noise v1.1.0 // indirect github.com/francoispqt/gojay v1.2.13 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/getsentry/sentry-go v0.27.0 // indirect - github.com/go-kit/log v0.2.1 // indirect - github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect - github.com/golang/glog v1.2.3 // indirect + github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.4 // indirect - github.com/golang/snappy v0.0.4 // indirect - github.com/google/btree v1.1.3 // indirect github.com/google/flatbuffers v24.12.23+incompatible // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gopacket v1.1.19 // indirect @@ -106,12 +90,9 @@ require ( github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/jbenet/goprocess v0.1.4 // indirect - github.com/jmhodges/levigo v1.0.0 // indirect github.com/klauspost/compress v1.17.11 // indirect github.com/klauspost/cpuid/v2 v2.2.9 // indirect github.com/koron/go-ssdp v0.0.5 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/kr/text v0.2.0 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/libp2p/go-cidranger v1.1.0 // indirect github.com/libp2p/go-flow-metrics v0.2.0 // indirect @@ -124,7 +105,6 @@ require ( github.com/libp2p/go-netroute v0.2.2 // indirect github.com/libp2p/go-reuseport v0.4.0 // indirect github.com/libp2p/go-yamux/v5 v5.0.0 // indirect - github.com/linxGnu/grocksdb v1.8.14 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -144,13 +124,11 @@ require ( github.com/multiformats/go-multistream v0.6.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae // indirect github.com/onsi/ginkgo/v2 v2.22.2 // indirect github.com/opencontainers/runtime-spec v1.2.0 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect github.com/pion/datachannel v1.5.10 // indirect github.com/pion/dtls/v2 v2.2.12 // indirect github.com/pion/dtls/v3 v3.0.4 // indirect @@ -180,23 +158,18 @@ require ( github.com/quic-go/quic-go v0.50.0 // indirect github.com/quic-go/webtransport-go v0.8.1-0.20241018022711-4ac2c9250e66 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect - github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect - github.com/rogpeppe/go-internal v1.13.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/sasha-s/go-deadlock v0.3.5 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect github.com/wlynxg/anet v0.0.5 // indirect - go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/otel v1.34.0 // indirect @@ -208,7 +181,6 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect - golang.org/x/crypto v0.33.0 // indirect golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/sync v0.11.0 // indirect diff --git a/go.sum b/go.sum index cf579620f6..9b9c9976a7 100644 --- a/go.sum +++ b/go.sum @@ -45,8 +45,6 @@ git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGy github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= -github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= @@ -85,10 +83,7 @@ github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBT github.com/btcsuite/btcd v0.0.0-20190523000118-16327141da8c/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= -github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo= github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= -github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= -github.com/btcsuite/btcd/btcutil v1.1.6/go.mod h1:9dFymx8HpuLqBnsPELrImQeTQfKBQqzqGbbV3jK55aE= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= @@ -139,25 +134,7 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= -github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= -github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw= -github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= -github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= -github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/cometbft/cometbft v0.38.15 h1:5veFd8k1uXM27PBg9sMO3hAfRJ3vbh4OmmLf6cVrqXg= -github.com/cometbft/cometbft v0.38.15/go.mod h1:+wh6ap6xctVG+JOHwbl8pPKZ0GeqdPYqISu7F4b43cQ= -github.com/cometbft/cometbft-db v0.14.1 h1:SxoamPghqICBAIcGpleHbmoPqy+crij/++eZz3DlerQ= -github.com/cometbft/cometbft-db v0.14.1/go.mod h1:KHP1YghilyGV/xjD5DP3+2hyigWx0WTp9X+0Gnx0RxQ= github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE= github.com/containerd/cgroups v1.0.3/go.mod h1:/ofk34relqNjSGyqPrmEULrO4Sc8LJhvJmWbUCUKqj8= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= @@ -181,7 +158,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -196,11 +172,11 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvw github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE= -github.com/dgraph-io/badger/v4 v4.2.1-0.20231013074411-fb1b00959581 h1:yy45brf1ktmnkTCZlHynP1gRlVwZ9g19oz5D9wG81v4= -github.com/dgraph-io/badger/v4 v4.2.1-0.20231013074411-fb1b00959581/go.mod h1:T/uWAYxrXdaXw64ihI++9RMbKTCpKd/yE9+saARew7k= +github.com/dgraph-io/badger/v4 v4.5.1 h1:7DCIXrQjo1LKmM96YD+hLVJ2EEsyyoWxJfpdd56HLps= +github.com/dgraph-io/badger/v4 v4.5.1/go.mod h1:qn3Be0j3TfV4kPbVoK0arXCD1/nr1ftth6sbL5jxdoA= github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= -github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= -github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= +github.com/dgraph-io/ristretto/v2 v2.1.0 h1:59LjpOJLNDULHh8MC4UaegN52lC4JnO2dITsie/Pa8I= +github.com/dgraph-io/ristretto/v2 v2.1.0/go.mod h1:uejeqfYXpUomfse0+lO+13ATz4TypQYLJZzBSAemuB4= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= @@ -232,8 +208,6 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg= github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= -github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= -github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= @@ -246,13 +220,9 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= -github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -263,14 +233,10 @@ github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= -github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= -github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -296,8 +262,6 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.2.3 h1:oDTdz9f5VGVVNGu/Q7UXKWYsD0873HXLHdJUNBsSEKM= -github.com/golang/glog v1.2.3/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -332,12 +296,8 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= -github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/flatbuffers v24.12.23+incompatible h1:ubBKR94NR4pXUCY/MUsRVzd9umNW7ht7EG9hHfS9FX8= github.com/google/flatbuffers v24.12.23+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -361,8 +321,6 @@ github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= -github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -498,8 +456,6 @@ github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0 github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= -github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= @@ -551,8 +507,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= -github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-addr-util v0.1.0/go.mod h1:6I3ZYuFr2O/9D+SoyM0zEw0EF3YkldtTX406BpdQMqw= github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= @@ -671,8 +625,6 @@ github.com/libp2p/go-yamux/v5 v5.0.0/go.mod h1:en+3cdX51U0ZslwRdRLrvQsdayFt3TSUK github.com/libp2p/zeroconf/v2 v2.1.1/go.mod h1:fuJqLnUwZTshS3U/bMRJ3+ow/v9oid1n0DmyYyNO1Xs= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= -github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= github.com/lucas-clemente/quic-go v0.23.0/go.mod h1:paZuzjXCE5mj6sikVLMvqXk8lJV2AsqtJ6bDhjEfxx0= github.com/lucas-clemente/quic-go v0.25.0/go.mod h1:YtzP8bxRVCBlO77yRanE264+fY/T2U9ZlW1AaHOsMOg= github.com/lucas-clemente/quic-go v0.27.0/go.mod h1:AzgQoPda7N+3IqMMMkywBKggIFo2KT6pfnlrQ2QieeI= @@ -723,8 +675,6 @@ github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b/go.mod h1:lxPUiZwKo github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc h1:PTfri+PuQmWDqERdnNMiD9ZejrlswWrCpBEZgWOiTrc= github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc/go.mod h1:cGKTAVKx4SxOuR/czcZ/E2RSJ3sfHs8FpHhQ5CWMf9s= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= -github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= -github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ= github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= github.com/minio/sha256-simd v0.0.0-20190328051042-05b4dd3047e5/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= github.com/minio/sha256-simd v0.1.0/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= @@ -823,10 +773,6 @@ github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJE github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= -github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= -github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae h1:FatpGJD2jmJfhZiFDElaC0QhZUDQnxUeAwTGkfAHN3I= -github.com/oasisprotocol/curve25519-voi v0.0.0-20220708102147-0a8a51822cae/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= @@ -837,7 +783,6 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108 github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU= github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cTyztHwsk= @@ -873,12 +818,8 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 h1:Dx7Ovyv/SFnMFw3fD4oEoeorXc6saIiQ23LrGLth0Gw= -github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= -github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pion/datachannel v1.5.10 h1:ly0Q26K1i6ZkGf42W7D4hQYR90pZwzFOjTq5AuCKk4o= github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M= github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s= @@ -921,7 +862,6 @@ github.com/pion/turn/v4 v4.0.0 h1:qxplo3Rxa9Yg1xXDxxH8xaqcyGUtbHYw4QSCvmFWvhM= github.com/pion/turn/v4 v4.0.0/go.mod h1:MuPDkm15nYSklKpN8vWJ9W2M0PlyQZqYt1McGuxG7mA= github.com/pion/webrtc/v4 v4.0.9 h1:PyOYMRKJgfy0dzPcYtFD/4oW9zaw3Ze3oZzzbj2LV9E= github.com/pion/webrtc/v4 v4.0.9/go.mod h1:ViHLVaNpiuvaH8pdiuQxuA9awuE6KVzAXx3vVWilOck= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -987,18 +927,13 @@ github.com/raulk/go-watchdog v1.2.0/go.mod h1:lzSbAl5sh4rtI8tYHU01BWIDzgzqaQLj6R github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= -github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/rollkit/go-sequencing v0.4.1 h1:P0x1wUFIAhdEeqUbrRAF343iExKhq9UkVOBbi45l750= github.com/rollkit/go-sequencing v0.4.1/go.mod h1:QnOk8mqyVgFWdMnjvZVBG4x8GC/TsRtoN5XdPZzfCSs= -github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= -github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= @@ -1012,8 +947,6 @@ github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgY github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= -github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= @@ -1106,8 +1039,6 @@ github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= @@ -1140,8 +1071,6 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6ejyAJc760RwW4SnVDiTYTzwnXuxo= -go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -1314,7 +1243,6 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -1421,7 +1349,6 @@ golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1446,7 +1373,6 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1674,7 +1600,6 @@ gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/src-d/go-cli.v0 v0.0.0-20181105080154-d492247bbc0d/go.mod h1:z+K8VcOYVYcSwSjGebuDL6176A1XskgbtNl64NSg+n8= gopkg.in/src-d/go-log.v1 v1.0.1/go.mod h1:GN34hKP0g305ysm2/hctJ0Y8nWP3zxXXJ8GFabTyABE= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= diff --git a/node/full.go b/node/full.go index 300be6c8ce..f31c9b9a23 100644 --- a/node/full.go +++ b/node/full.go @@ -13,7 +13,6 @@ import ( "cosmossdk.io/log" ds "github.com/ipfs/go-datastore" ktds "github.com/ipfs/go-datastore/keytransform" - "github.com/libp2p/go-libp2p/core/crypto" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" @@ -24,8 +23,10 @@ import ( "github.com/rollkit/rollkit/pkg/config" genesispkg "github.com/rollkit/rollkit/pkg/genesis" "github.com/rollkit/rollkit/pkg/p2p" + "github.com/rollkit/rollkit/pkg/p2p/key" rpcserver "github.com/rollkit/rollkit/pkg/rpc/server" "github.com/rollkit/rollkit/pkg/service" + "github.com/rollkit/rollkit/pkg/signer" "github.com/rollkit/rollkit/pkg/store" "github.com/rollkit/rollkit/pkg/sync" ) @@ -68,7 +69,8 @@ type FullNode struct { func newFullNode( ctx context.Context, nodeConfig config.Config, - signingKey crypto.PrivKey, + signer signer.Signer, + nodeKey key.NodeKey, genesis genesispkg.Genesis, exec coreexecutor.Executor, sequencer coresequencer.Sequencer, @@ -83,7 +85,7 @@ func newFullNode( return nil, err } - p2pClient, err := p2p.NewClient(nodeConfig, genesis.ChainID, baseKV, logger.With("module", "p2p"), p2pMetrics) + p2pClient, err := p2p.NewClient(nodeConfig, genesis.ChainID, baseKV, logger.With("module", "p2p"), p2pMetrics, nodeKey) if err != nil { return nil, err } @@ -103,7 +105,7 @@ func newFullNode( blockManager, err := initBlockManager( ctx, - signingKey, + signer, exec, nodeConfig, genesis, @@ -185,7 +187,7 @@ func initDataSyncService( func initBlockManager( ctx context.Context, - signingKey crypto.PrivKey, + signer signer.Signer, exec coreexecutor.Executor, nodeConfig config.Config, genesis genesispkg.Genesis, @@ -212,7 +214,7 @@ func initBlockManager( blockManager, err := block.NewManager( ctx, - signingKey, + signer, nodeConfig, rollGen, store, diff --git a/node/full_node_integration_test.go b/node/full_node_integration_test.go index 27a23e5fac..318b6f38a3 100644 --- a/node/full_node_integration_test.go +++ b/node/full_node_integration_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "path/filepath" "sync" "testing" "time" @@ -17,6 +18,8 @@ import ( coreexecutor "github.com/rollkit/rollkit/core/execution" coresequencer "github.com/rollkit/rollkit/core/sequencer" rollkitconfig "github.com/rollkit/rollkit/pkg/config" + "github.com/rollkit/rollkit/pkg/p2p/key" + remote_signer "github.com/rollkit/rollkit/pkg/signer/noop" "github.com/rollkit/rollkit/types" ) @@ -62,13 +65,18 @@ func (s *FullNodeTestSuite) SetupTest() { // Create genesis with current time genesis, genesisValidatorKey, _ := types.GetGenesisWithPrivkey("test-chain") + remoteSigner, err := remote_signer.NewNoopSigner(genesisValidatorKey) + require.NoError(s.T(), err) dummyExec := coreexecutor.NewDummyExecutor() dummySequencer := coresequencer.NewDummySequencer() dummyDA := coreda.NewDummyDA(100_000, 0, 0) dummyClient := coreda.NewDummyClient(dummyDA, []byte(MockDANamespace)) - err := InitFiles(config.RootDir) + err = InitFiles(config.RootDir) + require.NoError(s.T(), err) + + nodeKey, err := key.LoadOrGenNodeKey(filepath.Join(config.RootDir, "config", "node_key.json")) require.NoError(s.T(), err) node, err := NewNode( @@ -77,7 +85,8 @@ func (s *FullNodeTestSuite) SetupTest() { dummyExec, dummySequencer, dummyClient, - genesisValidatorKey, + remoteSigner, + *nodeKey, genesis, DefaultMetricsProvider(rollkitconfig.DefaultInstrumentationConfig()), log.NewTestLogger(s.T()), @@ -314,13 +323,18 @@ func (s *FullNodeTestSuite) TestMaxPending() { config.Node.MaxPendingBlocks = 2 genesis, genesisValidatorKey, _ := types.GetGenesisWithPrivkey("test-chain") + remoteSigner, err := remote_signer.NewNoopSigner(genesisValidatorKey) + require.NoError(err) + + nodeKey, err := key.LoadOrGenNodeKey(filepath.Join(config.RootDir, "config", "node_key.json")) + require.NoError(err) dummyExec := coreexecutor.NewDummyExecutor() dummySequencer := coresequencer.NewDummySequencer() dummyDA := coreda.NewDummyDA(100_000, 0, 0) dummyClient := coreda.NewDummyClient(dummyDA, []byte(MockDANamespace)) - err := InitFiles(config.RootDir) + err = InitFiles(config.RootDir) require.NoError(err) node, err := NewNode( @@ -329,7 +343,8 @@ func (s *FullNodeTestSuite) TestMaxPending() { dummyExec, dummySequencer, dummyClient, - genesisValidatorKey, + remoteSigner, + *nodeKey, genesis, DefaultMetricsProvider(rollkitconfig.DefaultInstrumentationConfig()), log.NewTestLogger(s.T()), @@ -398,19 +413,25 @@ func (s *FullNodeTestSuite) TestStateRecovery() { // Create a NEW node instance instead of reusing the old one config := getTestConfig(s.T(), 1) genesis, genesisValidatorKey, _ := types.GetGenesisWithPrivkey("test-chain") + remoteSigner, err := remote_signer.NewNoopSigner(genesisValidatorKey) + require.NoError(err) dummyExec := coreexecutor.NewDummyExecutor() dummySequencer := coresequencer.NewDummySequencer() dummyDA := coreda.NewDummyDA(100_000, 0, 0) dummyClient := coreda.NewDummyClient(dummyDA, []byte(MockDANamespace)) + nodeKey, err := key.LoadOrGenNodeKey(filepath.Join(config.RootDir, "config", "node_key.json")) + require.NoError(err) + node, err := NewNode( s.ctx, config, dummyExec, dummySequencer, dummyClient, - genesisValidatorKey, + remoteSigner, + *nodeKey, genesis, DefaultMetricsProvider(rollkitconfig.DefaultInstrumentationConfig()), log.NewTestLogger(s.T()), diff --git a/node/helpers_test.go b/node/helpers_test.go index 9aea5bc815..95d6c9e168 100644 --- a/node/helpers_test.go +++ b/node/helpers_test.go @@ -3,6 +3,7 @@ package node import ( "context" "fmt" + "path/filepath" "testing" "time" @@ -13,6 +14,8 @@ import ( coreexecutor "github.com/rollkit/rollkit/core/execution" coresequencer "github.com/rollkit/rollkit/core/sequencer" rollkitconfig "github.com/rollkit/rollkit/pkg/config" + "github.com/rollkit/rollkit/pkg/p2p/key" + remote_signer "github.com/rollkit/rollkit/pkg/signer/noop" "github.com/rollkit/rollkit/types" ) @@ -45,13 +48,18 @@ func setupTestNodeWithCleanup(t *testing.T) (*FullNode, func()) { // Generate genesis and keys genesis, genesisValidatorKey, _ := types.GetGenesisWithPrivkey("test-chain") + remoteSigner, err := remote_signer.NewNoopSigner(genesisValidatorKey) + require.NoError(t, err) dummyExec := coreexecutor.NewDummyExecutor() dummySequencer := coresequencer.NewDummySequencer() dummyDA := coreda.NewDummyDA(100_000, 0, 0) dummyClient := coreda.NewDummyClient(dummyDA, []byte(MockDANamespace)) - err := InitFiles(config.RootDir) + err = InitFiles(config.RootDir) + require.NoError(t, err) + + nodeKey, err := key.LoadOrGenNodeKey(filepath.Join(config.RootDir, "node_key.json")) require.NoError(t, err) node, err := NewNode( @@ -60,7 +68,8 @@ func setupTestNodeWithCleanup(t *testing.T) (*FullNode, func()) { dummyExec, dummySequencer, dummyClient, - genesisValidatorKey, + remoteSigner, + *nodeKey, genesis, DefaultMetricsProvider(rollkitconfig.DefaultInstrumentationConfig()), log.NewTestLogger(t), diff --git a/node/light.go b/node/light.go index e618998a50..2b92024e40 100644 --- a/node/light.go +++ b/node/light.go @@ -13,6 +13,7 @@ import ( "github.com/rollkit/rollkit/pkg/config" "github.com/rollkit/rollkit/pkg/genesis" "github.com/rollkit/rollkit/pkg/p2p" + "github.com/rollkit/rollkit/pkg/p2p/key" rpcserver "github.com/rollkit/rollkit/pkg/rpc/server" "github.com/rollkit/rollkit/pkg/service" "github.com/rollkit/rollkit/pkg/store" @@ -37,6 +38,7 @@ func newLightNode( conf config.Config, genesis genesis.Genesis, metricsProvider MetricsProvider, + nodeKey key.NodeKey, logger log.Logger, ) (ln *LightNode, err error) { @@ -46,7 +48,7 @@ func newLightNode( if err != nil { return nil, err } - client, err := p2p.NewClient(conf, genesis.ChainID, datastore, logger.With("module", "p2p"), p2pMetrics) + client, err := p2p.NewClient(conf, genesis.ChainID, datastore, logger.With("module", "p2p"), p2pMetrics, nodeKey) if err != nil { return nil, err } diff --git a/node/node.go b/node/node.go index 33ff461563..e8024ffca2 100644 --- a/node/node.go +++ b/node/node.go @@ -4,14 +4,15 @@ import ( "context" "cosmossdk.io/log" - "github.com/libp2p/go-libp2p/core/crypto" coreda "github.com/rollkit/rollkit/core/da" coreexecutor "github.com/rollkit/rollkit/core/execution" coresequencer "github.com/rollkit/rollkit/core/sequencer" "github.com/rollkit/rollkit/pkg/config" "github.com/rollkit/rollkit/pkg/genesis" + "github.com/rollkit/rollkit/pkg/p2p/key" "github.com/rollkit/rollkit/pkg/service" + "github.com/rollkit/rollkit/pkg/signer" ) // Node is the interface for a rollup node @@ -23,26 +24,28 @@ type Node interface { // NewNode returns a new Full or Light Node based on the config // This is the entry point for composing a node, when compiling a node, you need to provide an executor -// Example executors can be found: TODO: add link +// Example executors can be found in rollups/ func NewNode( ctx context.Context, conf config.Config, exec coreexecutor.Executor, sequencer coresequencer.Sequencer, dac coreda.Client, - signingKey crypto.PrivKey, + signer signer.Signer, + nodeKey key.NodeKey, genesis genesis.Genesis, metricsProvider MetricsProvider, logger log.Logger, ) (Node, error) { if conf.Node.Light { - return newLightNode(conf, genesis, metricsProvider, logger) + return newLightNode(conf, genesis, metricsProvider, nodeKey, logger) } return newFullNode( ctx, conf, - signingKey, + signer, + nodeKey, genesis, exec, sequencer, diff --git a/node/node_integration_test.go b/node/node_integration_test.go index 010616deaa..a19f1be46c 100644 --- a/node/node_integration_test.go +++ b/node/node_integration_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "path/filepath" "sync" "testing" "time" @@ -18,6 +19,8 @@ import ( coreexecutor "github.com/rollkit/rollkit/core/execution" coresequencer "github.com/rollkit/rollkit/core/sequencer" rollkitconfig "github.com/rollkit/rollkit/pkg/config" + "github.com/rollkit/rollkit/pkg/p2p/key" + remote_signer "github.com/rollkit/rollkit/pkg/signer/noop" "github.com/rollkit/rollkit/types" ) @@ -44,6 +47,8 @@ func (s *NodeIntegrationTestSuite) SetupTest() { config.Node.MaxPendingBlocks = 100 // Allow more pending blocks genesis, genesisValidatorKey, _ := types.GetGenesisWithPrivkey("test-chain") + remoteSigner, err := remote_signer.NewNoopSigner(genesisValidatorKey) + require.NoError(s.T(), err) s.seqSrv = startMockSequencerServerGRPC(MockSequencerAddress) require.NotNil(s.T(), s.seqSrv) @@ -53,7 +58,10 @@ func (s *NodeIntegrationTestSuite) SetupTest() { dummyDA := coreda.NewDummyDA(100_000, 0, 0) dummyClient := coreda.NewDummyClient(dummyDA, []byte(MockDANamespace)) - err := InitFiles(config.RootDir) + err = InitFiles(config.RootDir) + require.NoError(s.T(), err) + + nodeKey, err := key.LoadOrGenNodeKey(filepath.Join(config.RootDir, "config", "node_key.json")) require.NoError(s.T(), err) node, err := NewNode( @@ -62,7 +70,8 @@ func (s *NodeIntegrationTestSuite) SetupTest() { dummyExec, dummySequencer, dummyClient, - genesisValidatorKey, + remoteSigner, + *nodeKey, genesis, DefaultMetricsProvider(rollkitconfig.DefaultInstrumentationConfig()), log.NewTestLogger(s.T()), diff --git a/node/node_test.go b/node/node_test.go index 9a970bb0f5..668871cf81 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "net" + "path/filepath" "sync" "testing" "time" @@ -20,6 +21,8 @@ import ( coreexecutor "github.com/rollkit/rollkit/core/execution" coresequencer "github.com/rollkit/rollkit/core/sequencer" rollkitconfig "github.com/rollkit/rollkit/pkg/config" + "github.com/rollkit/rollkit/pkg/p2p/key" + remote_signer "github.com/rollkit/rollkit/pkg/signer/noop" "github.com/rollkit/rollkit/types" ) @@ -179,13 +182,18 @@ func newTestNode(ctx context.Context, t *testing.T, nodeType NodeType, chainID s } genesis, genesisValidatorKey, _ := types.GetGenesisWithPrivkey(chainID) + remoteSigner, err := remote_signer.NewNoopSigner(genesisValidatorKey) + require.NoError(t, err) dummyExec := coreexecutor.NewDummyExecutor() dummySequencer := coresequencer.NewDummySequencer() dummyDA := coreda.NewDummyDA(100_000, 0, 0) dummyClient := coreda.NewDummyClient(dummyDA, []byte(MockDANamespace)) - err := InitFiles(config.RootDir) + err = InitFiles(config.RootDir) + require.NoError(t, err) + + nodeKey, err := key.LoadOrGenNodeKey(filepath.Join(config.RootDir, "config", "node_key.json")) require.NoError(t, err) logger := log.NewTestLogger(t) @@ -196,7 +204,8 @@ func newTestNode(ctx context.Context, t *testing.T, nodeType NodeType, chainID s dummyExec, dummySequencer, dummyClient, - genesisValidatorKey, + remoteSigner, + *nodeKey, genesis, DefaultMetricsProvider(rollkitconfig.DefaultInstrumentationConfig()), logger, diff --git a/pkg/cmd/init.go b/pkg/cmd/init.go index 04fde7b062..7ba6224726 100644 --- a/pkg/cmd/init.go +++ b/pkg/cmd/init.go @@ -1,15 +1,101 @@ package cmd import ( + "encoding/json" "fmt" "os" "path/filepath" + "time" "github.com/spf13/cobra" rollconf "github.com/rollkit/rollkit/pkg/config" + genesispkg "github.com/rollkit/rollkit/pkg/genesis" + "github.com/rollkit/rollkit/pkg/p2p/key" + "github.com/rollkit/rollkit/pkg/signer/file" ) +// ValidateHomePath checks if the home path is valid and not already initialized +func ValidateHomePath(homePath string) error { + if homePath == "" { + return fmt.Errorf("home path is required") + } + + configFilePath := filepath.Join(homePath, rollconf.RollkitConfigYaml) + if _, err := os.Stat(configFilePath); err == nil { + return fmt.Errorf("%s file already exists in the specified directory", rollconf.RollkitConfigYaml) + } + + return nil +} + +// InitializeConfig creates and initializes the configuration with default values +func InitializeConfig(homePath string, aggregator bool) rollconf.Config { + config := rollconf.DefaultNodeConfig + config.ConfigDir = homePath + config.RootDir = homePath + config.Node.Aggregator = aggregator + return config +} + +// InitializeSigner sets up the signer configuration and creates necessary files +func InitializeSigner(config *rollconf.Config, homePath string, passphrase string) error { + if config.Signer.SignerType == "file" && config.Node.Aggregator { + if passphrase == "" { + return fmt.Errorf("passphrase is required when using local file signer") + } + + signerDir := filepath.Join(homePath, "config") + if err := os.MkdirAll(signerDir, rollconf.DefaultDirPerm); err != nil { + return fmt.Errorf("failed to create signer directory: %w", err) + } + + config.Signer.SignerPath = filepath.Join(signerDir, "priv_key.json") + + _, err := file.NewFileSystemSigner(config.Signer.SignerPath, []byte(passphrase)) + if err != nil { + return fmt.Errorf("failed to initialize signer: %w", err) + } + } + return nil +} + +// InitializeNodeKey creates the node key file +func InitializeNodeKey(homePath string) error { + nodeKeyFile := filepath.Join(homePath, "config", "node_key.json") + _, err := key.LoadOrGenNodeKey(nodeKeyFile) + if err != nil { + return fmt.Errorf("failed to create node key: %w", err) + } + return nil +} + +// InitializeGenesis creates and saves a genesis file with the given app state +func InitializeGenesis(homePath string, chainID string, initialHeight uint64, appState []byte) error { + // Create an empty genesis file + genesisData := genesispkg.NewGenesis( + chainID, + initialHeight, + time.Now(), // Current time as genesis DA start height + genesispkg.GenesisExtraData{}, + json.RawMessage(appState), // App state from parameters + ) + + // Create the config directory if it doesn't exist + configDir := filepath.Join(homePath, "config") + if err := os.MkdirAll(configDir, rollconf.DefaultDirPerm); err != nil { + return fmt.Errorf("error creating config directory: %w", err) + } + + // Save the genesis file + genesisPath := filepath.Join(configDir, "genesis.json") + if err := genesispkg.SaveGenesis(genesisData, genesisPath); err != nil { + return fmt.Errorf("error writing genesis file: %w", err) + } + + return nil +} + // InitCmd initializes a new rollkit.yaml file in the current directory var InitCmd = &cobra.Command{ Use: "init", @@ -21,35 +107,69 @@ var InitCmd = &cobra.Command{ return fmt.Errorf("error reading home flag: %w", err) } - if homePath == "" { - return fmt.Errorf("home path is required") + if err := ValidateHomePath(homePath); err != nil { + return err } - configFilePath := filepath.Join(homePath, rollconf.RollkitConfigYaml) - if _, err := os.Stat(configFilePath); err == nil { - return fmt.Errorf("%s file already exists in the specified directory", rollconf.RollkitConfigYaml) + if err := os.MkdirAll(homePath, rollconf.DefaultDirPerm); err != nil { + return fmt.Errorf("error creating directory %s: %w", homePath, err) } - // Create a config with default values - config := rollconf.DefaultNodeConfig + aggregator, err := cmd.Flags().GetBool(rollconf.FlagAggregator) + if err != nil { + return fmt.Errorf("error reading aggregator flag: %w", err) + } - // Update with the values we found - config.ConfigDir = homePath + config := InitializeConfig(homePath, aggregator) - // Set the root directory to the specified home path - config.RootDir = homePath + passphrase, err := cmd.Flags().GetString(rollconf.FlagSignerPassphrase) + if err != nil { + return fmt.Errorf("error reading passphrase flag: %w", err) + } - // Make sure the home directory exists - if err := os.MkdirAll(homePath, rollconf.DefaultDirPerm); err != nil { - return fmt.Errorf("error creating directory %s: %w", homePath, err) + if err := InitializeSigner(&config, homePath, passphrase); err != nil { + return err } - // Use writeYamlConfig instead of manual marshaling and file writing if err := rollconf.WriteYamlConfig(config); err != nil { return fmt.Errorf("error writing rollkit.yaml file: %w", err) } + if err := InitializeNodeKey(homePath); err != nil { + return err + } + + // Get chain ID or use default + chainID, err := cmd.Flags().GetString(rollconf.FlagChainID) + if err != nil { + return fmt.Errorf("error reading chain ID flag: %w", err) + } + if chainID == "" { + chainID = "rollkit-test" + } + + // Initialize genesis with empty app state + if err := InitializeGenesis(homePath, chainID, 1, []byte("{}")); err != nil { + return fmt.Errorf("error initializing genesis file: %w", err) + } + fmt.Printf("Initialized %s file in %s\n", rollconf.RollkitConfigYaml, homePath) return nil }, } + +func init() { + InitFlags(InitCmd) +} + +func SignerFlags(cmd *cobra.Command) { + // Add passphrase flag + cmd.Flags().String(rollconf.FlagSignerPassphrase, "", "Passphrase for encrypting the local signer key (required when using local file signer)") + cmd.Flags().Bool(rollconf.FlagAggregator, false, "Run node in aggregator mode") +} + +// InitFlags adds init command flags +func InitFlags(cmd *cobra.Command) { + SignerFlags(cmd) + cmd.Flags().String(rollconf.FlagChainID, "rollkit-test", "Chain ID for the genesis file") +} diff --git a/pkg/cmd/init_test.go b/pkg/cmd/init_test.go index d05b97e23e..67e0fa7150 100644 --- a/pkg/cmd/init_test.go +++ b/pkg/cmd/init_test.go @@ -27,7 +27,7 @@ func TestInitCommand(t *testing.T) { require.NoError(t, os.Chdir(dir)) // Remove any existing rollkit.yaml files in the test directory - configPath := filepath.Join(dir, rollconf.RollkitConfigYaml) + configPath := filepath.Join(dir, "config", rollconf.RollkitConfigYaml) _ = os.Remove(configPath) // Ignore error if file doesn't exist // Create a new test-specific command @@ -54,7 +54,7 @@ func TestInitCommand(t *testing.T) { require.NoError(t, err) // Verify the config can be read - _, err = rollconf.ReadYaml(dir) + _, err = rollconf.ReadYaml(filepath.Join(dir, "config")) require.NoError(t, err) // Read the file content directly to verify the YAML structure diff --git a/pkg/cmd/run_node.go b/pkg/cmd/run_node.go index 1ffa6057fe..84dd71af69 100644 --- a/pkg/cmd/run_node.go +++ b/pkg/cmd/run_node.go @@ -2,7 +2,6 @@ package cmd import ( "context" - "encoding/json" "errors" "fmt" "os" @@ -12,7 +11,6 @@ import ( "time" "cosmossdk.io/log" - cometprivval "github.com/cometbft/cometbft/privval" "github.com/rs/zerolog" "github.com/spf13/cobra" @@ -22,43 +20,41 @@ import ( "github.com/rollkit/rollkit/node" rollconf "github.com/rollkit/rollkit/pkg/config" genesispkg "github.com/rollkit/rollkit/pkg/genesis" - rollos "github.com/rollkit/rollkit/pkg/os" + "github.com/rollkit/rollkit/pkg/p2p/key" "github.com/rollkit/rollkit/pkg/signer" + "github.com/rollkit/rollkit/pkg/signer/file" ) var ( - // initialize the rollkit node configuration - nodeConfig = rollconf.DefaultNodeConfig +// initialize the rollkit node configuration - // initialize the logger with the cometBFT defaults - logger = log.NewLogger(os.Stdout) ) -func parseConfig(cmd *cobra.Command) error { +func parseConfig(cmd *cobra.Command) (rollconf.Config, error) { // Load configuration with the correct order of precedence: // DefaultNodeConfig -> Yaml -> Flags var err error - nodeConfig, err = rollconf.LoadNodeConfig(cmd) + nodeConfig, err := rollconf.LoadNodeConfig(cmd) if err != nil { - return fmt.Errorf("failed to load node config: %w", err) + return rollconf.Config{}, fmt.Errorf("failed to load node config: %w", err) } // Validate the root directory if err := rollconf.EnsureRoot(nodeConfig.RootDir); err != nil { - return fmt.Errorf("failed to ensure root directory: %w", err) + return rollconf.Config{}, fmt.Errorf("failed to ensure root directory: %w", err) } - return nil + return nodeConfig, nil } -// setupLogger configures and returns a logger based on the provided configuration. +// SetupLogger configures and returns a logger based on the provided configuration. // It applies the following settings from the config: // - Log format (text or JSON) // - Log level (debug, info, warn, error) // - Stack traces for error logs // // The returned logger is already configured with the "module" field set to "main". -func setupLogger(config rollconf.LogConfig) log.Logger { +func SetupLogger(config rollconf.LogConfig) log.Logger { var logOptions []log.Option // Configure logger format @@ -100,7 +96,6 @@ func NewRunNodeCmd( executor coreexecutor.Executor, sequencer coresequencer.Sequencer, dac coreda.Client, - keyProvider signer.KeyProvider, ) *cobra.Command { if executor == nil { panic("executor cannot be nil") @@ -111,26 +106,13 @@ func NewRunNodeCmd( if dac == nil { panic("da client cannot be nil") } - if keyProvider == nil { - panic("key provider cannot be nil") - } cmd := &cobra.Command{ Use: "start", Aliases: []string{"node", "run"}, Short: "Run the rollkit node", - // PersistentPreRunE is used to parse the config and initial the config files - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - if err := parseConfig(cmd); err != nil { - return err - } - - logger = setupLogger(nodeConfig.Log) - - return initConfigFiles() - }, RunE: func(cmd *cobra.Command, args []string) error { - return startNode(cmd, executor, sequencer, dac, keyProvider) + return startNode(cmd, executor, sequencer, dac) }, } @@ -140,79 +122,39 @@ func NewRunNodeCmd( return cmd } -// initConfigFiles initializes the config and data directories -func initConfigFiles() error { - // Create config and data directories using nodeConfig values - configDir := filepath.Join(nodeConfig.RootDir, nodeConfig.ConfigDir) - dataDir := filepath.Join(nodeConfig.RootDir, nodeConfig.DBPath) - - if err := os.MkdirAll(configDir, rollconf.DefaultDirPerm); err != nil { - return fmt.Errorf("failed to create config directory: %w", err) - } - - if err := os.MkdirAll(dataDir, rollconf.DefaultDirPerm); err != nil { - return fmt.Errorf("failed to create data directory: %w", err) - } - - // Generate the private validator config files - cometprivvalKeyFile := filepath.Join(configDir, "priv_validator_key.json") - cometprivvalStateFile := filepath.Join(dataDir, "priv_validator_state.json") - if rollos.FileExists(cometprivvalKeyFile) { - logger.Info("Found private validator", "keyFile", cometprivvalKeyFile, - "stateFile", cometprivvalStateFile) - } else { - pv := cometprivval.GenFilePV(cometprivvalKeyFile, cometprivvalStateFile) - pv.Save() - logger.Info("Generated private validator", "keyFile", cometprivvalKeyFile, - "stateFile", cometprivvalStateFile) - } - - // Generate the genesis file - genFile := filepath.Join(configDir, "genesis.json") - if rollos.FileExists(genFile) { - logger.Info("Found genesis file", "path", genFile) - } else { - // Create a default genesis - genesis := genesispkg.NewGenesis( - "test-chain", - uint64(1), - time.Now(), - genesispkg.GenesisExtraData{}, // No proposer address for now - nil, // No raw bytes for now - ) - - // Marshal the genesis struct directly - genesisBytes, err := json.MarshalIndent(genesis, "", " ") - if err != nil { - return fmt.Errorf("failed to marshal genesis: %w", err) - } - - // Write genesis bytes directly to file - if err := os.WriteFile(genFile, genesisBytes, 0600); err != nil { - return fmt.Errorf("failed to write genesis file: %w", err) - } - logger.Info("Generated genesis file", "path", genFile) - } - - return nil -} - // startNode handles the node startup logic -func startNode(cmd *cobra.Command, executor coreexecutor.Executor, sequencer coresequencer.Sequencer, dac coreda.Client, keyProvider signer.KeyProvider) error { +func startNode(cmd *cobra.Command, executor coreexecutor.Executor, sequencer coresequencer.Sequencer, dac coreda.Client) error { ctx, cancel := context.WithCancel(cmd.Context()) defer cancel() - if err := parseConfig(cmd); err != nil { + nodeConfig, err := parseConfig(cmd) + if err != nil { return fmt.Errorf("failed to parse config: %w", err) } + logger := SetupLogger(nodeConfig.Log) - if err := initConfigFiles(); err != nil { - return fmt.Errorf("failed to initialize files: %w", err) + //create a new remote signer + var signer signer.Signer + if nodeConfig.Signer.SignerType == "file" { + passphrase, err := cmd.Flags().GetString(rollconf.FlagSignerPassphrase) + if err != nil { + return err + } + + signer, err = file.NewFileSystemSigner(nodeConfig.Signer.SignerPath, []byte(passphrase)) + if err != nil { + return err + } + } else if nodeConfig.Signer.SignerType == "grpc" { + panic("grpc remote signer not implemented") + } else { + return fmt.Errorf("unknown remote signer type: %s", nodeConfig.Signer.SignerType) } - signingKey, err := keyProvider.GetSigningKey() + nodeKeyFile := filepath.Join(nodeConfig.RootDir, "config", "node_key.json") + nodeKey, err := key.LoadOrGenNodeKey(nodeKeyFile) if err != nil { - return fmt.Errorf("failed to get signing key: %w", err) + return fmt.Errorf("failed to load node key: %w", err) } metrics := node.DefaultMetricsProvider(rollconf.DefaultInstrumentationConfig()) @@ -230,7 +172,8 @@ func startNode(cmd *cobra.Command, executor coreexecutor.Executor, sequencer cor executor, sequencer, dac, - signingKey, + signer, + *nodeKey, genesis, metrics, logger, diff --git a/pkg/cmd/run_node_test.go b/pkg/cmd/run_node_test.go index adc345dae3..961b687bd2 100644 --- a/pkg/cmd/run_node_test.go +++ b/pkg/cmd/run_node_test.go @@ -3,7 +3,6 @@ package cmd import ( "context" "os" - "path/filepath" "reflect" "testing" "time" @@ -16,23 +15,22 @@ import ( coresequencer "github.com/rollkit/rollkit/core/sequencer" "github.com/rollkit/rollkit/da" rollconf "github.com/rollkit/rollkit/pkg/config" - "github.com/rollkit/rollkit/pkg/signer" testExecutor "github.com/rollkit/rollkit/rollups/testapp/kv" ) -func createTestComponents(ctx context.Context) (coreexecutor.Executor, coresequencer.Sequencer, coreda.Client, signer.KeyProvider) { +func createTestComponents(ctx context.Context) (coreexecutor.Executor, coresequencer.Sequencer, coreda.Client) { executor := testExecutor.CreateDirectKVExecutor(ctx) sequencer := coresequencer.NewDummySequencer() dummyDA := coreda.NewDummyDA(100_000, 0, 0) logger := log.NewLogger(os.Stdout) dac := da.NewDAClient(dummyDA, 0, 1.0, []byte("test"), []byte(""), logger) - keyProvider := signer.NewFileKeyProvider("", "config", "data") - return executor, sequencer, dac, keyProvider + + return executor, sequencer, dac } func TestParseFlags(t *testing.T) { // Initialize nodeConfig with default values to avoid issues with instrument - nodeConfig = rollconf.DefaultNodeConfig + nodeConfig := rollconf.DefaultNodeConfig flags := []string{ "--home", "custom/root/dir", @@ -73,9 +71,9 @@ func TestParseFlags(t *testing.T) { args := append([]string{"start"}, flags...) - executor, sequencer, dac, keyProvider := createTestComponents(context.Background()) + executor, sequencer, dac := createTestComponents(context.Background()) - newRunNodeCmd := NewRunNodeCmd(executor, sequencer, dac, keyProvider) + newRunNodeCmd := NewRunNodeCmd(executor, sequencer, dac) // Register root flags to be able to use --home flag rollconf.AddBasicFlags(newRunNodeCmd, "testapp") @@ -84,7 +82,8 @@ func TestParseFlags(t *testing.T) { t.Errorf("Error: %v", err) } - if err := parseConfig(newRunNodeCmd); err != nil { + nodeConfig, err := parseConfig(newRunNodeCmd) + if err != nil { t.Errorf("Error: %v", err) } @@ -151,15 +150,16 @@ func TestAggregatorFlagInvariants(t *testing.T) { for i, flags := range flagVariants { args := append([]string{"start"}, flags...) - executor, sequencer, dac, keyProvider := createTestComponents(context.Background()) + executor, sequencer, dac := createTestComponents(context.Background()) - newRunNodeCmd := NewRunNodeCmd(executor, sequencer, dac, keyProvider) + newRunNodeCmd := NewRunNodeCmd(executor, sequencer, dac) if err := newRunNodeCmd.ParseFlags(args); err != nil { t.Errorf("Error: %v", err) } - if err := parseConfig(newRunNodeCmd); err != nil { + nodeConfig, err := parseConfig(newRunNodeCmd) + if err != nil { t.Errorf("Error: %v", err) } @@ -173,24 +173,25 @@ func TestAggregatorFlagInvariants(t *testing.T) { // when no flag is specified func TestDefaultAggregatorValue(t *testing.T) { // Reset nodeConfig to default values - nodeConfig = rollconf.DefaultNodeConfig + nodeConfig := rollconf.DefaultNodeConfig // Create a new command without specifying any flags args := []string{"start"} - executor, sequencer, dac, keyProvider := createTestComponents(context.Background()) + executor, sequencer, dac := createTestComponents(context.Background()) - newRunNodeCmd := NewRunNodeCmd(executor, sequencer, dac, keyProvider) + newRunNodeCmd := NewRunNodeCmd(executor, sequencer, dac) if err := newRunNodeCmd.ParseFlags(args); err != nil { t.Errorf("Error parsing flags: %v", err) } - if err := parseConfig(newRunNodeCmd); err != nil { + nodeConfig, err := parseConfig(newRunNodeCmd) + if err != nil { t.Errorf("Error parsing config: %v", err) } // Verify that Aggregator is true by default - assert.True(t, nodeConfig.Node.Aggregator, "Expected Aggregator to be true by default") + assert.False(t, nodeConfig.Node.Aggregator, "Expected Aggregator to be false by default") } // TestCentralizedAddresses verifies that when centralized service flags are provided, @@ -203,13 +204,14 @@ func TestCentralizedAddresses(t *testing.T) { "--node.sequencer_rollup_id=centralrollup", } - executor, sequencer, dac, keyProvider := createTestComponents(context.Background()) + executor, sequencer, dac := createTestComponents(context.Background()) - cmd := NewRunNodeCmd(executor, sequencer, dac, keyProvider) + cmd := NewRunNodeCmd(executor, sequencer, dac) if err := cmd.ParseFlags(args); err != nil { t.Fatalf("ParseFlags error: %v", err) } - if err := parseConfig(cmd); err != nil { + nodeConfig, err := parseConfig(cmd) + if err != nil { t.Fatalf("parseConfig error: %v", err) } @@ -226,51 +228,3 @@ func TestCentralizedAddresses(t *testing.T) { t.Error("Expected flag \"rollkit.sequencer_rollup_id\" to be marked as changed") } } - -func TestInitFiles(t *testing.T) { - // Save the original nodeConfig - origNodeConfig := nodeConfig - - // Create a temporary directory for the test - tempDir, err := os.MkdirTemp("", "rollkit-test") - assert.NoError(t, err) - defer func() { - err := os.RemoveAll(tempDir) - assert.NoError(t, err) - }() - - // Create the necessary subdirectories - configDir := filepath.Join(tempDir, "config") - dataDir := filepath.Join(tempDir, "data") - err = os.MkdirAll(configDir, rollconf.DefaultDirPerm) - assert.NoError(t, err) - err = os.MkdirAll(dataDir, rollconf.DefaultDirPerm) - assert.NoError(t, err) - - // Set the nodeConfig to use the temporary directory - nodeConfig = rollconf.Config{ - RootDir: tempDir, - ConfigDir: "config", - DBPath: "data", - } - - // Restore the original nodeConfig when the test completes - defer func() { - nodeConfig = origNodeConfig - }() - - // Call initFiles - err = initConfigFiles() - assert.NoError(t, err) - - // Verify that the expected files were created - files := []string{ - filepath.Join(tempDir, "config", "priv_validator_key.json"), - filepath.Join(tempDir, "data", "priv_validator_state.json"), - filepath.Join(tempDir, "config", "genesis.json"), - } - - for _, file := range files { - assert.FileExists(t, file) - } -} diff --git a/pkg/config/config.go b/pkg/config/config.go index 3cdffe87cd..ce2ac9f9e9 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -21,6 +21,8 @@ const ( FlagDBPath = "db_path" // FlagChainConfigDir is a flag for specifying the chain config directory FlagChainConfigDir = "config_dir" + // FlagChainID is a flag for specifying the chain ID + FlagChainID = "chain_id" // Node configuration flags @@ -99,6 +101,17 @@ const ( // FlagLogTrace is a flag for enabling stack traces in error logs FlagLogTrace = "log.trace" + // Signer configuration flags + + // FlagSignerType is a flag for specifying the signer type + FlagSignerType = "signer.type" + // FlagSignerPath is a flag for specifying the signer path + FlagSignerPath = "signer.path" + + // FlagSignerPassphrase is a flag for specifying the signer passphrase + //nolint:gosec + FlagSignerPassphrase = "signer.passphrase" + // RPC configuration flags // FlagRPCAddress is a flag for specifying the RPC server address @@ -131,7 +144,7 @@ type Config struct { RootDir string `mapstructure:"home" yaml:"home" comment:"Root directory where rollkit files are located"` DBPath string `mapstructure:"db_path" yaml:"db_path" comment:"Path inside the root directory where the database is located"` ConfigDir string `mapstructure:"config_dir" yaml:"config_dir" comment:"Directory containing the rollup chain configuration"` - + ChainID string `mapstructure:"chain_id" yaml:"chain_id" comment:"Chain ID for the rollup"` // P2P configuration P2P P2PConfig `mapstructure:"p2p" yaml:"p2p"` @@ -149,6 +162,9 @@ type Config struct { // Logging configuration Log LogConfig `mapstructure:"log" yaml:"log"` + + // Remote signer configuration + Signer SignerConfig `mapstructure:"signer" yaml:"signer"` } // DAConfig contains all Data Availability configuration parameters @@ -200,6 +216,12 @@ type P2PConfig struct { AllowedPeers string `mapstructure:"allowed_peers" yaml:"allowed_peers" comment:"Comma separated list of peer IDs to allow connections from"` } +// SignerConfig contains all signer configuration parameters +type SignerConfig struct { + SignerType string `mapstructure:"signer_type" yaml:"signer_type" comment:"Type of remote signer to use (file, grpc)"` + SignerPath string `mapstructure:"signer_path" yaml:"signer_path" comment:"Path to the signer file or address"` +} + // AddBasicFlags registers the basic configuration flags that are common across applications // This includes logging configuration and root directory settings func AddBasicFlags(cmd *cobra.Command, appName string) { @@ -226,7 +248,7 @@ func AddFlags(cmd *cobra.Command) { cmd.Flags().String(FlagRootDir, DefaultNodeConfig.RootDir, "root directory for config and data") cmd.Flags().String(FlagDBPath, DefaultNodeConfig.DBPath, "path for the node database") cmd.Flags().String(FlagChainConfigDir, DefaultNodeConfig.ConfigDir, "directory containing chain configuration files") - + cmd.Flags().String(FlagChainID, DefaultNodeConfig.ChainID, "chain ID") // Node configuration flags cmd.Flags().BoolVar(&def.Node.Aggregator, FlagAggregator, def.Node.Aggregator, "run node in aggregator mode") cmd.Flags().Bool(FlagLight, def.Node.Light, "run light client") @@ -267,6 +289,16 @@ func AddFlags(cmd *cobra.Command) { cmd.Flags().Int(FlagMaxOpenConnections, instrDef.MaxOpenConnections, "maximum number of simultaneous connections for metrics") cmd.Flags().Bool(FlagPprof, instrDef.Pprof, "enable pprof HTTP endpoint") cmd.Flags().String(FlagPprofListenAddr, instrDef.PprofListenAddr, "pprof HTTP server listening address") + + // Logging configuration flags + cmd.Flags().String(FlagLogLevel, "info", "log level (debug, info, warn, error)") + cmd.Flags().String(FlagLogFormat, "", "log format (text, json)") + cmd.Flags().Bool(FlagLogTrace, false, "enable stack traces in error logs") + + // Signer configuration flags + cmd.Flags().String(FlagSignerType, def.Signer.SignerType, "type of signer to use (file, grpc)") + cmd.Flags().String(FlagSignerPath, def.Signer.SignerPath, "path to the signer file or address") + cmd.Flags().String(FlagSignerPassphrase, "", "passphrase for the signer (required for file signer and if aggregator is enabled)") } // LoadNodeConfig loads the node configuration in the following order of precedence: @@ -392,4 +424,8 @@ func setDefaultsInViper(v *viper.Viper, config Config) { v.SetDefault(FlagLogLevel, "info") v.SetDefault(FlagLogFormat, "") v.SetDefault(FlagLogTrace, false) + + // Signer configuration defaults + v.SetDefault(FlagSignerType, config.Signer.SignerType) + v.SetDefault(FlagSignerPath, config.Signer.SignerPath) } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 773154fab6..82030aa1cf 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -19,7 +19,7 @@ func TestDefaultNodeConfig(t *testing.T) { assert.Equal(t, DefaultRootDir(), def.RootDir) assert.Equal(t, "data", def.DBPath) - assert.Equal(t, true, def.Node.Aggregator) + assert.Equal(t, false, def.Node.Aggregator) assert.Equal(t, false, def.Node.Light) assert.Equal(t, DefaultDAAddress, def.DA.Address) assert.Equal(t, "", def.DA.AuthToken) @@ -97,7 +97,7 @@ func TestAddFlags(t *testing.T) { assertFlagValue(t, persistentFlags, FlagLogTrace, false) // Count the number of flags we're explicitly checking - expectedFlagCount := 38 // Update this number to include all flags (34 regular + 4 persistent) + expectedFlagCount := 45 // Update this number if you add more flag checks above // Get the actual number of flags (both regular and persistent) actualFlagCount := 0 diff --git a/pkg/config/defaults.go b/pkg/config/defaults.go index 33f30839d7..7f0be4d757 100644 --- a/pkg/config/defaults.go +++ b/pkg/config/defaults.go @@ -16,6 +16,9 @@ const ( // DefaultDataDir is the default directory for data files (e.g. database). DefaultDataDir = "data" + // DefaultSignerPath is the default path for the signer file + DefaultSignerPath = "signer" + // DefaultListenAddress is a default listen address for P2P client. DefaultListenAddress = "/ip4/0.0.0.0/tcp/7676" // Version is the current rollkit version @@ -35,7 +38,7 @@ const ( // DefaultRootDir returns the default root directory for rollkit func DefaultRootDir() string { - return DefaultRootDirWithName("rollkit") + return DefaultRootDirWithName(".rollkit") } // DefaultRootDirWithName returns the default root directory for an application, @@ -53,12 +56,13 @@ var DefaultNodeConfig = Config{ RootDir: DefaultRootDir(), DBPath: DefaultDataDir, ConfigDir: DefaultConfigDir, + ChainID: "rollkit-test", P2P: P2PConfig{ ListenAddress: DefaultListenAddress, Seeds: "", }, Node: NodeConfig{ - Aggregator: true, + Aggregator: false, BlockTime: DurationWrapper{1 * time.Second}, LazyAggregator: false, LazyBlockTime: DurationWrapper{60 * time.Second}, @@ -80,6 +84,10 @@ var DefaultNodeConfig = Config{ Format: "", Trace: false, }, + Signer: SignerConfig{ + SignerType: "file", + SignerPath: DefaultSignerPath, + }, RPC: RPCConfig{ Address: "127.0.0.1", Port: 7331, diff --git a/pkg/config/yaml.go b/pkg/config/yaml.go index 3bb5dccc4b..5d9696fe28 100644 --- a/pkg/config/yaml.go +++ b/pkg/config/yaml.go @@ -124,7 +124,7 @@ func findConfigFile(startDir string) (string, error) { // It ensures the directory exists and writes the configuration with proper permissions. func WriteYamlConfig(config Config) error { // Configure the output file - configPath := filepath.Join(config.RootDir, RollkitConfigYaml) + configPath := filepath.Join(config.RootDir, "config", RollkitConfigYaml) // Ensure the directory exists if err := os.MkdirAll(filepath.Dir(configPath), DefaultDirPerm); err != nil { diff --git a/pkg/config/yaml_test.go b/pkg/config/yaml_test.go index 94b09ac5d6..56e53eab6e 100644 --- a/pkg/config/yaml_test.go +++ b/pkg/config/yaml_test.go @@ -55,7 +55,9 @@ func TestReadYaml(t *testing.T) { name: "sets RootDir even if empty yaml", setup: func(t *testing.T, dir string) error { // Create empty YAML file - return os.WriteFile(filepath.Join(dir, RollkitConfigYaml), []byte(""), 0600) + err := os.MkdirAll(filepath.Join(dir, "config"), 0755) + require.NoError(t, err) + return os.WriteFile(filepath.Join(dir, "config", RollkitConfigYaml), []byte(""), 0600) }, validate: func(t *testing.T, cfg Config, err error) { require.NoError(t, err) @@ -66,7 +68,9 @@ func TestReadYaml(t *testing.T) { name: "returns error if config file cannot be decoded", setup: func(t *testing.T, dir string) error { // Create invalid YAML file - return os.WriteFile(filepath.Join(dir, RollkitConfigYaml), []byte("invalid: yaml: content"), 0600) + err := os.MkdirAll(filepath.Join(dir, "config"), 0755) + require.NoError(t, err) + return os.WriteFile(filepath.Join(dir, "config", RollkitConfigYaml), []byte("invalid: yaml: content"), 0600) }, validate: func(t *testing.T, cfg Config, err error) { require.Error(t, err) @@ -85,7 +89,7 @@ func TestReadYaml(t *testing.T) { require.NoError(t, err) // Read the config - cfg, err := ReadYaml(tempDir) + cfg, err := ReadYaml(filepath.Join(tempDir, "config")) // Validate the result tc.validate(t, cfg, err) @@ -143,16 +147,18 @@ func TestYamlConfigOperations(t *testing.T) { // Create a temporary directory for each test case tempDir := t.TempDir() + path := filepath.Join(tempDir, "config") + // Setup the test case and write the initial config tc.setup(t, tempDir) // Verify the config file exists - configPath := filepath.Join(tempDir, RollkitConfigYaml) + configPath := filepath.Join(path, RollkitConfigYaml) _, err := os.Stat(configPath) require.NoError(t, err, "Config file should exist") // Read the config back - cfg, err := ReadYaml(tempDir) + cfg, err := ReadYaml(path) require.NoError(t, err) // Validate the config diff --git a/pkg/genesis/genesis.go b/pkg/genesis/genesis.go index 55f163f59c..5028307fd0 100644 --- a/pkg/genesis/genesis.go +++ b/pkg/genesis/genesis.go @@ -8,9 +8,7 @@ import ( // GenesisExtraData represents the flexible configuration data in genesis type GenesisExtraData struct { - ProposerAddress []byte `json:"proposer_address,omitempty"` - Validators []ValidatorInfo `json:"validators,omitempty"` - ConsensusParams map[string]string `json:"consensus_params,omitempty"` + ProposerAddress []byte `json:"proposer_address,omitempty"` } // ValidatorInfo represents a validator's configuration in genesis diff --git a/pkg/genesis/genesis_test.go b/pkg/genesis/genesis_test.go index bd5b62b82d..d42e270656 100644 --- a/pkg/genesis/genesis_test.go +++ b/pkg/genesis/genesis_test.go @@ -21,12 +21,6 @@ func TestGenesis_Validate(t *testing.T) { InitialHeight: 1, ExtraData: GenesisExtraData{ ProposerAddress: []byte("proposer"), - Validators: []ValidatorInfo{ - { - Address: []byte("validator"), - PublicKey: []byte("pubkey"), - }, - }, }, AppState: json.RawMessage(`{}`), }, diff --git a/pkg/genesis/io_test.go b/pkg/genesis/io_test.go index 10b3e1f734..00efcfd991 100644 --- a/pkg/genesis/io_test.go +++ b/pkg/genesis/io_test.go @@ -35,12 +35,6 @@ func TestLoadAndSaveGenesis(t *testing.T) { GenesisDAStartHeight: validTime, ExtraData: GenesisExtraData{ ProposerAddress: []byte("proposer-address"), - Validators: []ValidatorInfo{ - { - Address: []byte("validator-1"), - PublicKey: []byte("pubkey-1"), - }, - }, }, AppState: json.RawMessage(`{"key": "value"}`), }, diff --git a/pkg/p2p/client.go b/pkg/p2p/client.go index dbd573977e..45df0e055e 100644 --- a/pkg/p2p/client.go +++ b/pkg/p2p/client.go @@ -5,7 +5,6 @@ import ( "encoding/hex" "errors" "fmt" - "path/filepath" "strings" "time" @@ -64,7 +63,14 @@ type Client struct { // // Basic checks on parameters are done, and default parameters are provided for unset-configuration // TODO(tzdybal): consider passing entire config, not just P2P config, to reduce number of arguments -func NewClient(conf config.Config, chainID string, ds datastore.Datastore, logger log.Logger, metrics *Metrics) (*Client, error) { +func NewClient( + conf config.Config, + chainID string, + ds datastore.Datastore, + logger log.Logger, + metrics *Metrics, + nodeKey key.NodeKey, +) (*Client, error) { if conf.RootDir == "" { return nil, fmt.Errorf("rootDir is required") } @@ -78,12 +84,6 @@ func NewClient(conf config.Config, chainID string, ds datastore.Datastore, logge return nil, fmt.Errorf("failed to create connection gater: %w", err) } - nodeKeyFile := filepath.Join(conf.RootDir, "config", "node_key.json") - nodeKey, err := key.LoadOrGenNodeKey(nodeKeyFile) - if err != nil { - return nil, err - } - return &Client{ conf: conf.P2P, gater: gater, diff --git a/pkg/p2p/client_test.go b/pkg/p2p/client_test.go index a054df5e36..7cee013e0c 100644 --- a/pkg/p2p/client_test.go +++ b/pkg/p2p/client_test.go @@ -16,6 +16,7 @@ import ( "github.com/stretchr/testify/require" "github.com/rollkit/rollkit/pkg/config" + "github.com/rollkit/rollkit/pkg/p2p/key" ) func TestClientStartup(t *testing.T) { @@ -57,8 +58,11 @@ func TestClientStartup(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { + nodeKey, err := key.LoadOrGenNodeKey(filepath.Join(testCase.conf.RootDir, "config", "node_key.json")) + require.NoError(t, err) + client, err := NewClient(testCase.conf, "TestChain", - dssync.MutexWrap(datastore.NewMapDatastore()), log.NewTestLogger(t), NopMetrics()) + dssync.MutexWrap(datastore.NewMapDatastore()), log.NewTestLogger(t), NopMetrics(), *nodeKey) assert.NoError(err) assert.NotNil(client) @@ -157,12 +161,16 @@ func TestSeedStringParsing(t *testing.T) { tempDir := t.TempDir() ClientInitFiles(t, tempDir) + nodeKey, err := key.LoadOrGenNodeKey(filepath.Join(tempDir, "config", "node_key.json")) + require.NoError(err) + client, err := NewClient( config.Config{RootDir: tempDir}, "TestNetwork", dssync.MutexWrap(datastore.NewMapDatastore()), logger, NopMetrics(), + *nodeKey, ) require.NoError(err) require.NotNil(client) diff --git a/pkg/p2p/utils_test.go b/pkg/p2p/utils_test.go index 94ea151330..aaf1bda265 100644 --- a/pkg/p2p/utils_test.go +++ b/pkg/p2p/utils_test.go @@ -20,6 +20,7 @@ import ( "github.com/stretchr/testify/require" "github.com/rollkit/rollkit/pkg/config" + "github.com/rollkit/rollkit/pkg/p2p/key" ) type testNet []*Client @@ -108,6 +109,9 @@ func startTestNetwork(ctx context.Context, t *testing.T, n int, conf map[int]hos for i := 0; i < n; i++ { tempDir := filepath.Join(t.TempDir(), fmt.Sprintf("client_%d", i)) ClientInitFiles(t, tempDir) + nodeKey, err := key.LoadOrGenNodeKey(filepath.Join(tempDir, "config", "node_key.json")) + require.NoError(err) + client, err := NewClient( config.Config{ RootDir: tempDir, @@ -119,6 +123,7 @@ func startTestNetwork(ctx context.Context, t *testing.T, n int, conf map[int]hos sync.MutexWrap(datastore.NewMapDatastore()), logger, NopMetrics(), + *nodeKey, ) require.NoError(err) require.NotNil(client) diff --git a/pkg/rpc/client/client.go b/pkg/rpc/client/client.go index 38145ea184..cfb3305d36 100644 --- a/pkg/rpc/client/client.go +++ b/pkg/rpc/client/client.go @@ -10,13 +10,13 @@ import ( rpc "github.com/rollkit/rollkit/types/pb/rollkit/v1/v1connect" ) -// StoreClient is the client for the StoreService -type StoreClient struct { +// Client is the client for the StoreService +type Client struct { client rpc.StoreServiceClient } // NewStoreClient creates a new StoreClient -func NewStoreClient(baseURL string) *StoreClient { +func NewClient(baseURL string) *Client { httpClient := http.DefaultClient client := rpc.NewStoreServiceClient( httpClient, @@ -24,13 +24,13 @@ func NewStoreClient(baseURL string) *StoreClient { connect.WithGRPC(), ) - return &StoreClient{ + return &Client{ client: client, } } // GetBlockByHeight returns a block by height -func (c *StoreClient) GetBlockByHeight(ctx context.Context, height uint64) (*pb.Block, error) { +func (c *Client) GetBlockByHeight(ctx context.Context, height uint64) (*pb.Block, error) { req := connect.NewRequest(&pb.GetBlockRequest{ Identifier: &pb.GetBlockRequest_Height{ Height: height, @@ -46,7 +46,7 @@ func (c *StoreClient) GetBlockByHeight(ctx context.Context, height uint64) (*pb. } // GetBlockByHash returns a block by hash -func (c *StoreClient) GetBlockByHash(ctx context.Context, hash []byte) (*pb.Block, error) { +func (c *Client) GetBlockByHash(ctx context.Context, hash []byte) (*pb.Block, error) { req := connect.NewRequest(&pb.GetBlockRequest{ Identifier: &pb.GetBlockRequest_Hash{ Hash: hash, @@ -62,7 +62,7 @@ func (c *StoreClient) GetBlockByHash(ctx context.Context, hash []byte) (*pb.Bloc } // GetState returns the current state -func (c *StoreClient) GetState(ctx context.Context) (*pb.State, error) { +func (c *Client) GetState(ctx context.Context) (*pb.State, error) { req := connect.NewRequest(&pb.GetStateRequest{}) resp, err := c.client.GetState(ctx, req) if err != nil { @@ -73,7 +73,7 @@ func (c *StoreClient) GetState(ctx context.Context) (*pb.State, error) { } // GetMetadata returns metadata for a specific key -func (c *StoreClient) GetMetadata(ctx context.Context, key string) ([]byte, error) { +func (c *Client) GetMetadata(ctx context.Context, key string) ([]byte, error) { req := connect.NewRequest(&pb.GetMetadataRequest{ Key: key, }) diff --git a/pkg/rpc/client/client_test.go b/pkg/rpc/client/client_test.go index fe1e3925b2..6f2e002a0a 100644 --- a/pkg/rpc/client/client_test.go +++ b/pkg/rpc/client/client_test.go @@ -19,7 +19,7 @@ import ( ) // setupTestServer creates a test server with a mock store -func setupTestServer(t *testing.T, mockStore *mocks.Store) (*httptest.Server, *StoreClient) { +func setupTestServer(t *testing.T, mockStore *mocks.Store) (*httptest.Server, *Client) { // Create a new HTTP test server mux := http.NewServeMux() @@ -34,7 +34,7 @@ func setupTestServer(t *testing.T, mockStore *mocks.Store) (*httptest.Server, *S testServer := httptest.NewServer(h2c.NewHandler(mux, &http2.Server{})) // Create a client that connects to the test server - client := NewStoreClient(testServer.URL) + client := NewClient(testServer.URL) return testServer, client } diff --git a/pkg/rpc/example/example.go b/pkg/rpc/example/example.go index 918ddeb3b2..97351f3673 100644 --- a/pkg/rpc/example/example.go +++ b/pkg/rpc/example/example.go @@ -41,7 +41,7 @@ func StartStoreServer(s store.Store, address string) { // ExampleClient demonstrates how to use the Store RPC client func ExampleClient() { // Create a new client - client := client.NewStoreClient("http://localhost:8080") + client := client.NewClient("http://localhost:8080") ctx := context.Background() // Get the current state diff --git a/pkg/signer/file/README.md b/pkg/signer/file/README.md new file mode 100644 index 0000000000..9936bca874 --- /dev/null +++ b/pkg/signer/file/README.md @@ -0,0 +1,77 @@ +# Secure FileSystem Signer + +This package provides a secure implementation of a signer that stores cryptographic keys on the filesystem. The implementation follows security best practices to ensure that private keys are never stored in plain text on disk. + +## Features + +- **Secure Key Storage**: Private keys are encrypted using AES-GCM before being stored on disk +- **Passphrase Protection**: Keys are protected by a user-provided passphrase +- **In-Memory Operation**: Once loaded, keys remain in memory for signing operations +- **Automatic Key Generation**: If keys don't exist, they are automatically generated +- **Thread Safety**: Concurrent access to the signer is protected by mutex locks + +## Security Measures + +1. **Encryption**: Private keys are encrypted using AES-GCM, a secure authenticated encryption mode +2. **Permissions**: Key files are stored with 0600 permissions (readable and writable only by the owner) +3. **Directory Creation**: Key directories are created with 0700 permissions +4. **No Plain Text**: Private keys are never stored in plain text on disk +5. **Passphrase Derivation**: A key derivation function is used to derive encryption keys from passphrases + +## Usage + +```go +// Create a new signer (or load existing keys) +passphrase := []byte("your-secure-passphrase") +keyPath := "/path/to/secure/keys.json" +signer, err := NewFileSystemSigner(keyPath, passphrase) +if err != nil { + // Handle error +} + +// Sign a message +message := []byte("Message to sign") +signature, err := signer.Sign(message) +if err != nil { + // Handle error +} + +// Get the public key +pubKey, err := signer.GetPublic() +if err != nil { + // Handle error +} +``` + +## Production Considerations + +For production use, consider the following enhancements: + +1. **Stronger KDF**: Replace the simple key derivation function with Argon2 or PBKDF2 +2. **Secure Passphrase Handling**: Implement secure methods for obtaining and handling passphrases + +## Implementation Details + +The `FileSystemSigner` stores keys in a JSON file with the following structure: + +```json +{ + "priv_key_encrypted": "...", // Base64-encoded encrypted private key + "nonce": "...", // Base64-encoded nonce for AES-GCM + "pub_key": "..." // Base64-encoded public key +} +``` + +The encryption process: + +1. Generate a random nonce +2. Derive an encryption key from the passphrase +3. Encrypt the private key using AES-GCM with the derived key and nonce +4. Store the encrypted private key, nonce, and public key in the JSON file + +The decryption process: + +1. Read the JSON file +2. Derive the encryption key from the passphrase +3. Decrypt the private key using AES-GCM with the derived key and stored nonce +4. Load the keys into memory for use diff --git a/pkg/signer/file/doc.go b/pkg/signer/file/doc.go new file mode 100644 index 0000000000..6c367aa82a --- /dev/null +++ b/pkg/signer/file/doc.go @@ -0,0 +1,34 @@ +/* +File Remote Signer implements the Signer interface using a file to store the keys. + +The keys are stored in a file in the local filesystem. + + passphrase := []byte("your-secure-passphrase") + keyPath := "/path/to/secure/keys.json" + + // Create or load a signer + signer, err := NewFileSystemSigner(keyPath, passphrase) + if err != nil { + panic(err) + } + + // Sign a message + message := []byte("Message to sign") + signature, err := signer.Sign(message) + if err != nil { + panic(err) + } + + // Get the public key + pubKey, err := signer.GetPublic() + if err != nil { + panic(err) + } + + // Verify the signature (typically done by another party) + valid, err := pubKey.Verify(message, signature) + if err != nil { + panic(err) + } +*/ +package file diff --git a/pkg/signer/file/example_test.go b/pkg/signer/file/example_test.go new file mode 100644 index 0000000000..60bfbfeea5 --- /dev/null +++ b/pkg/signer/file/example_test.go @@ -0,0 +1,103 @@ +package file + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestFileSystemSigner(t *testing.T) { + // Create a temporary directory for the test + tempDir := t.TempDir() + keyPath := filepath.Join(tempDir, "secure_keys.json") + passphrase := []byte("test-passphrase-123") + + // Create a new signer (this will generate and save keys) + signer, err := NewFileSystemSigner(keyPath, passphrase) + require.NoError(t, err) + require.NotNil(t, signer) + + // Verify the key file was created + _, err = os.Stat(keyPath) + require.NoError(t, err) + + // Get the public key + pubKey, err := signer.GetPublic() + require.NoError(t, err) + require.NotNil(t, pubKey) + + // Sign a message + message := []byte("Hello, world!") + signature, err := signer.Sign(message) + require.NoError(t, err) + require.NotNil(t, signature) + + // Verify the signature + valid, err := pubKey.Verify(message, signature) + require.NoError(t, err) + assert.True(t, valid) + + passphrase = []byte("test-passphrase-123") + // Create a new signer instance (this will load the existing keys) + signer2, err := NewFileSystemSigner(keyPath, passphrase) + require.NoError(t, err) + require.NotNil(t, signer2) + + // Get the public key from the second signer + pubKey2, err := signer2.GetPublic() + require.NoError(t, err) + require.NotNil(t, pubKey2) + + // Verify that both signers have the same public key + pubKeyBytes1, err := pubKey.Raw() + require.NoError(t, err) + pubKeyBytes2, err := pubKey2.Raw() + require.NoError(t, err) + assert.Equal(t, pubKeyBytes1, pubKeyBytes2) + + // Test with wrong passphrase + wrongPassphrase := []byte("wrong-passphrase") + _, err = NewFileSystemSigner(keyPath, wrongPassphrase) + assert.Error(t, err) +} + +// Example demonstrates how to use the FileSystemSigner +func Example() { + // In a real application, you would use a secure passphrase + passphrase := []byte("your-secure-passphrase") + keyPath := "/path/to/secure/keys.json" + + // Create or load a signer + signer, err := NewFileSystemSigner(keyPath, passphrase) + if err != nil { + panic(err) + } + + // Sign a message + message := []byte("Message to sign") + signature, err := signer.Sign(message) + if err != nil { + panic(err) + } + + // Get the public key + pubKey, err := signer.GetPublic() + if err != nil { + panic(err) + } + + // Verify the signature (typically done by another party) + valid, err := pubKey.Verify(message, signature) + if err != nil { + panic(err) + } + + if valid { + // Signature is valid + } else { + // Signature is invalid + } +} diff --git a/pkg/signer/file/local.go b/pkg/signer/file/local.go new file mode 100644 index 0000000000..75bc6d874f --- /dev/null +++ b/pkg/signer/file/local.go @@ -0,0 +1,291 @@ +package file + +import ( + "crypto/aes" + "crypto/cipher" + "crypto/rand" + "encoding/json" + "fmt" + "io" + "os" + "path/filepath" + "sync" + + "github.com/libp2p/go-libp2p/core/crypto" + "golang.org/x/crypto/argon2" + + "github.com/rollkit/rollkit/pkg/signer" +) + +// FileSystemSigner implements a signer that securely stores keys on disk +// and loads them into memory only when needed. +type FileSystemSigner struct { + privateKey crypto.PrivKey + publicKey crypto.PubKey + keyFile string + mu sync.RWMutex +} + +// keyData represents the encrypted key data stored on disk +type keyData struct { + PrivKeyEncrypted []byte `json:"priv_key_encrypted"` + Nonce []byte `json:"nonce"` + PubKeyBytes []byte `json:"pub_key"` + Salt []byte `json:"salt,omitempty"` +} + +// NewFileSystemSigner creates a new signer that stores keys securely on disk. +// If the keys don't exist at the specified paths, it generates new ones. +func NewFileSystemSigner(keyPath string, passphrase []byte) (signer.Signer, error) { + defer zeroBytes(passphrase) // Wipe passphrase from memory after use + + // Create directory if it doesn't exist + dir := filepath.Dir(keyPath) + if err := os.MkdirAll(dir, 0700); err != nil { + return nil, fmt.Errorf("failed to create directory: %w", err) + } + + // Check if key file exists + if _, err := os.Stat(keyPath); os.IsNotExist(err) { + // Generate new keys + return generateAndSaveKeys(keyPath, passphrase) + } + + // Load existing keys + signer := &FileSystemSigner{ + keyFile: keyPath, + } + + // Load keys into memory + if err := signer.loadKeys(passphrase); err != nil { + return nil, err + } + + return signer, nil +} + +// generateAndSaveKeys creates a new key pair and saves it to disk +func generateAndSaveKeys(keyPath string, passphrase []byte) (*FileSystemSigner, error) { + defer zeroBytes(passphrase) + + // Generate new Ed25519 key pair + privKey, pubKey, err := crypto.GenerateKeyPair(crypto.Ed25519, 256) + if err != nil { + return nil, fmt.Errorf("failed to generate key pair: %w", err) + } + + signer := &FileSystemSigner{ + privateKey: privKey, + publicKey: pubKey, + keyFile: keyPath, + } + + // Save keys to disk + if err := signer.saveKeys(passphrase); err != nil { + return nil, err + } + + return signer, nil +} + +// saveKeys encrypts and saves the private key to disk +func (s *FileSystemSigner) saveKeys(passphrase []byte) error { + s.mu.Lock() + defer s.mu.Unlock() + + if s.privateKey == nil || s.publicKey == nil { + return fmt.Errorf("keys not initialized") + } + + // Create or reuse a random salt for Argon2 + salt := make([]byte, 16) + if _, err := rand.Read(salt); err != nil { + return fmt.Errorf("failed to generate salt: %w", err) + } + + // Get raw private key bytes + privKeyBytes, err := s.privateKey.Raw() + if err != nil { + return fmt.Errorf("failed to get raw private key: %w", err) + } + + // Get raw public key bytes + pubKeyBytes, err := s.publicKey.Raw() + if err != nil { + return fmt.Errorf("failed to get raw public key: %w", err) + } + + // Derive a key with Argon2 + derivedKey := deriveKeyArgon2(passphrase, salt, 32) + + // Zero out passphrase from memory once we have our derived key + zeroBytes(passphrase) + + // Create AES cipher + block, err := aes.NewCipher(derivedKey) + if err != nil { + return fmt.Errorf("failed to create cipher: %w", err) + } + + // Create GCM mode + gcm, err := cipher.NewGCM(block) + if err != nil { + return fmt.Errorf("failed to create GCM: %w", err) + } + + // Create a nonce + nonce := make([]byte, gcm.NonceSize()) + if _, err := io.ReadFull(rand.Reader, nonce); err != nil { + return fmt.Errorf("failed to generate nonce: %w", err) + } + + // Encrypt the private key + encryptedPrivKey := gcm.Seal(nil, nonce, privKeyBytes, nil) + + // Create key data structure + data := keyData{ + PrivKeyEncrypted: encryptedPrivKey, + Nonce: nonce, + PubKeyBytes: pubKeyBytes, + Salt: salt, + } + + // Marshal to JSON + jsonData, err := json.Marshal(data) + if err != nil { + return fmt.Errorf("failed to marshal key data: %w", err) + } + + // Write to file with secure permissions + if err := os.WriteFile(s.keyFile, jsonData, 0600); err != nil { + return fmt.Errorf("failed to write key file: %w", err) + } + + // Zero out derivedKey bytes for security + zeroBytes(derivedKey) + zeroBytes(privKeyBytes) + + return nil +} + +// loadKeys decrypts and loads the keys from disk into memory +func (s *FileSystemSigner) loadKeys(passphrase []byte) error { + s.mu.Lock() + defer s.mu.Unlock() + defer zeroBytes(passphrase) // Wipe passphrase from memory after use + + // Read the key file + jsonData, err := os.ReadFile(s.keyFile) + if err != nil { + return fmt.Errorf("failed to read key file: %w", err) + } + + // Unmarshal JSON + var data keyData + if err := json.Unmarshal(jsonData, &data); err != nil { + return fmt.Errorf("failed to unmarshal key data: %w", err) + } + + // If there's no salt in the file, fallback to older naive deriveKey (for backward-compatibility) + var derivedKey []byte + if len(data.Salt) == 0 { + // fallback to naive approach + derivedKey = fallbackDeriveKey(passphrase, 32) + } else { + derivedKey = deriveKeyArgon2(passphrase, data.Salt, 32) + } + + block, err := aes.NewCipher(derivedKey) + if err != nil { + return fmt.Errorf("failed to create cipher: %w", err) + } + + gcm, err := cipher.NewGCM(block) + if err != nil { + return fmt.Errorf("failed to create GCM: %w", err) + } + + // Decrypt the private key + privKeyBytes, err := gcm.Open(nil, data.Nonce, data.PrivKeyEncrypted, nil) + if err != nil { + return fmt.Errorf("failed to decrypt private key (wrong passphrase?): %w", err) + } + + // Unmarshal the private key + privKey, err := crypto.UnmarshalEd25519PrivateKey(privKeyBytes) + if err != nil { + return fmt.Errorf("failed to unmarshal private key: %w", err) + } + + // Unmarshal the public key + pubKey, err := crypto.UnmarshalEd25519PublicKey(data.PubKeyBytes) + if err != nil { + return fmt.Errorf("failed to unmarshal public key: %w", err) + } + + // Set the keys + s.privateKey = privKey + s.publicKey = pubKey + + // Zero out sensitive data + zeroBytes(derivedKey) + zeroBytes(privKeyBytes) + + return nil +} + +// Sign signs a message using the private key +func (s *FileSystemSigner) Sign(message []byte) ([]byte, error) { + s.mu.RLock() + defer s.mu.RUnlock() + + if s.privateKey == nil { + return nil, fmt.Errorf("private key not loaded") + } + + return s.privateKey.Sign(message) +} + +// GetPublic returns the public key +func (s *FileSystemSigner) GetPublic() (crypto.PubKey, error) { + s.mu.RLock() + defer s.mu.RUnlock() + + if s.publicKey == nil { + return nil, fmt.Errorf("public key not loaded") + } + + return s.publicKey, nil +} + +// deriveKeyArgon2 uses Argon2id for key derivation +func deriveKeyArgon2(passphrase, salt []byte, keyLen uint32) []byte { + // Using some default parameters: + // Time (iterations) = 3 + // Memory = 32MB + // Threads = 4 + // You can tune these parameters for your security/performance needs. + return argon2.IDKey(passphrase, salt, 3, 32*1024, 4, keyLen) +} + +// fallbackDeriveKey is the old naive approach for backwards compatibility. +// Will be used if a key file has no salt field. +func fallbackDeriveKey(passphrase []byte, keyLen int) []byte { + if len(passphrase) >= keyLen { + return passphrase[:keyLen] + } + + key := make([]byte, keyLen) + copy(key, passphrase) + for i := len(passphrase); i < keyLen; i++ { + key[i] = passphrase[i%len(passphrase)] ^ byte(i) + } + return key +} + +// zeroBytes overwrites a byte slice with zeros +func zeroBytes(b []byte) { + for i := range b { + b[i] = 0 + } +} diff --git a/pkg/signer/file_signer.go b/pkg/signer/file_signer.go deleted file mode 100644 index 85adcfad91..0000000000 --- a/pkg/signer/file_signer.go +++ /dev/null @@ -1,39 +0,0 @@ -package signer - -import ( - "path/filepath" - - cometprivval "github.com/cometbft/cometbft/privval" - "github.com/libp2p/go-libp2p/core/crypto" -) - -// FileKeyProvider implements the KeyProvider interface using files to store the keys -type FileKeyProvider struct { - keyFile string - stateFile string - privateKey crypto.PrivKey -} - -// NewFileKeyProvider creates a new FileKeyProvider -func NewFileKeyProvider(rootDir, configDir, dbPath string) *FileKeyProvider { - return &FileKeyProvider{ - keyFile: filepath.Join(rootDir, configDir, "priv_validator_key.json"), - stateFile: filepath.Join(rootDir, dbPath, "priv_validator_state.json"), - } -} - -// GetSigningKey returns the private key used for signing -func (p *FileKeyProvider) GetSigningKey() (crypto.PrivKey, error) { - if p.privateKey != nil { - return p.privateKey, nil - } - - pval := cometprivval.LoadOrGenFilePV(p.keyFile, p.stateFile) - privateKey, err := crypto.UnmarshalEd25519PrivateKey(pval.Key.PrivKey.Bytes()) - if err != nil { - return nil, err - } - - p.privateKey = privateKey - return privateKey, nil -} diff --git a/pkg/signer/noop/doc.go b/pkg/signer/noop/doc.go new file mode 100644 index 0000000000..afe1ec7fb2 --- /dev/null +++ b/pkg/signer/noop/doc.go @@ -0,0 +1,6 @@ +/* +Noop remote signer implements the Signer interface using a no-op signer. + +This is useful for testing and development purposes. +*/ +package noop diff --git a/pkg/signer/noop/signer.go b/pkg/signer/noop/signer.go new file mode 100644 index 0000000000..02698e41b5 --- /dev/null +++ b/pkg/signer/noop/signer.go @@ -0,0 +1,33 @@ +package noop + +import ( + "github.com/libp2p/go-libp2p/core/crypto" + + "github.com/rollkit/rollkit/pkg/signer" +) + +// NoopSigner implements the remote_signer.Signer interface. +// It generates a new Ed25519 key pair for each instance. +type NoopSigner struct { + privKey crypto.PrivKey + pubKey crypto.PubKey +} + +// NewNoopSigner creates a new signer with a fresh Ed25519 key pair. +func NewNoopSigner(privKey crypto.PrivKey) (signer.Signer, error) { + + return &NoopSigner{ + privKey: privKey, + pubKey: privKey.GetPublic(), + }, nil +} + +// Sign implements the Signer interface by signing the message with the Ed25519 private key. +func (n *NoopSigner) Sign(message []byte) ([]byte, error) { + return n.privKey.Sign(message) +} + +// GetPublic implements the Signer interface by returning the Ed25519 public key. +func (n *NoopSigner) GetPublic() (crypto.PubKey, error) { + return n.pubKey, nil +} diff --git a/pkg/signer/noop/signer_test.go b/pkg/signer/noop/signer_test.go new file mode 100644 index 0000000000..a3ec506ba5 --- /dev/null +++ b/pkg/signer/noop/signer_test.go @@ -0,0 +1,95 @@ +package noop + +import ( + "testing" + + "github.com/libp2p/go-libp2p/core/crypto" + "github.com/stretchr/testify/require" +) + +func TestNoopSigner(t *testing.T) { + t.Run("create new signer", func(t *testing.T) { + privKey, _, err := crypto.GenerateKeyPair(crypto.Ed25519, 256) + require.NoError(t, err) + signer, err := NewNoopSigner(privKey) + require.NoError(t, err) + require.NotNil(t, signer) + }) + + t.Run("get public key", func(t *testing.T) { + privKey, _, err := crypto.GenerateKeyPair(crypto.Ed25519, 256) + require.NoError(t, err) + signer, err := NewNoopSigner(privKey) + require.NoError(t, err) + + pubKey, err := signer.GetPublic() + require.NoError(t, err) + require.NotNil(t, pubKey) + }) + + t.Run("sign and verify", func(t *testing.T) { + privKey, _, err := crypto.GenerateKeyPair(crypto.Ed25519, 256) + require.NoError(t, err) + signer, err := NewNoopSigner(privKey) + require.NoError(t, err) + + message := []byte("test message") + signature, err := signer.Sign(message) + require.NoError(t, err) + require.NotNil(t, signature) + + // Verify signature using the public key + pubKey, err := signer.GetPublic() + require.NoError(t, err) + + valid, err := pubKey.Verify(message, signature) + require.NoError(t, err) + require.True(t, valid) + }) + + t.Run("different signers have different keys", func(t *testing.T) { + privKey1, _, err := crypto.GenerateKeyPair(crypto.Ed25519, 256) + require.NoError(t, err) + signer1, err := NewNoopSigner(privKey1) + require.NoError(t, err) + + privKey2, _, err := crypto.GenerateKeyPair(crypto.Ed25519, 256) + require.NoError(t, err) + signer2, err := NewNoopSigner(privKey2) + require.NoError(t, err) + + pub1, err := signer1.GetPublic() + require.NoError(t, err) + + pub2, err := signer2.GetPublic() + require.NoError(t, err) + + pub1Bytes, err := pub1.Raw() + require.NoError(t, err) + + pub2Bytes, err := pub2.Raw() + require.NoError(t, err) + + require.NotEqual(t, pub1Bytes, pub2Bytes) + }) + + t.Run("verify wrong message fails", func(t *testing.T) { + privKey, _, err := crypto.GenerateKeyPair(crypto.Ed25519, 256) + require.NoError(t, err) + signer, err := NewNoopSigner(privKey) + require.NoError(t, err) + + message := []byte("test message") + wrongMessage := []byte("wrong message") + + signature, err := signer.Sign(message) + require.NoError(t, err) + + pubKey, err := signer.GetPublic() + require.NoError(t, err) + + valid, err := pubKey.Verify(wrongMessage, signature) + require.NoError(t, err) + require.False(t, valid) + }) +} diff --git a/pkg/signer/signer.go b/pkg/signer/signer.go index baccbb9a6b..ccbb50216d 100644 --- a/pkg/signer/signer.go +++ b/pkg/signer/signer.go @@ -4,8 +4,11 @@ import ( "github.com/libp2p/go-libp2p/core/crypto" ) -// KeyProvider is an interface that provides access to signing keys -type KeyProvider interface { - // GetSigningKey returns the private key used for signing - GetSigningKey() (crypto.PrivKey, error) +// Signer is an interface for signing and verifying messages. +type Signer interface { + // Sign takes a message as bytes and returns its signature. + Sign(message []byte) ([]byte, error) + + // GetPublic returns the public key paired with this private key. + GetPublic() (crypto.PubKey, error) } diff --git a/pkg/signer/v1/signer.pb.go b/pkg/signer/v1/signer.pb.go new file mode 100644 index 0000000000..4f258e6c7a --- /dev/null +++ b/pkg/signer/v1/signer.pb.go @@ -0,0 +1,914 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rollkit/pkg/remote_signer/v1/signer.proto + +package v1 + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// The SignRequest holds the bytes we want to sign. +type SignRequest struct { + Message []byte `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (m *SignRequest) Reset() { *m = SignRequest{} } +func (m *SignRequest) String() string { return proto.CompactTextString(m) } +func (*SignRequest) ProtoMessage() {} +func (*SignRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fc0896255c20ccbe, []int{0} +} +func (m *SignRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SignRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SignRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SignRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignRequest.Merge(m, src) +} +func (m *SignRequest) XXX_Size() int { + return m.Size() +} +func (m *SignRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SignRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SignRequest proto.InternalMessageInfo + +func (m *SignRequest) GetMessage() []byte { + if m != nil { + return m.Message + } + return nil +} + +// The SignResponse returns the signature bytes. +type SignResponse struct { + Signature []byte `protobuf:"bytes,1,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (m *SignResponse) Reset() { *m = SignResponse{} } +func (m *SignResponse) String() string { return proto.CompactTextString(m) } +func (*SignResponse) ProtoMessage() {} +func (*SignResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fc0896255c20ccbe, []int{1} +} +func (m *SignResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SignResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SignResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SignResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignResponse.Merge(m, src) +} +func (m *SignResponse) XXX_Size() int { + return m.Size() +} +func (m *SignResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SignResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SignResponse proto.InternalMessageInfo + +func (m *SignResponse) GetSignature() []byte { + if m != nil { + return m.Signature + } + return nil +} + +// The GetPublicRequest is an empty request. +type GetPublicRequest struct { +} + +func (m *GetPublicRequest) Reset() { *m = GetPublicRequest{} } +func (m *GetPublicRequest) String() string { return proto.CompactTextString(m) } +func (*GetPublicRequest) ProtoMessage() {} +func (*GetPublicRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fc0896255c20ccbe, []int{2} +} +func (m *GetPublicRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetPublicRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetPublicRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetPublicRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPublicRequest.Merge(m, src) +} +func (m *GetPublicRequest) XXX_Size() int { + return m.Size() +} +func (m *GetPublicRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetPublicRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetPublicRequest proto.InternalMessageInfo + +// The GetPublicResponse returns the public key. +type GetPublicResponse struct { + PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` +} + +func (m *GetPublicResponse) Reset() { *m = GetPublicResponse{} } +func (m *GetPublicResponse) String() string { return proto.CompactTextString(m) } +func (*GetPublicResponse) ProtoMessage() {} +func (*GetPublicResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fc0896255c20ccbe, []int{3} +} +func (m *GetPublicResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetPublicResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetPublicResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetPublicResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPublicResponse.Merge(m, src) +} +func (m *GetPublicResponse) XXX_Size() int { + return m.Size() +} +func (m *GetPublicResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetPublicResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetPublicResponse proto.InternalMessageInfo + +func (m *GetPublicResponse) GetPublicKey() []byte { + if m != nil { + return m.PublicKey + } + return nil +} + +func init() { + proto.RegisterType((*SignRequest)(nil), "rollkit.pkg.remote_signer.v1.SignRequest") + proto.RegisterType((*SignResponse)(nil), "rollkit.pkg.remote_signer.v1.SignResponse") + proto.RegisterType((*GetPublicRequest)(nil), "rollkit.pkg.remote_signer.v1.GetPublicRequest") + proto.RegisterType((*GetPublicResponse)(nil), "rollkit.pkg.remote_signer.v1.GetPublicResponse") +} + +func init() { + proto.RegisterFile("rollkit/pkg/remote_signer/v1/signer.proto", fileDescriptor_fc0896255c20ccbe) +} + +var fileDescriptor_fc0896255c20ccbe = []byte{ + // 284 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2c, 0xca, 0xcf, 0xc9, + 0xc9, 0xce, 0x2c, 0xd1, 0x2f, 0xc8, 0x4e, 0xd7, 0x2f, 0x4a, 0xcd, 0xcd, 0x2f, 0x49, 0x8d, 0x2f, + 0xce, 0x4c, 0xcf, 0x4b, 0x2d, 0xd2, 0x2f, 0x33, 0xd4, 0x87, 0xb0, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, + 0xf2, 0x85, 0x64, 0xa0, 0x4a, 0xf5, 0x0a, 0xb2, 0xd3, 0xf5, 0x50, 0x94, 0xea, 0x95, 0x19, 0x2a, + 0xa9, 0x73, 0x71, 0x07, 0x67, 0xa6, 0xe7, 0x05, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, 0x49, + 0x70, 0xb1, 0xe7, 0xa6, 0x16, 0x17, 0x27, 0xa6, 0xa7, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x04, + 0xc1, 0xb8, 0x4a, 0x3a, 0x5c, 0x3c, 0x10, 0x85, 0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x42, 0x32, + 0x5c, 0x9c, 0x20, 0x53, 0x12, 0x4b, 0x4a, 0x8b, 0x60, 0x6a, 0x11, 0x02, 0x4a, 0x42, 0x5c, 0x02, + 0xee, 0xa9, 0x25, 0x01, 0xa5, 0x49, 0x39, 0x99, 0xc9, 0x50, 0xb3, 0x95, 0x8c, 0xb8, 0x04, 0x91, + 0xc4, 0xa0, 0xc6, 0xc8, 0x72, 0x71, 0x15, 0x80, 0x45, 0xe2, 0xb3, 0x53, 0x2b, 0x61, 0xe6, 0x40, + 0x44, 0xbc, 0x53, 0x2b, 0x8d, 0xee, 0x30, 0x72, 0xf1, 0x06, 0x83, 0x1d, 0x1b, 0x9c, 0x5a, 0x54, + 0x96, 0x99, 0x9c, 0x2a, 0x14, 0xcb, 0xc5, 0x02, 0x12, 0x10, 0xd2, 0xd4, 0xc3, 0xe7, 0x2f, 0x3d, + 0x24, 0x4f, 0x49, 0x69, 0x11, 0xa3, 0x14, 0xea, 0x9e, 0x1c, 0x2e, 0x4e, 0xb8, 0x23, 0x85, 0xf4, + 0xf0, 0x6b, 0x44, 0xf7, 0xa1, 0x94, 0x3e, 0xd1, 0xea, 0x21, 0xb6, 0x39, 0x79, 0x9e, 0x78, 0x24, + 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, + 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x7e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, + 0x72, 0x7e, 0xae, 0x3e, 0x2c, 0xae, 0xf1, 0xc5, 0x79, 0x12, 0x1b, 0x38, 0xb6, 0x8d, 0x01, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x69, 0xc4, 0x09, 0x0f, 0x1a, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// SignerServiceClient is the client API for SignerService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type SignerServiceClient interface { + Sign(ctx context.Context, in *SignRequest, opts ...grpc.CallOption) (*SignResponse, error) + GetPublic(ctx context.Context, in *GetPublicRequest, opts ...grpc.CallOption) (*GetPublicResponse, error) +} + +type signerServiceClient struct { + cc grpc1.ClientConn +} + +func NewSignerServiceClient(cc grpc1.ClientConn) SignerServiceClient { + return &signerServiceClient{cc} +} + +func (c *signerServiceClient) Sign(ctx context.Context, in *SignRequest, opts ...grpc.CallOption) (*SignResponse, error) { + out := new(SignResponse) + err := c.cc.Invoke(ctx, "/rollkit.pkg.remote_signer.v1.SignerService/Sign", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *signerServiceClient) GetPublic(ctx context.Context, in *GetPublicRequest, opts ...grpc.CallOption) (*GetPublicResponse, error) { + out := new(GetPublicResponse) + err := c.cc.Invoke(ctx, "/rollkit.pkg.remote_signer.v1.SignerService/GetPublic", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SignerServiceServer is the server API for SignerService service. +type SignerServiceServer interface { + Sign(context.Context, *SignRequest) (*SignResponse, error) + GetPublic(context.Context, *GetPublicRequest) (*GetPublicResponse, error) +} + +// UnimplementedSignerServiceServer can be embedded to have forward compatible implementations. +type UnimplementedSignerServiceServer struct { +} + +func (*UnimplementedSignerServiceServer) Sign(ctx context.Context, req *SignRequest) (*SignResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Sign not implemented") +} +func (*UnimplementedSignerServiceServer) GetPublic(ctx context.Context, req *GetPublicRequest) (*GetPublicResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPublic not implemented") +} + +func RegisterSignerServiceServer(s grpc1.Server, srv SignerServiceServer) { + s.RegisterService(&_SignerService_serviceDesc, srv) +} + +func _SignerService_Sign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SignRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SignerServiceServer).Sign(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rollkit.pkg.remote_signer.v1.SignerService/Sign", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SignerServiceServer).Sign(ctx, req.(*SignRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SignerService_GetPublic_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPublicRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SignerServiceServer).GetPublic(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rollkit.pkg.remote_signer.v1.SignerService/GetPublic", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SignerServiceServer).GetPublic(ctx, req.(*GetPublicRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _SignerService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "rollkit.pkg.remote_signer.v1.SignerService", + HandlerType: (*SignerServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Sign", + Handler: _SignerService_Sign_Handler, + }, + { + MethodName: "GetPublic", + Handler: _SignerService_GetPublic_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "rollkit/pkg/remote_signer/v1/signer.proto", +} + +func (m *SignRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SignRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SignRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Message) > 0 { + i -= len(m.Message) + copy(dAtA[i:], m.Message) + i = encodeVarintSigner(dAtA, i, uint64(len(m.Message))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SignResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SignResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SignResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintSigner(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GetPublicRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetPublicRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetPublicRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *GetPublicResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetPublicResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetPublicResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PublicKey) > 0 { + i -= len(m.PublicKey) + copy(dAtA[i:], m.PublicKey) + i = encodeVarintSigner(dAtA, i, uint64(len(m.PublicKey))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintSigner(dAtA []byte, offset int, v uint64) int { + offset -= sovSigner(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *SignRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Message) + if l > 0 { + n += 1 + l + sovSigner(uint64(l)) + } + return n +} + +func (m *SignResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovSigner(uint64(l)) + } + return n +} + +func (m *GetPublicRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *GetPublicResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PublicKey) + if l > 0 { + n += 1 + l + sovSigner(uint64(l)) + } + return n +} + +func sovSigner(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSigner(x uint64) (n int) { + return sovSigner(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *SignRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSigner + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SignRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SignRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSigner + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSigner + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSigner + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = append(m.Message[:0], dAtA[iNdEx:postIndex]...) + if m.Message == nil { + m.Message = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSigner(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSigner + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SignResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSigner + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SignResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SignResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSigner + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSigner + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSigner + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) + if m.Signature == nil { + m.Signature = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSigner(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSigner + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetPublicRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSigner + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetPublicRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetPublicRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipSigner(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSigner + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetPublicResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSigner + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetPublicResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetPublicResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSigner + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSigner + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSigner + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PublicKey = append(m.PublicKey[:0], dAtA[iNdEx:postIndex]...) + if m.PublicKey == nil { + m.PublicKey = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSigner(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSigner + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSigner(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSigner + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSigner + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSigner + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthSigner + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSigner + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSigner + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSigner = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSigner = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSigner = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/rollkit/v1/signer.proto b/proto/rollkit/v1/signer.proto new file mode 100644 index 0000000000..82c10dbd06 --- /dev/null +++ b/proto/rollkit/v1/signer.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package rollkit.v1; + +option go_package = "github.com/rollkit/rollkit/types/pb/rollkit/v1"; + +// The SignRequest holds the bytes we want to sign. +message SignRequest { + bytes message = 1; +} + +// The SignResponse returns the signature bytes. +message SignResponse { + bytes signature = 1; +} + +// The GetPublicRequest is an empty request. +message GetPublicRequest {} + +// The GetPublicResponse returns the public key. +message GetPublicResponse { + bytes public_key = 1; +} + +// The SignerService defines the RPCs to sign and to retrieve the public key. +service SignerService { + // Sign signs the given message. + rpc Sign(SignRequest) returns (SignResponse); + // GetPublic returns the public key. + rpc GetPublic(GetPublicRequest) returns (GetPublicResponse); +} \ No newline at end of file diff --git a/rollups/testapp/commands/root.go b/rollups/testapp/cmd/root.go similarity index 97% rename from rollups/testapp/commands/root.go rename to rollups/testapp/cmd/root.go index 598ccd1ae8..98f800fb2a 100644 --- a/rollups/testapp/commands/root.go +++ b/rollups/testapp/cmd/root.go @@ -1,4 +1,4 @@ -package commands +package cmd import ( "github.com/spf13/cobra" diff --git a/rollups/testapp/main.go b/rollups/testapp/main.go index dce3fd0c52..adf33921d6 100644 --- a/rollups/testapp/main.go +++ b/rollups/testapp/main.go @@ -11,8 +11,7 @@ import ( coresequencer "github.com/rollkit/rollkit/core/sequencer" "github.com/rollkit/rollkit/da" rollcmd "github.com/rollkit/rollkit/pkg/cmd" - "github.com/rollkit/rollkit/pkg/signer" - commands "github.com/rollkit/rollkit/rollups/testapp/commands" + commands "github.com/rollkit/rollkit/rollups/testapp/cmd" testExecutor "github.com/rollkit/rollkit/rollups/testapp/kv" ) @@ -24,6 +23,7 @@ func main() { ctx := context.Background() // Create test implementations + // TODO: we need to start the executor http server executor := testExecutor.CreateDirectKVExecutor(ctx) sequencer := coresequencer.NewDummySequencer() @@ -32,13 +32,10 @@ func main() { logger := log.NewLogger(os.Stdout) dac := da.NewDAClient(dummyDA, 0, 1.0, []byte("test"), []byte(""), logger) - // Create key provider - keyProvider := signer.NewFileKeyProvider("", "config", "data") - // Add subcommands to the root command rootCmd.AddCommand( rollcmd.NewDocsGenCmd(rootCmd, commands.AppName), - rollcmd.NewRunNodeCmd(executor, sequencer, dac, keyProvider), + rollcmd.NewRunNodeCmd(executor, sequencer, dac), rollcmd.VersionCmd, rollcmd.InitCmd, ) diff --git a/sequencers/single/go.mod b/sequencers/single/go.mod index 402f459e46..2d5d0a4470 100644 --- a/sequencers/single/go.mod +++ b/sequencers/single/go.mod @@ -16,6 +16,7 @@ require ( github.com/rollkit/rollkit v0.0.0-00010101000000-000000000000 github.com/rollkit/rollkit/core v0.0.0-00010101000000-000000000000 github.com/rollkit/rollkit/da v0.0.0-00010101000000-000000000000 + google.golang.org/protobuf v1.36.5 ) require ( @@ -25,7 +26,6 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/jbenet/goprocess v0.1.4 // indirect github.com/klauspost/cpuid/v2 v2.2.9 // indirect @@ -40,5 +40,4 @@ require ( github.com/twitchyliquid64/golang-asm v0.15.1 // indirect golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect golang.org/x/sys v0.30.0 // indirect - google.golang.org/protobuf v1.36.5 // indirect ) diff --git a/sequencers/single/go.sum b/sequencers/single/go.sum index 094351628e..1976192b64 100644 --- a/sequencers/single/go.sum +++ b/sequencers/single/go.sum @@ -23,8 +23,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8Yc github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -34,8 +32,6 @@ github.com/ipfs/go-datastore v0.7.0/go.mod h1:ucOWMfbOPI6ZEyaIB1q/+78RPLBPERfuUV github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -44,8 +40,8 @@ github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -85,40 +81,13 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/sequencers/single/queue.go b/sequencers/single/queue.go index 0091b6f702..e4faac4491 100644 --- a/sequencers/single/queue.go +++ b/sequencers/single/queue.go @@ -9,6 +9,7 @@ import ( ktds "github.com/ipfs/go-datastore/keytransform" "github.com/ipfs/go-datastore/query" coresequencer "github.com/rollkit/rollkit/core/sequencer" + "google.golang.org/protobuf/proto" pb "github.com/rollkit/rollkit/types/pb/rollkit/v1" ) @@ -45,7 +46,7 @@ func (bq *BatchQueue) AddBatch(ctx context.Context, batch coresequencer.Batch) e Txs: batch.Transactions, } - encodedBatch, err := pbBatch.Marshal() + encodedBatch, err := proto.Marshal(pbBatch) if err != nil { return err } @@ -108,7 +109,7 @@ func (bq *BatchQueue) Load(ctx context.Context) error { // Load each batch for result := range results.Next() { pbBatch := &pb.Batch{} - err := pbBatch.Unmarshal(result.Value) + err := proto.Unmarshal(result.Value, pbBatch) if err != nil { fmt.Printf("Error decoding batch: %v\n", err) continue diff --git a/specs/lazy-adr/adr-017-node-pruning.md b/specs/lazy-adr/adr-017-node-pruning.md index bf90a07156..d12ebd49cd 100644 --- a/specs/lazy-adr/adr-017-node-pruning.md +++ b/specs/lazy-adr/adr-017-node-pruning.md @@ -715,12 +715,12 @@ rollkit migrate-storage [subcommand] [flags] 5. **rollback**: Reverts migration -```bash -rollkit migrate-storage rollback [--data-dir=] [--backup-dir=] -``` + ```bash + rollkit migrate-storage rollback [--data-dir=] [--backup-dir=] + ``` -- Restores from backup -- Validates restoration + - Restores from backup + - Validates restoration #### Migration Configuration diff --git a/test/e2e/base_test.go b/test/e2e/base_test.go index d82287c0fa..57460a14c9 100644 --- a/test/e2e/base_test.go +++ b/test/e2e/base_test.go @@ -3,22 +3,16 @@ package e2e import ( - "context" "flag" - "fmt" "path/filepath" "testing" "time" - - "github.com/cometbft/cometbft/abci/example/kvstore" - rpchttp "github.com/cometbft/cometbft/rpc/client/http" - "github.com/stretchr/testify/require" ) var binaryPath string func init() { - flag.StringVar(&binaryPath, "binary", "rollkit", "rollkit binary") + flag.StringVar(&binaryPath, "binary", "testapp", "testapp binary") } func TestBasic(t *testing.T) { @@ -30,87 +24,90 @@ func TestBasic(t *testing.T) { var ( workDir = t.TempDir() node1Home = filepath.Join(workDir, "1") - node2Home = filepath.Join(workDir, "2") + // node2Home = filepath.Join(workDir, "2") ) // Define and parse the binary flag locally in the test function. sut := NewSystemUnderTest(t) + aggregatorPass := "12345678" + // init aggregator + sut.RunCmd(binaryPath, + "init", + "--home="+node1Home, + "--node.sequencer_rollup_id=testing", + "--node.aggregator", + "--node.block_time=5ms", + "--da.block_time=15ms", + "--node.aggrgator", + "--signer.passphrase="+aggregatorPass, + ) + // start aggregator sut.StartNode(binaryPath, "start", - "--proxy_app=kvstore", "--home="+node1Home, - "--p2p.laddr=tcp://127.0.0.1:26656", - "--rpc.laddr=tcp://127.0.0.1:26657", - "--rollkit.sequencer_rollup_id=testing", - "--rollkit.aggregator", - "--rollkit.block_time=5ms", - "--rollkit.da_block_time=15ms", - "--rollkit.da_address=http://0.0.0.0:7980", - "--rollkit.sequencer_address=0.0.0.0:50051", + "--node.sequencer_rollup_id=testing", + "--node.aggregator", + "--signer.passphrase="+aggregatorPass, + "--node.block_time=5ms", + "--da.block_time=15ms", ) - sut.AwaitNodeUp(t, "tcp://127.0.0.1:26657", 2*time.Second) + sut.AwaitNodeUp(t, "tcp://127.0.0.1:7331", 2*time.Second) - // copy genesis to target home2 - MustCopyFile(t, filepath.Join(node1Home, "config", "genesis.json"), filepath.Join(node2Home, "config", "genesis.json")) - sut.StartNode( - binaryPath, - "start", - "--proxy_app=kvstore", - "--home="+node2Home, - "--p2p.laddr=tcp://127.0.0.1:16656", - "--rpc.laddr=tcp://127.0.0.1:16657", - "--rollkit.sequencer_rollup_id=testing", - fmt.Sprintf("--p2p.seeds=%s@127.0.0.1:26656", NodeID(t, node1Home)), - "--rollkit.aggregator=false", - "--rollkit.block_time=5ms", - "--rollkit.da_block_time=15ms", - "--rollkit.da_address=http://0.0.0.0:7980", - "--rollkit.sequencer_address=0.0.0.0:50051", - "--log_level=debug", - ) - sut.AwaitNodeUp(t, "tcp://127.0.0.1:16657", 2*time.Second) + // // copy genesis to target home2 + // MustCopyFile(t, filepath.Join(node1Home, "config", "genesis.json"), filepath.Join(node2Home, "config", "genesis.json")) + // sut.StartNode( + // binaryPath, + // "start", + // "--home="+node2Home, + // "--node.sequencer_rollup_id=testing", + // fmt.Sprintf("--p2p.seeds=%s@127.0.0.1:26656", NodeID(t, node1Home)), + // "--block_time=5ms", + // "--da_block_time=15ms", + // "--log_level=debug", + // ) + // sut.AwaitNodeUp(t, "tcp://127.0.0.1:16657", 2*time.Second) - asserNodeCaughtUp := func(c *rpchttp.HTTP) { - ctx, done := context.WithTimeout(context.Background(), time.Second) - defer done() - status, err := c.Status(ctx) - require.NoError(t, err) - require.False(t, status.SyncInfo.CatchingUp) - } - node1Client, err := rpchttp.New("tcp://localhost:26657", "tcp://localhost:26657"+"/websocket") - require.NoError(t, err) - asserNodeCaughtUp(node1Client) + // asserNodeCaughtUp := func(c *rpchttp.HTTP) { + // ctx, done := context.WithTimeout(context.Background(), time.Second) + // defer done() + // status, err := c.Status(ctx) + // require.NoError(t, err) + // require.False(t, status.SyncInfo.CatchingUp) + // } + // node1Client, err := rpchttp.New("tcp://localhost:26657", "tcp://localhost:26657"+"/websocket") + // require.NoError(t, err) + // asserNodeCaughtUp(node1Client) - node2Client, err := rpchttp.New("tcp://localhost:16657", "tcp://localhost:16657"+"/websocket") - require.NoError(t, err) - asserNodeCaughtUp(node2Client) + // node2Client, err := rpchttp.New("tcp://localhost:16657", "tcp://localhost:16657"+"/websocket") + // require.NoError(t, err) + // asserNodeCaughtUp(node2Client) // when a client TX for state update is executed - const myKey = "foo" - myValue := fmt.Sprintf("bar%d", time.Now().UnixNano()) - tx := kvstore.NewTx(myKey, myValue) + // const myKey = "foo" + // myValue := fmt.Sprintf("bar%d", time.Now().UnixNano()) + // tx := fmt.Sprintf("%s=%s", myKey, myValue) - ctx, done := context.WithTimeout(context.Background(), time.Second) - defer done() - result, err := node1Client.BroadcastTxCommit(ctx, tx) - require.NoError(t, err) - require.Equal(t, uint32(0), result.TxResult.Code, result.TxResult.Log) + // ctx, done := context.WithTimeout(context.Background(), time.Second) + // defer done() + // result, err := node1Client.BroadcastTxCommit(ctx, tx) + // require.NoError(t, err) + // require.Equal(t, uint32(0), result.TxResult.Code, result.TxResult.Log) // then state is persisted - ctx, done = context.WithTimeout(context.Background(), 150*time.Millisecond) - defer done() - resQuery, err := node1Client.ABCIQuery(ctx, "/store", []byte(myKey)) - require.NoError(t, err) - require.Equal(t, myValue, string(resQuery.Response.Value)) + // ctx, done = context.WithTimeout(context.Background(), 150*time.Millisecond) + // defer done() + // resQuery, err := node1Client.ABCIQuery(ctx, "/store", []byte(myKey)) + // require.NoError(t, err) + // require.Equal(t, myValue, string(resQuery.Response.Value)) // and state distributed to fullnode - require.Eventually(t, func() bool { - ctx, done := context.WithTimeout(context.Background(), 150*time.Millisecond) - defer done() - resQuery, err = node2Client.ABCIQuery(ctx, "/store", []byte(myKey)) - require.NoError(t, err) - return myValue == string(resQuery.Response.Value) - }, time.Second, 5*time.Millisecond) + // require.Eventually(t, func() bool { + // ctx, done := context.WithTimeout(context.Background(), 150*time.Millisecond) + // defer done() + // resQuery, err = node2Client.ABCIQuery(ctx, "/store", []byte(myKey)) + // require.NoError(t, err) + // return myValue == string(resQuery.Response.Value) + // }, time.Second, 5*time.Millisecond) } diff --git a/test/e2e/sut_helper.go b/test/e2e/sut_helper.go index b775a2d7be..29bc836838 100644 --- a/test/e2e/sut_helper.go +++ b/test/e2e/sut_helper.go @@ -16,12 +16,12 @@ import ( "testing" "time" - "github.com/cometbft/cometbft/p2p" - rpchttp "github.com/cometbft/cometbft/rpc/client/http" - "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/peer" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/rollkit/rollkit/pkg/p2p/key" + "github.com/rollkit/rollkit/pkg/rpc/client" ) // WorkDir defines the default working directory for spawned processes. @@ -50,6 +50,16 @@ func NewSystemUnderTest(t *testing.T) *SystemUnderTest { return r } +// RunCmd runs a command and returns the output +func (s *SystemUnderTest) RunCmd(cmd string, args ...string) (string, error) { + c := exec.Command( //nolint:gosec // used by tests only + locateExecutable(cmd), + args..., + ) + out, err := c.Output() + return string(out), err +} + // StartNode starts a process for the given command and manages it cleanup on test end. func (s *SystemUnderTest) StartNode(cmd string, args ...string) { c := exec.Command( //nolint:gosec // used by tests only @@ -76,19 +86,17 @@ func (s *SystemUnderTest) AwaitNodeUp(t *testing.T, rpcAddr string, timeout time go func() { // query for a non empty block on status page t.Logf("Checking node status: %s\n", rpcAddr) for { - con, err := rpchttp.New(rpcAddr, "/websocket") - if err != nil || con.Start() != nil { + con := client.NewClient(rpcAddr) + if con == nil { time.Sleep(100 * time.Millisecond) continue } - result, err := con.Status(ctx) - if err != nil || result.SyncInfo.LatestBlockHeight < 1 { - _ = con.Stop() + result, err := con.GetState(ctx) + if err != nil || result.LastBlockHeight < 1 { time.Sleep(100 * time.Millisecond) continue } - t.Logf("Node started. Current block: %d\n", result.SyncInfo.LatestBlockHeight) - _ = con.Stop() + t.Logf("Node started. Current block: %d\n", result.LastBlockHeight) started <- struct{}{} return } @@ -256,11 +264,9 @@ func MustCopyFile(t *testing.T, src, dest string) *os.File { // NodeID generates and returns the peer ID from the node's private key. func NodeID(t *testing.T, nodeDir string) peer.ID { t.Helper() - node1Key, err := p2p.LoadOrGenNodeKey(filepath.Join(nodeDir, "config", "node_key.json")) - require.NoError(t, err) - p2pKey, err := crypto.UnmarshalEd25519PrivateKey(node1Key.PrivKey.Bytes()) + node1Key, err := key.LoadOrGenNodeKey(filepath.Join(nodeDir, "config", "node_key.json")) require.NoError(t, err) - node1ID, err := peer.IDFromPrivateKey(p2pKey) + node1ID, err := peer.IDFromPrivateKey(node1Key.PrivKey) require.NoError(t, err) return node1ID } diff --git a/types/hashing.go b/types/hashing.go index d6295db62f..491019bc10 100644 --- a/types/hashing.go +++ b/types/hashing.go @@ -2,8 +2,11 @@ package types import ( "crypto/sha256" + "hash" +) - "github.com/cometbft/cometbft/crypto/merkle" +var ( + leafPrefix = []byte{0} ) // Hash returns hash of the header @@ -21,7 +24,12 @@ func (d *Data) Hash() Hash { // Ignoring the marshal error for now to satisfy the go-header interface // Later on the usage of Hash should be replaced with DA commitment dBytes, _ := d.MarshalBinary() - return merkle.HashFromByteSlices([][]byte{ - dBytes, - }) + return leafHashOpt(sha256.New(), dBytes) +} + +func leafHashOpt(s hash.Hash, leaf []byte) []byte { + s.Reset() + s.Write(leafPrefix) + s.Write(leaf) + return s.Sum(nil) } diff --git a/types/pb/rollkit/v1/rollkit.pb.go b/types/pb/rollkit/v1/rollkit.pb.go index 1ced8f8d16..07ae027078 100644 --- a/types/pb/rollkit/v1/rollkit.pb.go +++ b/types/pb/rollkit/v1/rollkit.pb.go @@ -7,7 +7,6 @@ package v1 import ( - _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" timestamppb "google.golang.org/protobuf/types/known/timestamppb" @@ -559,7 +558,7 @@ var File_rollkit_v1_rollkit_proto protoreflect.FileDescriptor const file_rollkit_v1_rollkit_proto_rawDesc = "" + "\n" + "\x18rollkit/v1/rollkit.proto\x12\n" + - "rollkit.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x14gogoproto/gogo.proto\"1\n" + + "rollkit.v1\x1a\x1fgoogle/protobuf/timestamp.proto\"1\n" + "\aVersion\x12\x14\n" + "\x05block\x18\x01 \x01(\x04R\x05block\x12\x10\n" + "\x03app\x18\x02 \x01(\x04R\x03app\"\xaf\x03\n" + @@ -591,11 +590,11 @@ const file_rollkit_v1_rollkit_proto_rawDesc = "" + "\x0elast_data_hash\x18\x04 \x01(\fR\flastDataHash\"J\n" + "\x04Data\x120\n" + "\bmetadata\x18\x01 \x01(\v2\x14.rollkit.v1.MetadataR\bmetadata\x12\x10\n" + - "\x03txs\x18\x02 \x03(\fR\x03txs\"\xce\x01\n" + + "\x03txs\x18\x02 \x03(\fR\x03txs\"\xc4\x01\n" + "\x04Vote\x12\x19\n" + "\bchain_id\x18\x01 \x01(\tR\achainId\x12\x16\n" + - "\x06height\x18\x02 \x01(\x04R\x06height\x12B\n" + - "\ttimestamp\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampB\b\xc8\xde\x1f\x00\x90\xdf\x1f\x01R\ttimestamp\x12\"\n" + + "\x06height\x18\x02 \x01(\x04R\x06height\x128\n" + + "\ttimestamp\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\x12\"\n" + "\rblock_id_hash\x18\x04 \x01(\fR\vblockIdHash\x12+\n" + "\x11validator_address\x18\x05 \x01(\fR\x10validatorAddressB0Z.github.com/rollkit/rollkit/types/pb/rollkit/v1b\x06proto3" diff --git a/types/pb/rollkit/v1/signer.pb.go b/types/pb/rollkit/v1/signer.pb.go new file mode 100644 index 0000000000..bc71ca0428 --- /dev/null +++ b/types/pb/rollkit/v1/signer.pb.go @@ -0,0 +1,267 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc (unknown) +// source: rollkit/v1/signer.proto + +package v1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// The SignRequest holds the bytes we want to sign. +type SignRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Message []byte `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SignRequest) Reset() { + *x = SignRequest{} + mi := &file_rollkit_v1_signer_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SignRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SignRequest) ProtoMessage() {} + +func (x *SignRequest) ProtoReflect() protoreflect.Message { + mi := &file_rollkit_v1_signer_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SignRequest.ProtoReflect.Descriptor instead. +func (*SignRequest) Descriptor() ([]byte, []int) { + return file_rollkit_v1_signer_proto_rawDescGZIP(), []int{0} +} + +func (x *SignRequest) GetMessage() []byte { + if x != nil { + return x.Message + } + return nil +} + +// The SignResponse returns the signature bytes. +type SignResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Signature []byte `protobuf:"bytes,1,opt,name=signature,proto3" json:"signature,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SignResponse) Reset() { + *x = SignResponse{} + mi := &file_rollkit_v1_signer_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SignResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SignResponse) ProtoMessage() {} + +func (x *SignResponse) ProtoReflect() protoreflect.Message { + mi := &file_rollkit_v1_signer_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SignResponse.ProtoReflect.Descriptor instead. +func (*SignResponse) Descriptor() ([]byte, []int) { + return file_rollkit_v1_signer_proto_rawDescGZIP(), []int{1} +} + +func (x *SignResponse) GetSignature() []byte { + if x != nil { + return x.Signature + } + return nil +} + +// The GetPublicRequest is an empty request. +type GetPublicRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPublicRequest) Reset() { + *x = GetPublicRequest{} + mi := &file_rollkit_v1_signer_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPublicRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPublicRequest) ProtoMessage() {} + +func (x *GetPublicRequest) ProtoReflect() protoreflect.Message { + mi := &file_rollkit_v1_signer_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPublicRequest.ProtoReflect.Descriptor instead. +func (*GetPublicRequest) Descriptor() ([]byte, []int) { + return file_rollkit_v1_signer_proto_rawDescGZIP(), []int{2} +} + +// The GetPublicResponse returns the public key. +type GetPublicResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPublicResponse) Reset() { + *x = GetPublicResponse{} + mi := &file_rollkit_v1_signer_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPublicResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPublicResponse) ProtoMessage() {} + +func (x *GetPublicResponse) ProtoReflect() protoreflect.Message { + mi := &file_rollkit_v1_signer_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPublicResponse.ProtoReflect.Descriptor instead. +func (*GetPublicResponse) Descriptor() ([]byte, []int) { + return file_rollkit_v1_signer_proto_rawDescGZIP(), []int{3} +} + +func (x *GetPublicResponse) GetPublicKey() []byte { + if x != nil { + return x.PublicKey + } + return nil +} + +var File_rollkit_v1_signer_proto protoreflect.FileDescriptor + +const file_rollkit_v1_signer_proto_rawDesc = "" + + "\n" + + "\x17rollkit/v1/signer.proto\x12\n" + + "rollkit.v1\"'\n" + + "\vSignRequest\x12\x18\n" + + "\amessage\x18\x01 \x01(\fR\amessage\",\n" + + "\fSignResponse\x12\x1c\n" + + "\tsignature\x18\x01 \x01(\fR\tsignature\"\x12\n" + + "\x10GetPublicRequest\"2\n" + + "\x11GetPublicResponse\x12\x1d\n" + + "\n" + + "public_key\x18\x01 \x01(\fR\tpublicKey2\x94\x01\n" + + "\rSignerService\x129\n" + + "\x04Sign\x12\x17.rollkit.v1.SignRequest\x1a\x18.rollkit.v1.SignResponse\x12H\n" + + "\tGetPublic\x12\x1c.rollkit.v1.GetPublicRequest\x1a\x1d.rollkit.v1.GetPublicResponseB0Z.github.com/rollkit/rollkit/types/pb/rollkit/v1b\x06proto3" + +var ( + file_rollkit_v1_signer_proto_rawDescOnce sync.Once + file_rollkit_v1_signer_proto_rawDescData []byte +) + +func file_rollkit_v1_signer_proto_rawDescGZIP() []byte { + file_rollkit_v1_signer_proto_rawDescOnce.Do(func() { + file_rollkit_v1_signer_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_rollkit_v1_signer_proto_rawDesc), len(file_rollkit_v1_signer_proto_rawDesc))) + }) + return file_rollkit_v1_signer_proto_rawDescData +} + +var file_rollkit_v1_signer_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_rollkit_v1_signer_proto_goTypes = []any{ + (*SignRequest)(nil), // 0: rollkit.v1.SignRequest + (*SignResponse)(nil), // 1: rollkit.v1.SignResponse + (*GetPublicRequest)(nil), // 2: rollkit.v1.GetPublicRequest + (*GetPublicResponse)(nil), // 3: rollkit.v1.GetPublicResponse +} +var file_rollkit_v1_signer_proto_depIdxs = []int32{ + 0, // 0: rollkit.v1.SignerService.Sign:input_type -> rollkit.v1.SignRequest + 2, // 1: rollkit.v1.SignerService.GetPublic:input_type -> rollkit.v1.GetPublicRequest + 1, // 2: rollkit.v1.SignerService.Sign:output_type -> rollkit.v1.SignResponse + 3, // 3: rollkit.v1.SignerService.GetPublic:output_type -> rollkit.v1.GetPublicResponse + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_rollkit_v1_signer_proto_init() } +func file_rollkit_v1_signer_proto_init() { + if File_rollkit_v1_signer_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_rollkit_v1_signer_proto_rawDesc), len(file_rollkit_v1_signer_proto_rawDesc)), + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_rollkit_v1_signer_proto_goTypes, + DependencyIndexes: file_rollkit_v1_signer_proto_depIdxs, + MessageInfos: file_rollkit_v1_signer_proto_msgTypes, + }.Build() + File_rollkit_v1_signer_proto = out.File + file_rollkit_v1_signer_proto_goTypes = nil + file_rollkit_v1_signer_proto_depIdxs = nil +} diff --git a/types/pb/rollkit/v1/state.pb.go b/types/pb/rollkit/v1/state.pb.go index 9cf51853a9..46cef39037 100644 --- a/types/pb/rollkit/v1/state.pb.go +++ b/types/pb/rollkit/v1/state.pb.go @@ -7,7 +7,6 @@ package v1 import ( - _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" timestamppb "google.golang.org/protobuf/types/known/timestamppb" @@ -129,13 +128,13 @@ var File_rollkit_v1_state_proto protoreflect.FileDescriptor const file_rollkit_v1_state_proto_rawDesc = "" + "\n" + "\x16rollkit/v1/state.proto\x12\n" + - "rollkit.v1\x1a\x14gogoproto/gogo.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x18rollkit/v1/rollkit.proto\"\xd6\x02\n" + + "rollkit.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x18rollkit/v1/rollkit.proto\"\xcc\x02\n" + "\x05State\x12-\n" + "\aversion\x18\x01 \x01(\v2\x13.rollkit.v1.VersionR\aversion\x12\x19\n" + "\bchain_id\x18\x02 \x01(\tR\achainId\x12%\n" + "\x0einitial_height\x18\x03 \x01(\x04R\rinitialHeight\x12*\n" + - "\x11last_block_height\x18\x04 \x01(\x04R\x0flastBlockHeight\x12L\n" + - "\x0flast_block_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampB\b\xc8\xde\x1f\x00\x90\xdf\x1f\x01R\rlastBlockTime\x12\x1b\n" + + "\x11last_block_height\x18\x04 \x01(\x04R\x0flastBlockHeight\x12B\n" + + "\x0flast_block_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\rlastBlockTime\x12\x1b\n" + "\tda_height\x18\x06 \x01(\x04R\bdaHeight\x12*\n" + "\x11last_results_hash\x18\a \x01(\fR\x0flastResultsHash\x12\x19\n" + "\bapp_hash\x18\b \x01(\fR\aappHashB0Z.github.com/rollkit/rollkit/types/pb/rollkit/v1b\x06proto3" diff --git a/types/pb/rollkit/v1/v1connect/signer.connect.go b/types/pb/rollkit/v1/v1connect/signer.connect.go new file mode 100644 index 0000000000..ff668b9ec2 --- /dev/null +++ b/types/pb/rollkit/v1/v1connect/signer.connect.go @@ -0,0 +1,140 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: rollkit/v1/signer.proto + +package v1connect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + v1 "github.com/rollkit/rollkit/types/pb/rollkit/v1" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // SignerServiceName is the fully-qualified name of the SignerService service. + SignerServiceName = "rollkit.v1.SignerService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // SignerServiceSignProcedure is the fully-qualified name of the SignerService's Sign RPC. + SignerServiceSignProcedure = "/rollkit.v1.SignerService/Sign" + // SignerServiceGetPublicProcedure is the fully-qualified name of the SignerService's GetPublic RPC. + SignerServiceGetPublicProcedure = "/rollkit.v1.SignerService/GetPublic" +) + +// SignerServiceClient is a client for the rollkit.v1.SignerService service. +type SignerServiceClient interface { + // Sign signs the given message. + Sign(context.Context, *connect.Request[v1.SignRequest]) (*connect.Response[v1.SignResponse], error) + // GetPublic returns the public key. + GetPublic(context.Context, *connect.Request[v1.GetPublicRequest]) (*connect.Response[v1.GetPublicResponse], error) +} + +// NewSignerServiceClient constructs a client for the rollkit.v1.SignerService service. By default, +// it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and +// sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() +// or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewSignerServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SignerServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + signerServiceMethods := v1.File_rollkit_v1_signer_proto.Services().ByName("SignerService").Methods() + return &signerServiceClient{ + sign: connect.NewClient[v1.SignRequest, v1.SignResponse]( + httpClient, + baseURL+SignerServiceSignProcedure, + connect.WithSchema(signerServiceMethods.ByName("Sign")), + connect.WithClientOptions(opts...), + ), + getPublic: connect.NewClient[v1.GetPublicRequest, v1.GetPublicResponse]( + httpClient, + baseURL+SignerServiceGetPublicProcedure, + connect.WithSchema(signerServiceMethods.ByName("GetPublic")), + connect.WithClientOptions(opts...), + ), + } +} + +// signerServiceClient implements SignerServiceClient. +type signerServiceClient struct { + sign *connect.Client[v1.SignRequest, v1.SignResponse] + getPublic *connect.Client[v1.GetPublicRequest, v1.GetPublicResponse] +} + +// Sign calls rollkit.v1.SignerService.Sign. +func (c *signerServiceClient) Sign(ctx context.Context, req *connect.Request[v1.SignRequest]) (*connect.Response[v1.SignResponse], error) { + return c.sign.CallUnary(ctx, req) +} + +// GetPublic calls rollkit.v1.SignerService.GetPublic. +func (c *signerServiceClient) GetPublic(ctx context.Context, req *connect.Request[v1.GetPublicRequest]) (*connect.Response[v1.GetPublicResponse], error) { + return c.getPublic.CallUnary(ctx, req) +} + +// SignerServiceHandler is an implementation of the rollkit.v1.SignerService service. +type SignerServiceHandler interface { + // Sign signs the given message. + Sign(context.Context, *connect.Request[v1.SignRequest]) (*connect.Response[v1.SignResponse], error) + // GetPublic returns the public key. + GetPublic(context.Context, *connect.Request[v1.GetPublicRequest]) (*connect.Response[v1.GetPublicResponse], error) +} + +// NewSignerServiceHandler builds an HTTP handler from the service implementation. It returns the +// path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewSignerServiceHandler(svc SignerServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + signerServiceMethods := v1.File_rollkit_v1_signer_proto.Services().ByName("SignerService").Methods() + signerServiceSignHandler := connect.NewUnaryHandler( + SignerServiceSignProcedure, + svc.Sign, + connect.WithSchema(signerServiceMethods.ByName("Sign")), + connect.WithHandlerOptions(opts...), + ) + signerServiceGetPublicHandler := connect.NewUnaryHandler( + SignerServiceGetPublicProcedure, + svc.GetPublic, + connect.WithSchema(signerServiceMethods.ByName("GetPublic")), + connect.WithHandlerOptions(opts...), + ) + return "/rollkit.v1.SignerService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case SignerServiceSignProcedure: + signerServiceSignHandler.ServeHTTP(w, r) + case SignerServiceGetPublicProcedure: + signerServiceGetPublicHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedSignerServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedSignerServiceHandler struct{} + +func (UnimplementedSignerServiceHandler) Sign(context.Context, *connect.Request[v1.SignRequest]) (*connect.Response[v1.SignResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("rollkit.v1.SignerService.Sign is not implemented")) +} + +func (UnimplementedSignerServiceHandler) GetPublic(context.Context, *connect.Request[v1.GetPublicRequest]) (*connect.Response[v1.GetPublicResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("rollkit.v1.SignerService.GetPublic is not implemented")) +}