Skip to content

Commit

Permalink
Merge pull request #15 from pellartech/multiple-improvements
Browse files Browse the repository at this point in the history
Multiple improvements
  • Loading branch information
Sledro authored Jan 31, 2024
2 parents 3147261 + d2bf85f commit b188fb6
Show file tree
Hide file tree
Showing 12 changed files with 275 additions and 230 deletions.
85 changes: 79 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,90 @@

![LightLink Hummingbird preview screenshot](<preview.png>)

Hummingbird is a command line tool for interacting with the LightLink protocol.
Hummingbird is a light client for interacting with the [LightLink Protocol](https://lightlink.io).

It is designed to work in unison with the [lightlink-hummingbird-contracts](https://github.com/pellartech/lightlink-hummingbird-contracts) repository.

## Commands
## Installation

### Prerequisites

- [Golang](https://go.dev/dl/) (v1.21.5 or higher) installed. Go version can be checked with `$ go version`

### Option 1: Install from source (Linux / MacOS)

```bash
git clone [email protected]:pellartech/lightlink-hummingbird.git
cd lightlink-hummingbird
git checkout -b v0.0.1
make
```

### Option 2: Install from binary (Windows / Linux / MacOS)

Download the latest release from [here](https://github.com/pellartech/lightlink-hummingbird/releases)

### Configuration

Hummingbird requires a configuration file to run. A sample configuration file is provided in the repository [here](config.example.json). Copy this file and rename it to `config.json`. Then fill in the required fields.

```bash
cp config.example.json config.json
```

A single environment variable ETH_KEY is required to be set. This is the private key of the Ethereum account that will be used to sign transactions. This account must have sufficient funds to pay for gas fees.

```bash
export ETH_KEY=0x...
```



**Note**: configuration file `config.json` path can be specified with the `--config-path` flag. If not specified, the default path is `./config.json`

```
{
"storePath": "./storage", // Path to the local storage
"celestia": {
"token": "abcd", // Celestia token
"endpoint": "", // Celestia rpc endpoint
"namespace": "", // Celestia namespace to identify the blobs
"tendermint_rpc": "", // Tendermint rpc endpoint
"grpc": "", // Celestia grpc endpoint
"gasPrice": 0.01 // Gas price to use when submitting new headers to Celestia
},
"ethereum": {
"httpEndpoint": "", // Ethereum http rpc endpoint
"wsEndpoint": "", // Ethereum websocket rpc endpoint
"canonicalStateChain": "", // Canonical state chain contract address
"daOracle": "", // Data availability oracle contract address
"challenge": "", // Challenge contract address
"gasPriceIncreasePercent": 100 // Increase gas price manually when submitting new headers to L1
},
"lightlink": {
"endpoint": "", // LightLink rpc endpoint
"delay": 100 // Delay in ms between each block query
},
"rollup": {
"bundleSize": 200, // Number of headers to include in each bundle
"l1pollDelay": 90000, // (90sec) Delay in ms between each L1 block query
"l2pollDelay": 30000, // (30sec) Delay in ms between each L2 block query
"storeCelestiaPointers": true, // Store celestia pointers in the local storage
"storeHeaders": true // Store headers in the local storage
},
"defender": {
"workerDelay": 60000 // (60sec) Delay in ms between scanning for historical challenges to defend
}
}
```

## Usage

```bash
hb rollup info # Get the current rollup state
hb rollup next # Generate the next rollup block
hb rollup start # Start the rollup loop to generate and submit bundles
hb challenge challenge-da <block_number> # Challenge data availability
hb rollup next # [Publisher Only] Generate the next rollup block
hb rollup start # [Publisher Only] Start the rollup loop to generate and submit bundles
hb challenger challenge-da <block_number> # Challenge data availability
hb defender defend-da <block_hash> # Defend data availability
hd defender info-da <block_hash> # Provides info on an existing challenge
hb defender prove-da <block_hash> # Prove data availability
Expand All @@ -34,4 +107,4 @@ see `hb --help` for more information

<p align="center">
<img src="humming.png" style="size:50%" alt="HummingBird">
</p>
</p>
1 change: 0 additions & 1 deletion cli/cmd/defender_defendda.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ var DefenderDefendDaCmd = &cobra.Command{

d := defender.NewDefender(n, &defender.Opts{
Logger: logger.With("ctx", "Defender"),
DryRun: dryRun,
})

// get block hash and tx hash from args/flags
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/defender_proveda.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var DefenderProveDaCmd = &cobra.Command{
})

blockHash := common.HexToHash(args[0])
proof, err := d.ProveDA(blockHash)
proof, err := d.GetDAProof(blockHash)
if err != nil {
logger.Error("Failed to prove data availability", "err", err)
panic(err)
Expand Down
10 changes: 6 additions & 4 deletions cli/cmd/defender_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ var DefenderStartCmd = &cobra.Command{
Logger: logger.With("ctx", "Defender"),
WorkerDelay: time.Duration(cfg.Defender.WorkerDelay) * time.Millisecond,
})
for {
err = d.Start()
if err != nil {
logger.Error("Defender.Start failed", "err", err, "retry_in", "5s")
}

err = d.Start()
if err != nil {
logger.Error("Defender.Start failed", "err", err, "retry_in", "5s")
time.Sleep(5 * time.Second)
}

},
}
6 changes: 6 additions & 0 deletions cli/cmd/rollup_next.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ var RollupNextCmd = &cobra.Command{
n, err := node.NewFromConfig(cfg, logger, ethKey)
utils.NoErr(err)

// Can only run rollup node if the eth key is a publisher
if !n.IsPublisher(ethKey) {
logger.Warn("ETH_KEY is not a publisher, cannot run rollup next command")
return
}

r := rollup.NewRollup(n, &rollup.Opts{
L1PollDelay: time.Duration(cfg.Rollup.L1PollDelay) * time.Millisecond,
L2PollDelay: time.Duration(cfg.Rollup.L2PollDelay) * time.Millisecond,
Expand Down
6 changes: 6 additions & 0 deletions cli/cmd/rollup_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ var RollupStartCmd = &cobra.Command{
n, err := node.NewFromConfig(cfg, logger, ethKey)
utils.NoErr(err)

// Can only run rollup node if the eth key is a publisher
if !n.IsPublisher(ethKey) {
logger.Warn("ETH_KEY is not a publisher, cannot run rollup start command")
return
}

r := rollup.NewRollup(n, &rollup.Opts{
L1PollDelay: time.Duration(cfg.Rollup.L1PollDelay) * time.Millisecond,
L2PollDelay: time.Duration(cfg.Rollup.L2PollDelay) * time.Millisecond,
Expand Down
Loading

0 comments on commit b188fb6

Please sign in to comment.