Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
887f26d
Update usages of core/lib to reflect current state (#59)
lazynina Feb 27, 2024
63505c3
Update DB functions and seeks to work with staked and locked stake ba…
lazynina Feb 27, 2024
02cf0ec
Extract operations from stake, unstake, and unlock stake txns (#61)
lazynina Feb 27, 2024
7e72e0b
Rosetta Support for restaked staking rewards (#60)
lazynina Feb 27, 2024
ffec52f
Use utxoOp.LockedAtEpochNumber to get proper subaccount in getUnstake…
lazynina Feb 27, 2024
fddd4d9
Clean up rosetta pos changes (#68)
lazynina Feb 27, 2024
d0c0612
Use UtxoOps from core's badger instance instead of copying over to ro…
lazynina Feb 27, 2024
03b264b
Update rosetta server init params (#70)
lazynina Feb 27, 2024
f009cb1
Address DH feedback (#71)
lazynina Feb 27, 2024
34b38e8
Update go mod and fix typo (#73)
lazynina Feb 29, 2024
58d23cc
WriteBatch enhancements (#72)
lazynina Mar 11, 2024
a2e132e
Merge branch 'main' into feature/proof-of-stake
lazynina Mar 11, 2024
93ed82c
Rosetta for atomic txns (#76)
lazynina Mar 29, 2024
975a0b0
Remove relic tags in scripts (#78)
lazynina Mar 29, 2024
43b4697
Update to badger v4 and update usage of NewAPIServer (#79)
lazynina Apr 5, 2024
3dcbd4b
Upgrade go to 1-22 (#81)
lazynina Apr 11, 2024
54401ce
Upgrade deps (#82)
lazynina Apr 11, 2024
9e61c71
NewUtxoView doesn't return an error (#83)
lazynina Apr 12, 2024
f66a0a2
Use OnBlockCommitted handler instead of OnBlockConnected (#84)
lazynina Apr 12, 2024
75a9b26
trigger build
lazynina Apr 22, 2024
ea1f728
trigger build 042324
lazynina Apr 23, 2024
0bbbc9a
revert construction hash function changes
lazynina Apr 23, 2024
08e1f67
Fix dockerfile
lazynina Apr 23, 2024
adafdc5
fix build error
lazynina Apr 23, 2024
3268bdf
trigger build for new pre-releases
lazynina Apr 26, 2024
0e2e55c
fix new server calls (#85)
lazynina May 6, 2024
09d7f38
Update NewServer call (#86)
lazynina May 7, 2024
b37cc3f
Remove snapshot db close (#87)
lazynina May 16, 2024
b7567d5
trigger build 5-19-24
lazynina May 19, 2024
ca40717
Add checkpoint syncing providers to rosetta (#88)
lazynina May 20, 2024
990de63
Fix snapshot block height period (#90)
lazynina May 20, 2024
4730534
Reduce write batch size
diamondhands0 May 20, 2024
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
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ FROM alpine:latest AS rosetta

RUN apk update && apk upgrade && apk add --update go gcc g++ vips-dev

COPY --from=golang:1.22-alpine /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"

WORKDIR /deso/src

COPY rosetta-deso/go.mod rosetta-deso/
Expand All @@ -20,10 +23,13 @@ COPY rosetta-deso/services services
COPY rosetta-deso/main.go .

# include core src
COPY core/desohash ../core/desohash
COPY core/cmd ../core/cmd
COPY core/lib ../core/lib
COPY core/migrate ../core/migrate
COPY core/desohash ../core/desohash
COPY core/cmd ../core/cmd
COPY core/lib ../core/lib
COPY core/migrate ../core/migrate
COPY core/bls ../core/bls
COPY core/collections ../core/collections
COPY core/consensus ../core/consensus

# build rosetta-deso
RUN GOOS=linux go build -mod=mod -a -installsuffix cgo -o bin/rosetta-deso main.go
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,19 @@ To run the construction checks, execute:
```
bin/rosetta-cli check:construction --configuration-file rosetta-cli-conf/testnet/deso.conf
```

### M1 Mac Users

There are some issues with running the rosetta cli w/ M1 Macs. To fix this, you can run the following command to build
the rosetta cli docker image:
```
docker build github.com/coinbase/mesh-cli --platform linux/amd64 -t rosetta-cli
```

Then update the configuration file to use `http://host.docker.internal:17005` instead of `http://localhost:17005` -
basically replacing all usages of `localhost` with `host.docker.internal`.

Then to run the rosetta cli check:data tests, you can run the following command:
```
docker run -v "$(pwd):/data" --rm -it --platform linux/amd64 rosetta-cli check:data --configuration-file /data/rosetta-cli-conf/testnet/deso.conf
```
117 changes: 106 additions & 11 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ package cmd

import (
"fmt"
coreCmd "github.com/deso-protocol/core/cmd"
"log"
"net/http"
"os"

coreCmd "github.com/deso-protocol/core/cmd"
"github.com/deso-protocol/core/lib"
"github.com/dgraph-io/badger/v4"

"github.com/coinbase/rosetta-sdk-go/asserter"
"github.com/coinbase/rosetta-sdk-go/server"
"github.com/coinbase/rosetta-sdk-go/types"
Expand Down Expand Up @@ -45,6 +48,7 @@ to quickly create a Cobra application.`,
[]*types.NetworkIdentifier{config.Network},
nil,
false,
"", // TODO: Figure out what we should supply for validation path.
)
if err != nil {
glog.Fatalf("unable to create new server asserter", "error", err)
Expand All @@ -64,19 +68,110 @@ to quickly create a Cobra application.`,
},
}

func init() {
// Add all the core node flags
coreCmd.SetupRunFlags(runCmd)
// debugCmd represents the debug command. It can help you debug the chain by
// printing txns directly from the badgerdb, among other things. You must modify
// the go code directly to suit your needs. It's not an "out of the box" thing.
var debugCmd = &cobra.Command{
Use: "debug",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
RunE: func(cmd *cobra.Command, args []string) error {
config, err := deso.LoadConfig()
if err != nil {
return err
}
// You need to set this or else the block cutovers will mess up your GetBlockIndex in
// DeserializeBlockNode.
// Check for regtest mode
if config.Regtest {
config.Params.EnableRegtest()
}
lib.GlobalDeSoParams = *config.Params

dbDir := lib.GetBadgerDbPath(config.DataDirectory)
opts := lib.PerformanceBadgerOptions(dbDir)
opts.ValueDir = dbDir
chainDB, err := badger.Open(opts)
if err != nil {
panic(err)
}

runCmd.PersistentFlags().String("network", string(deso.Mainnet), "network to connect to")
runCmd.PersistentFlags().String("mode", string(deso.Online), "mode to start in")
runCmd.PersistentFlags().Int("port", 17005, "rosetta api listener port")
runCmd.PersistentFlags().Int("node-port", 17000, "node api listener port")
runCmd.PersistentFlags().String("data-directory", "/data", "location to store persistent data")
// See if we have a best chain hash stored in the db.
bestBlockHash := lib.DbGetBestHash(chainDB, nil, lib.ChainTypeDeSoBlock)

runCmd.PersistentFlags().VisitAll(func(flag *pflag.Flag) {
// If there is no best chain hash in the db then it means we've never
// initialized anything so take the time to do it now.
if bestBlockHash == nil {
panic("bestBlockHash is nil")
}

blockIndexByHash, err := lib.GetBlockIndex(chainDB, false /*bitcoinNodes*/, config.Params)
if err != nil {
panic(fmt.Sprintf("Problem reading block index from db: %v", err))
}

tipNode := blockIndexByHash[*bestBlockHash]
if tipNode == nil {
panic(fmt.Sprintf("Best hash (%#v) not found in block index", bestBlockHash.String()))
}
bestChain, err := lib.GetBestChain(tipNode, blockIndexByHash)
if err != nil {
panic(fmt.Sprintf("Problem reading best chain from db: %v", err))
}

for _, bestChainNode := range bestChain {
block, err := lib.GetBlock(bestChainNode.Hash, chainDB, nil)
if err != nil {
panic(fmt.Sprintf("Problem reading block from db: %v", err))
}
if len(block.Txns) > 1 {
fmt.Println(block.Header.Height, bestChainNode.Hash.String(), len(block.Txns))
for _, txn := range block.Txns {
fmt.Println("\t", txn.Hash().String())
pubkeyString := "block reward"
if len(txn.PublicKey) != 0 {
pubkeyString = lib.PkToStringTestnet(txn.PublicKey)
}
fmt.Println("\t\tSender: \t", pubkeyString)
for _, output := range txn.TxOutputs {
fmt.Println("\t\tRecipient: \t", lib.PkToStringTestnet(output.PublicKey))
fmt.Println("\t\tAmount: \t", output.AmountNanos)
}
}
}
}
return nil
},
}

func initFlags(cmdIter *cobra.Command) {
coreCmd.SetupRunFlags(cmdIter)

cmdIter.PersistentFlags().String("network", string(deso.Mainnet), "network to connect to")
cmdIter.PersistentFlags().String("mode", string(deso.Online), "mode to start in")
cmdIter.PersistentFlags().Int("port", 17005, "rosetta api listener port")
cmdIter.PersistentFlags().Int("node-port", 17000, "node api listener port")
cmdIter.PersistentFlags().String("data-directory", "/data", "location to store persistent data")

cmdIter.PersistentFlags().VisitAll(func(flag *pflag.Flag) {
viper.BindPFlag(flag.Name, flag)
})

rootCmd.AddCommand(runCmd)
rootCmd.AddCommand(cmdIter)
}

func init() {
// This is a dirty hack. When we run in debug mode, we need to set the flags on the debugCmd rather
// than the runCmd. There is probably a "right" way to do this, but the below works for now...
if len(os.Args) > 1 && os.Args[1] == "debug" {
fmt.Println("DEBUGGING!")
initFlags(debugCmd)
} else {
initFlags(runCmd)
}
}
Loading