Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ai): add extra devtool input arguments #3026

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading