synctx
=================

Generated by [oclif](https://oclif.io)

Sync pending transactions from source to target node. Supports both Besu and Geth clients.

#### How Does It Work

The tool grabs pending transactions in the txpool for both the source and target node. Then, it compares the pending
transactions in both pools to determine which transactions we need to sync, as some transactions are already persisted
in the target node. The comparison is performed on the transaction hash. To perform the actual sync, the tool will batch
send transactions in groups of 10 (controlled by the --concurrency flag) to help with performance. The batch
transactions are sent asynchronously, but the controlling concurrent loop is synchronous.

# Install

1. Download and extract the zip on the release page. Each release contains multiple distributions. Find the distribution
   that works for your machine type.
2. When unzipping the release contents, a `synctx` folder is extracted, which contains the command line entrypoint
   inside
   the `bin` directory.
3. Move the extracted content to a path of your choosing, such as `/usr/local/synctx`
4. Edit your `PATH` variable to include synctx, `PATH="$PATH:/usr/local/synctx/bin` make sure to persist this change in
   your `.profile` | `.bash_profile` | `.zsh_profile`
5. Run `synctx --help` to confirm that the installation has completed successfully.

#### Docker

As an alternative to downloading the distribution, you can also run the tool via Docker. This builds the distribution
inside the image and exposes `synctx` as an entrypoint. From there, you may run `docker run synctx:latest --help`

Building the image can be done with `docker build . -t synctx:latest`

# How To Sync

To sync transactions between nodes, first make sure you have port-forwarded to the necessary Kubernetes services or
pods.
`kubectl port-forward {service|pod}/{service_name|pod_name}`

[How to port-forward in K8s](https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/)

Then provide the source and target nodes, where the source node is the node pending transactions will be synced from.
`synctx -s http://localhost:8500 -t http://localhost:8501`

To perform a dry run and verify if the current nodes are targeted, include the `--dry-run` flag.
`synctx -s http://localhost:8500 -t http://localhost:8501 --dry-run`

# Ethstats

[Mainnet](https://ethstats.linea.build/)
[Testnet](https://ethstats.sepolia.linea.build/)

# Local Development

It is highly recommended to read the official docs of `oclif` as it is used to generate the CLI.

To run the tool against your local changes (without constantly building it), run `./bin/dev.js`

# Commands

## `synctx`

```
USAGE
  $ synctx -s <value> -t <value> [--dry-run] [--local] [-c <value>]

CONFIG FLAGS
  -c, --concurrency=<value>  [default: 10] number of concurrent batch requests
  --dry-run                  enable dry run
  --local                    enable local run, provide only forwarded ports

NODE FLAGS
  -s, --source=<value>  (required) source node to sync from
  -t, --target=<value>  (required) target node to sync to

EXAMPLES
  $ synctx  --source=8500 --target=8501 --local

  $ synctx  --source=http://geth-archive-1:8545 --target=http://geth-validator-1:8545 --concurrency=10
```

_See code: [dist/index.ts](https://github.com/scripts/synctx/blob/v0.0.0/dist/index.ts)_

## `synctx help [COMMANDS]`

Display help for synctx.

```
USAGE
  $ synctx help [COMMANDS] [-n]

ARGUMENTS
  COMMANDS  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for synctx.
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.20/src/commands/help.ts)_

<!-- commandsstop -->
