Skip to content

Commit

Permalink
feat!: drop cosmos-sdk and call manifestd (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency authored Jun 27, 2024
1 parent aa66f41 commit 9981a0b
Show file tree
Hide file tree
Showing 16 changed files with 256 additions and 1,327 deletions.
14 changes: 12 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# The Lifted Initiative
version: 2.1

GO_VERSION: &go_version '1.22.2'
GORELEASER_VERSION: &goreleaser_version 'v1.25.1'
GO_VERSION: &go_version '1.22.4'
GORELEASER_VERSION: &goreleaser_version 'v1.26.2'
GO_MOD_CACHE_KEY: &go_mod_cache_key 'go-mod-2'

orbs:
Expand All @@ -24,6 +24,16 @@ jobs:
- go/mod-download
- go/save-cache:
key: *go_mod_cache_key
- run:
name: Pull manifest-ledger Docker image
command: docker pull ghcr.io/liftedinit/manifest-ledger:v0.0.1-alpha.10
- run:
name: Install manifestd from manifest-ledger Docker image
command: |
id=$(docker create ghcr.io/liftedinit/manifest-ledger:v0.0.1-alpha.10)
docker cp $id:/usr/bin/manifestd /tmp/manifestd
sudo mv /tmp/manifestd /usr/local/bin/
docker rm -v $id
- run: make test
- run: make coverage
- codecov/upload:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Flags:
- `--keyring-backend string` - The keyring backend to use. Default is `test`.
- `--node-address` - The RPC endpoint of the MANIFEST chain. Default is `http://localhost:26657`.
- `--uuid string` - The UUID of the work item to migrate. Default is an empty string.
- `--binary` - The name of the chain binary used to perform the migration. The binary must be in `$PATH`. Default is `manifestd`

This command triggers a token transaction on the MANIFEST chain and updates the work item status in the remote database.

Expand Down
4 changes: 4 additions & 0 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,9 @@ func LoadMigrationConfigFromCLI() config.MigrateConfig {
TokenMap: tokenMap,
WaitTxTimeout: viper.GetUint("wait-for-tx-timeout"),
WaitBlockTimeout: viper.GetUint("wait-for-block-timeout"),
Binary: viper.GetString("binary"),
GasAdjustment: viper.GetFloat64("gas-adjustment"),
GasPrice: viper.GetFloat64("gas-price"),
GasDenom: viper.GetString("gas-denom"),
}
}
32 changes: 31 additions & 1 deletion cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ func setupStringCmdFlags(command *cobra.Command) {
{"bank-address", "bank-address", "bank", "Bank address to send tokens from", false},
{"chain-home", "chain-home", "", "Root directory of the chain configuration", false},
{"uuid", "migrate-uuid", "", "UUID of the work item to migrate", true},
{"binary", "binary", "manifestd", "Binary name of the blockchain to migrate to", false},
{"gas-denom", "gas-denom", "umfx", "Denomination of the gas price", false},
}

for _, arg := range args {
Expand Down Expand Up @@ -144,12 +146,31 @@ func setupUIntCmdFlags(command *cobra.Command) {
slog.Error(ErrorBindingFlag, "error", err)
}
}
}

func setupFloatCmdFlags(command *cobra.Command) {
args := []struct {
name string
key string
value float64
usage string
}{
{"gas-price", "gas-price", 0.0011, "Minimum gas price to use for transactions"},
{"gas-adjustment", "gas-adjustment", 1.2, "Gas adjustment to use for transactions"},
}

for _, arg := range args {
command.Flags().Float64(arg.name, arg.value, arg.usage)
if err := viper.BindPFlag(arg.key, command.Flags().Lookup(arg.name)); err != nil {
slog.Error(ErrorBindingFlag, "error", err)
}
}
}

func SetupMigrateCmdFlags(command *cobra.Command) {
setupStringCmdFlags(command)
setupUIntCmdFlags(command)
setupFloatCmdFlags(command)
}

func mapToken(symbol string, tokenMap map[string]utils.TokenInfo) (*utils.TokenInfo, error) {
Expand Down Expand Up @@ -195,7 +216,7 @@ func migrate(r *resty.Client, item *store.WorkItem, config config.MigrateConfig)
return errors.WithMessage(err, "error mapping token")
}

slog.Debug("Amount before conversion", "amount", txArgs.Amount)
slog.Debug("Amount", "amount", txArgs.Amount)

var newItem = *item

Expand Down Expand Up @@ -265,7 +286,16 @@ func setAsCompleted(r *resty.Client, newItem store.WorkItem, txHash *string, blo

func setAsFailed(r *resty.Client, newItem store.WorkItem, errStr *string) error {
newItem.Status = store.FAILED

// Truncate the error string if it is too long (Talib limitation)
maxLen := 8192
if len(*errStr) > maxLen {
// errStr should be at most 8191 characters long
almostHalf := maxLen/2 - 2
*errStr = (*errStr)[:almostHalf] + " ... " + (*errStr)[len(*errStr)-almostHalf:]
}
newItem.Error = errStr

if err := store.UpdateWorkItemAndSaveState(r, newItem); err != nil {
return errors.WithMessage(err, "error setting status to FAILED")
}
Expand Down
126 changes: 5 additions & 121 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
module github.com/liftedinit/mfx-migrator

go 1.22.2
go 1.22.4

require (
cosmossdk.io/math v1.3.0
github.com/cometbft/cometbft v0.38.6
github.com/cosmos/cosmos-sdk v0.50.5
github.com/go-resty/resty/v2 v2.11.0
github.com/google/uuid v1.6.0
github.com/jarcoal/httpmock v1.3.1
Expand All @@ -16,142 +13,29 @@ require (
)

require (
cosmossdk.io/api v0.7.3 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/core v0.11.0 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/log v1.3.1 // indirect
cosmossdk.io/store v1.0.2 // indirect
cosmossdk.io/x/tx v0.13.1 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/OneOfOne/xxhash v1.2.8 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.0 // 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.9.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.2 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.4 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.4.11 // indirect
github.com/cosmos/iavl v1.0.1 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/emicklei/dot v1.6.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.1 // indirect
github.com/hashicorp/go-plugin v1.5.2 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.8.12 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.47.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.9.0 // indirect
github.com/rs/zerolog v1.32.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.1 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.7.0 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect
google.golang.org/grpc v1.62.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
pgregory.net/rapid v1.1.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit 9981a0b

Please sign in to comment.