From 87081a2da8d4c391912f5d2758b81d034f63bc59 Mon Sep 17 00:00:00 2001 From: KonradStaniec Date: Thu, 16 May 2024 12:44:58 +0200 Subject: [PATCH 1/3] better logging of errors for failed request (#26) --- internal/services/remote_signer.go | 2 +- internal/services/unbonding_pipeline.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/services/remote_signer.go b/internal/services/remote_signer.go index 02aa98d..3d305be 100644 --- a/internal/services/remote_signer.go +++ b/internal/services/remote_signer.go @@ -45,7 +45,7 @@ func (rs *RemoteSigner) SignUnbondingTransaction(req *SignRequest) (*PubKeySigPa ) if err != nil { - return nil, err + return nil, fmt.Errorf("request to coventant %s, with url:%s, failed: %w", pkStr, url, err) } return &PubKeySigPair{ diff --git a/internal/services/unbonding_pipeline.go b/internal/services/unbonding_pipeline.go index 472cd85..7d2d18a 100644 --- a/internal/services/unbonding_pipeline.go +++ b/internal/services/unbonding_pipeline.go @@ -184,7 +184,7 @@ func (up *UnbondingPipeline) requestSigFromCovenant(req *SignRequest, resultChan // TODO record metrics up.logger.Error("failed to get signatures from covenant", "signer_pk", pkStr, - "error", res.Err) + "error", err) res.Err = err } else { From 919666f6ebc1e2568e106b9db74bbfc7a63b3e85 Mon Sep 17 00:00:00 2001 From: KonradStaniec Date: Thu, 16 May 2024 13:13:16 +0200 Subject: [PATCH 2/3] Use scheme from original url (#27) --- internal/config/remote_signer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/config/remote_signer.go b/internal/config/remote_signer.go index c3bbbaa..a90db2f 100644 --- a/internal/config/remote_signer.go +++ b/internal/config/remote_signer.go @@ -46,7 +46,7 @@ func (c *RemoteSignerConfig) Parse() (*ParsedRemoteSignerConfig, error) { if err != nil { return nil, fmt.Errorf("invalid url %s: %w", urlStr, err) } - urls[i] = fmt.Sprintf("http://%s", parsedUrl.Host) + urls[i] = fmt.Sprintf("%s://%s", parsedUrl.Scheme, parsedUrl.Host) publicKeyStr := parsedUrl.User.String() pkBytes, err := hex.DecodeString(publicKeyStr) From f5d04a929ff00ab6870c9f5824111eef2c5eeeb8 Mon Sep 17 00:00:00 2001 From: KonradStaniec Date: Fri, 24 May 2024 11:23:07 +0200 Subject: [PATCH 3/3] Add docs (#31) * Add docs --- README.md | 85 ++++++++++++++++++++++++++++++++++++++++++++++-- cmd/root.go | 2 +- docs/commands.md | 43 ++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ad614f5..72d9c6e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,84 @@ -# CLI-TOOLS +# CLI-Tools -Set of CLI tools to run as Batch jobs on phase-1 main net +Set of CLI tool which are used for different purposes: +- processing unbonding requests +- building test staking/unbonding/withdraw phase-1 Bitcoin transactions +- building Bitcon transactions timestamping files + +See [deployment guide](/docs/commands.md) to review all available commands. + +### Installation + +#### Prerequisites + +This project requires Go version 1.21 or later. + +Install Go by following the instructions on the official Go installation [guide](https://go.dev/doc/install). + +#### Download the code + +To get started, clone the repository to your local machine from GitHub; please +use the version according to the phase-1 system guidelines -- +you can find all versions in the official +[releases](https://github.com/babylonchain/cli-tools/releases) page. + +```shell +git clone https://github.com/babylonchain/cli-tools.git +cd cli-tools +git checkout +``` + +#### Build and install the binary + +At the top-level directory of the project + +```shell +make install +``` + +The above command will build and install the `cli-tools` binary to +`$GOPATH/bin`. + +If your shell cannot find the installed binaries, make sure `$GOPATH/bin` is in +the `$PATH` of your shell. The following updates to `$PATH` can be performed to +this direction: + +```shell +export PATH=$HOME/go/bin:$PATH +echo 'export PATH=$HOME/go/bin:$PATH' >> ~/.profile +``` + +### Usage + +To see all available commands: + +```shell +cli-tools --help +``` + +Example output: + +```shell +Set of cli tools used in phase-1 + +Usage: + cli-tools [command] + +Available Commands: + completion Generate the autocompletion script for the specified shell + create-phase1-staking-tx create phase1 staking tx + create-phase1-unbonding-request create phase1 unbonding tx + create-phase1-withdaw-request create phase1 withdraw tx + create-timestamp-transaction Creates a timestamp btc transaction by hashing the file input. + dump-cfg dumps default confiiguration file + help Help about any command + process-failed-transactions tries to re-send unbonding transactions that failed to be sent to the network + run-unbonding-pipeline runs unbonding pipeline + +Flags: + --config string path to the directory with configuration file + -h, --help help for cli-tools + --params string path to the global params file + +Use "cli-tools [command] --help" for more information about a command. +``` diff --git a/cmd/root.go b/cmd/root.go index 727a16e..ea932be 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,7 +17,7 @@ var ( rootCmd = &cobra.Command{ Use: "cli-tools", - Short: "Set of cli tools to run batch jobs on phase-1 mainnet", + Short: "Set of cli tools used in phase-1", } // C:\Users\\AppData\Local\tools on Windows diff --git a/docs/commands.md b/docs/commands.md index 90d56b4..8d84ef0 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -138,3 +138,46 @@ $ bitcoin-cli -rpcwallet=timestamp-w gettransaction 25b65b31c6f4d2f46ebeb5fa4c9a } } ``` + +## BTC Transaction creation commands + +The following set of commands are used to create phase-1 compatible transactions +with the goal to ease up testing of the phase-1 system: +- `create-phase1-staking-tx` +- `create-phase1-unbonding-request` +- `create-phase1-withdaw-request` + +Disclaimer: Those commands should only be used for testing purposes and should not be +used with real BTC. + +## Dump config command + +Some of the commands require a config file to work properly. To generate a config +file the `dump-cfg` command can be used. + +```shell +cli-tools dump-cfg --config "./config.toml" +``` + +will generate a `config.toml` file in the same directory as the one +the `cli-tools` program binary resides in. + + +## Unbonding processing commands + +There are two commands responsible for processing unbonding requests: +- `run-unbonding-pipeline` +- `process-failed-transactions` + +Both of those commands require: +- config file path +- global parameters paths + +Example: + +```shell +cli-tools run-unbonding-pipeline --config "./config/config.toml" --params "./config/global-params.json" +``` + +For these commands to work, they must have access to the data source (mongo-db) containing +unbonding transactions already signed by staker and validated by some other process.