Skip to content

Commit

Permalink
refactor: add extra devtool input arguments
Browse files Browse the repository at this point in the history
This commit adds extra devtool input arguments allowing developers to
spin up multiple Os on the ETH devnet.
  • Loading branch information
rickstaa committed Apr 20, 2024
1 parent 9305333 commit 25194e3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 17 deletions.
17 changes: 8 additions & 9 deletions cmd/devtool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@

An on-chain workflow testing tool that supports the following:

- Automatically submitting the necessary setup transactions for each node type
- Generating a Bash script with default CLI flags to start each node type
- Automatically submitting the necessary setup transactions for each node type
- Generating a Bash script with default CLI flags to start each node type

## Prerequisites

## Step 1: Set up a private ETH network with Livepeer protocol deployed
### Step 1: Set up a private ETH network with Livepeer protocol deployed

```
```bash
docker pull livepeer/geth-with-livepeer-protocol:confluence
docker run -p 8545:8545 -p 8546:8546 --name geth-with-livepeer-protocol livepeer/geth-with-livepeer-protocol:confluence
```


## Step 2: Set up a broadcaster
### Step 2: Set up a broadcaster

`go run cmd/devtool/devtool.go setup broadcaster`

This command will submit the setup transactions for a broadcaster and generate the Bash script
`run_broadcaster_<ETH_ACCOUNT>.sh` which can be used to start a broadcaster node.

## Step 3: Set up a orchestrator/transcoder
### Step 3: Set up a orchestrator/transcoder

`go run cmd/devtool/devtool.go setup transcoder`

This command will submit the setup transactions for an orchestrator/transcoder and generate the Bash scripts:

* `run_orchestrator_with_transcoder_<ETH_ACCOUNT>.sh` which can be used to start an orchestrator node that contains a transcoder (combined OT)
* `run_orchestrator_standalone_<ETH_ACCOUNT>.sh` and `run_transcoder_<ETH_ACCOUNT>.sh` which can be used to start separate orchestrator and transcoder nodes (split O/T)
- `run_orchestrator_with_transcoder_<ETH_ACCOUNT>.sh` which can be used to start an orchestrator node that contains a transcoder (combined OT)
- `run_orchestrator_standalone_<ETH_ACCOUNT>.sh` and `run_transcoder_<ETH_ACCOUNT>.sh` which can be used to start separate orchestrator and transcoder nodes (split O/T)
38 changes: 36 additions & 2 deletions cmd/devtool/devtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ package main
import (
"flag"
"fmt"
"github.com/golang/glog"
"github.com/livepeer/go-livepeer/cmd/devtool/devtool"
"io"
"io/ioutil"
"math/big"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/golang/glog"
"github.com/livepeer/go-livepeer/cmd/devtool/devtool"
)

var (
Expand All @@ -27,6 +29,10 @@ func main() {
miningAccountFlag := flag.String("miningaccount", "", "Override geth mining account (usually not needed)")
ethControllerFlag := flag.String("controller", "", "Override controller address (usually not needed)")
svcHost := flag.String("svchost", "127.0.0.1", "default service host")
cliPortStr := flag.String("cliport", "", "CLI port")
mediaPortStr := flag.String("mediaport", "", "Media port")
rtmpPortStr := flag.String("rtmpport", "", "RTMP port")
bondAmount := flag.String("bond", "500", "Orchestrator bonded amount in LPT")

flag.Parse()

Expand All @@ -46,6 +52,34 @@ func main() {
serviceHost = *svcHost
cfg.ServiceURI = fmt.Sprintf("https://%s:", serviceHost)
}
if *cliPortStr != "" {
cliPortTmp, err := strconv.Atoi(*cliPortStr)
if err != nil {
glog.Errorf("Invalid cli port %v", *cliPortStr)
}
cliPort = cliPortTmp
}
if *mediaPortStr != "" {
mediaPortTmp, err := strconv.Atoi(*mediaPortStr)
if err != nil {
glog.Errorf("Invalid media port %v", *mediaPortStr)
}
mediaPort = mediaPortTmp
}
if *rtmpPortStr != "" {
rtmpPortTmp, err := strconv.Atoi(*rtmpPortStr)
if err != nil {
glog.Errorf("Invalid rtmp port %v", *rtmpPortStr)
}
rtmpPort = rtmpPortTmp
}
if *bondAmount != "" {
cfg.BondAmount = new(big.Int)
_, ok := cfg.BondAmount.SetString(*bondAmount, 10)
if !ok {
glog.Exitf("Invalid bond amount %v", *bondAmount)
}
}
args := flag.Args()
goodToGo := false
isBroadcaster := true
Expand Down
14 changes: 8 additions & 6 deletions cmd/devtool/devtool/devtool_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"math/big"
"os"
"strings"
"time"

"github.com/ethereum/go-ethereum/accounts/keystore"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/console"
Expand All @@ -13,11 +19,6 @@ import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/golang/glog"
"github.com/livepeer/go-livepeer/eth"
"io/ioutil"
"math/big"
"os"
"strings"
"time"
)

const (
Expand All @@ -35,6 +36,7 @@ type DevtoolConfig struct {
Account string
KeystoreDir string
IsBroadcaster bool
BondAmount *big.Int
}

func NewDevtoolConfig() DevtoolConfig {
Expand Down Expand Up @@ -300,7 +302,7 @@ func (d *Devtool) RegisterOrchestrator(cfg DevtoolConfig) error {
// curl -d "blockRewardCut=10&feeShare=5&amount=500" --data-urlencode "serviceURI=https://$transcoderServiceAddr" \
// -H "Content-Type: application/x-www-form-urlencoded" \
// -X "POST" http://localhost:$transcoderCliPort/activateTranscoder\
var amount *big.Int = big.NewInt(int64(500))
var amount = cfg.BondAmount
glog.Infof("Bonding %v to %s", amount, cfg.Account)

tx, err := d.Client.Bond(amount, ethcommon.HexToAddress(cfg.Account))
Expand Down

0 comments on commit 25194e3

Please sign in to comment.