Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(zetacore)!: remove rosetta api #3130

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions cmd/zetacored/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"os"

rosettaCmd "cosmossdk.io/tools/rosetta/cmd"
dbm "github.com/cometbft/cometbft-db"
tmcfg "github.com/cometbft/cometbft/config"
tmcli "github.com/cometbft/cometbft/libs/cli"
Expand Down Expand Up @@ -177,8 +176,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig types.EncodingConfig) {
if err := SetEthereumHDPath(rootCmd); err != nil {
fmt.Printf("warning: unable to set default HD path: %v\n", err)
}

rootCmd.AddCommand(rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec))
}

func addModuleInitFlags(startCmd *cobra.Command) {
Expand Down
17 changes: 0 additions & 17 deletions contrib/localnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# - An Ethereum node (eth)
# - A secondary optional Ethereum node (eth2) enabled when profile is set to eth2
# - A Bitcoin node (bitcoin)
# - A Rosetta API (rosetta)
# - An orchestrator to manage interaction with the localnet (orchestrator)
# - An upgrade host to serve binaries for the upgrade tests (upgrade-host). Only enabled when profile is set to upgrade.
# - An upgrade orchestrator to send the upgrade governance proposal (upgrade-orchestrator). Only enabled when profile is set to upgrade.
Expand All @@ -19,22 +18,6 @@ networks:
- subnet: 172.20.0.0/24

services:
rosetta:
image: zetanode:latest
container_name: rosetta
hostname: rosetta
depends_on:
zetacore0:
condition: service_healthy
ports:
- "8080:8080"
networks:
mynetwork:
ipv4_address: 172.20.0.200
entrypoint: ["zetacored", "rosetta", "--tendermint", "zetacore0:26657", "--grpc", "zetacore0:9090", "--network", "athens_101-1", "--blockchain", "zetacore"]
volumes:
- ssh:/root/.ssh

zetacore0:
image: zetanode:latest
container_name: zetacore0
Expand Down
14 changes: 0 additions & 14 deletions contrib/localnet/scripts/start-rosetta.sh

This file was deleted.

20 changes: 0 additions & 20 deletions contrib/localnet/zetacored/common/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,6 @@ enabled-unsafe-cors = true
### Rosetta Configuration ###
###############################################################################

[rosetta]

# Enable defines if the Rosetta API server should be enabled.
enable = false

# Address defines the Rosetta API server to listen on.
address = ":8080"

# Network defines the name of the blockchain that will be returned by Rosetta.
blockchain = "app"

# Network defines the name of the network that will be returned by Rosetta.
network = "network"

# Retries defines the number of retries when connecting to the node before failing.
retries = 3

# Offline defines if Rosetta server should run in offline mode.
offline = false

###############################################################################
### gRPC Configuration ###
###############################################################################
Expand Down
40 changes: 0 additions & 40 deletions docs/cli/zetacored/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Zetacore Daemon (server)
* [zetacored parse-genesis-file](#zetacored-parse-genesis-file) - Parse the provided genesis file and import the required data into the optionally provided genesis file
* [zetacored query](#zetacored-query) - Querying subcommands
* [zetacored rollback](#zetacored-rollback) - rollback cosmos-sdk and tendermint state by one height
* [zetacored rosetta](#zetacored-rosetta) - spin up a rosetta server
* [zetacored snapshots](#zetacored-snapshots) - Manage local snapshots
* [zetacored start](#zetacored-start) - Run the full node
* [zetacored status](#zetacored-status) - Query remote node for status
Expand Down Expand Up @@ -7363,45 +7362,6 @@ zetacored rollback [flags]

* [zetacored](#zetacored) - Zetacore Daemon (server)

## zetacored rosetta

spin up a rosetta server

```
zetacored rosetta [flags]
```

### Options

```
--addr string the address rosetta will bind to
--blockchain string the blockchain type
--denom-to-suggest string default denom for fee suggestion
--enable-fee-suggestion enable default fee suggestion
--gas-to-suggest int default gas for fee suggestion (default 200000)
--grpc string the app gRPC endpoint
-h, --help help for rosetta
--network string the network name
--offline run rosetta only with construction API
--prices-to-suggest string default prices for fee suggestion
--retries int the number of retries that will be done before quitting (default 5)
--tendermint string the tendermint rpc endpoint, without tcp://
```

### Options inherited from parent commands

```
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--log_no_color Disable colored logs
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored](#zetacored) - Zetacore Daemon (server)

## zetacored snapshots

Manage local snapshots
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ toolchain go1.22.8
require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
cosmossdk.io/tools/rosetta v0.2.1
cosmossdk.io/tools/rosetta v0.2.1 // indirect
gartnera marked this conversation as resolved.
Show resolved Hide resolved
github.com/99designs/keyring v1.2.1
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/btcec/v2 v2.3.2
github.com/btcsuite/btcd/btcutil v1.1.6
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/cenkalti/backoff/v4 v4.3.0
github.com/cockroachdb/errors v1.11.1
github.com/coinbase/rosetta-sdk-go v0.7.9
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
github.com/cometbft/cometbft v0.37.5
github.com/cometbft/cometbft-db v0.12.0
github.com/cosmos/btcutil v1.0.5
Expand Down
54 changes: 1 addition & 53 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
"time"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/tools/rosetta"
crgserver "cosmossdk.io/tools/rosetta/lib/server"
dbm "github.com/cometbft/cometbft-db"
abciserver "github.com/cometbft/cometbft/abci/server"
tcmd "github.com/cometbft/cometbft/cmd/cometbft/commands"
Expand All @@ -50,7 +48,6 @@ import (
"github.com/cosmos/cosmos-sdk/server/types"
pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
ethmetricsexp "github.com/ethereum/go-ethereum/metrics/exp"
"github.com/spf13/cobra"
"github.com/zeta-chain/ethermint/indexer"
Expand Down Expand Up @@ -626,61 +623,12 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt
}

// At this point it is safe to block the process if we're in query only mode as
// we do not need to start Rosetta or handle any Tendermint related processes.
// we do not need to handle any Tendermint related processes.
if gRPCOnly {
// wait for signal capture and gracefully return
return server.WaitForQuitSignals()
}

var rosettaSrv crgserver.Server
if config.Rosetta.Enable {
offlineMode := config.Rosetta.Offline

// If GRPC is not enabled rosetta cannot work in online mode, so it works in
// offline mode.
if !config.GRPC.Enable {
offlineMode = true
}

minGasPrices, err := sdk.ParseDecCoins(config.MinGasPrices)
if err != nil {
ctx.Logger.Error("failed to parse minimum-gas-prices", "error", err.Error())
return err
}

conf := &rosetta.Config{
Blockchain: config.Rosetta.Blockchain,
Network: config.Rosetta.Network,
TendermintRPC: ctx.Config.RPC.ListenAddress,
GRPCEndpoint: config.GRPC.Address,
Addr: config.Rosetta.Address,
Retries: config.Rosetta.Retries,
Offline: offlineMode,
GasToSuggest: config.Rosetta.GasToSuggest,
EnableFeeSuggestion: config.Rosetta.EnableFeeSuggestion,
GasPrices: minGasPrices.Sort(),
Codec: clientCtx.Codec.(*codec.ProtoCodec),
InterfaceRegistry: clientCtx.InterfaceRegistry,
}

rosettaSrv, err = rosetta.ServerFromConfig(conf)
if err != nil {
return err
}

errCh := make(chan error)
go func() {
if err := rosettaSrv.Start(); err != nil {
errCh <- err
}
}()

select {
case err := <-errCh:
return err
case <-time.After(types.ServerStartTime): // assume server started successfully
}
}
// Wait for SIGINT or SIGTERM signal
return server.WaitForQuitSignals()
}
Expand Down
19 changes: 17 additions & 2 deletions x/observer/keeper/events.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package keeper

import (
"encoding/json"
"log"
gartnera marked this conversation as resolved.
Show resolved Hide resolved
"strconv"

types2 "github.com/coinbase/rosetta-sdk-go/types"
sdk "github.com/cosmos/cosmos-sdk/types"

types "github.com/zeta-chain/node/x/observer/types"
Expand All @@ -21,11 +22,25 @@ func EmitEventBallotCreated(ctx sdk.Context, ballot types.Ballot, observationHas
}
}

// vendor this code from github.com/coinbase/rosetta-sdk-go/types
func prettyPrintStruct(val interface{}) string {
prettyStruct, err := json.MarshalIndent(
val,
"",
" ",
)
if err != nil {
log.Fatal(err)
}

return string(prettyStruct)
}
gartnera marked this conversation as resolved.
Show resolved Hide resolved

func EmitEventKeyGenBlockUpdated(ctx sdk.Context, keygen *types.Keygen) {
err := ctx.EventManager().EmitTypedEvents(&types.EventKeygenBlockUpdated{
MsgTypeUrl: sdk.MsgTypeURL(&types.MsgUpdateKeygen{}),
KeygenBlock: strconv.Itoa(int(keygen.BlockNumber)),
KeygenPubkeys: types2.PrettyPrintStruct(keygen.GranteePubkeys),
KeygenPubkeys: prettyPrintStruct(keygen.GranteePubkeys),
gartnera marked this conversation as resolved.
Show resolved Hide resolved
})
if err != nil {
ctx.Logger().Error("Error emitting EventKeygenBlockUpdated :", err)
Expand Down
Loading