Skip to content

Commit

Permalink
Merge pull request #1278 from statechannels/chainpk
Browse files Browse the repository at this point in the history
Minor improvemenets to `pk` and `chainpk` test config
  • Loading branch information
geoknee authored May 12, 2023
2 parents d6fd7d0 + fd3e066 commit f6cab5a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
20 changes: 13 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ func main() {
altsrc.NewStringFlag(&cli.StringFlag{
Name: PK,
Usage: "Specifies the private key for the client.",
Value: "2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d",
DefaultText: "Alice's private key",
Category: "Keys:",
Destination: &pkString,
}),
Expand All @@ -80,8 +78,6 @@ func main() {
altsrc.NewStringFlag(&cli.StringFlag{
Name: CHAIN_PK,
Usage: "Specifies the private key to use when interacting with the chain.",
Value: "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
DefaultText: "A hardhat / annvil default funded account",
Category: "Keys:",
Destination: &chainPk,
}),
Expand Down Expand Up @@ -121,21 +117,29 @@ func main() {
Flags: flags,
Before: altsrc.InitInputSourceWithContext(flags, altsrc.NewTomlSourceFromFlagFunc(CONFIG)),
Action: func(cCtx *cli.Context) error {
if pkString == "" {
panic("pk must be set")
}
if chainPk == "" {
panic("chainpk must be set")
}
pk := common.Hex2Bytes(pkString)
me := crypto.GetAddressFromSecretKeyBytes(pk)

logDestination := os.Stdout

var ourStore store.Store
fmt.Println("Initialising store...")

if useDurableStore {
fmt.Println("Initialising durable store...")
dataFolder := fmt.Sprintf("./data/nitro-service/%s", me.String())
ourStore = store.NewDurableStore(pk, dataFolder, buntdb.Config{})
} else {
fmt.Println("Initialising mem store...")
ourStore = store.NewMemStore(pk)
}

fmt.Println("Connecting to chain...")
fmt.Println("Connecting to chain " + chainUrl + " with chain id " + fmt.Sprint(chainId) + "...")
ethClient, txSubmitter, err := chainutils.ConnectToChain(context.Background(), chainUrl, chainId, common.Hex2Bytes(chainPk))
if err != nil {
panic(err)
Expand All @@ -151,7 +155,7 @@ func main() {
panic(err)
}

fmt.Println("Initializing message service...")
fmt.Println("Initializing message service on port " + fmt.Sprint(msgPort) + "...")
messageservice := p2pms.NewMessageService("127.0.0.1", msgPort, *ourStore.GetAddress(), pk, logDestination)
node := client.New(
messageservice,
Expand All @@ -164,8 +168,10 @@ func main() {
var transport transport.Responder

if useNats {
fmt.Println("Initializing NATS RPC transport...")
transport, err = nats.NewNatsTransportAsServer(rpcPort)
} else {
fmt.Println("Initializing websocketNATS RPC transport...")
transport, err = ws.NewWebSocketTransportAsServer(fmt.Sprint(rpcPort))
}
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions scripts/start-rpc-servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const (
gray color = "[90m"
)

const FUNDED_TEST_PK = "59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
const FUNDED_TEST_PK = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

func main() {
running := []*exec.Cmd{}
Expand Down Expand Up @@ -131,7 +131,7 @@ func setupRPCServer(p participant, c color, na types.Address) (*exec.Cmd, error)

cmd := exec.Command("go", args...)
cmd.Stdout = newColorWriter(c, os.Stdout)
cmd.Stderr = os.Stderr
cmd.Stderr = newColorWriter(c, os.Stderr)
err := cmd.Start()
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion scripts/test-configs/alice.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ usedurablestore = true
msgport = 3005
rpcport = 4005

pk = "2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d"
pk = "2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d"
chainpk = "59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
3 changes: 2 additions & 1 deletion scripts/test-configs/bob.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ usedurablestore = true
msgport = 3007
rpcport = 4007

pk = "0279651921cd800ac560c21ceea27aab0107b67daf436cdd25ce84cad30159b4"
pk = "0279651921cd800ac560c21ceea27aab0107b67daf436cdd25ce84cad30159b4"
chainpk = "5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"
3 changes: 2 additions & 1 deletion scripts/test-configs/irene.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ usedurablestore = true
msgport = 3006
rpcport = 4006

pk = "febb3b74b0b52d0976f6571d555f4ac8b91c308dfa25c7b58d1e6a7c3f50c781"
pk = "febb3b74b0b52d0976f6571d555f4ac8b91c308dfa25c7b58d1e6a7c3f50c781"
chainpk = "7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6"

0 comments on commit f6cab5a

Please sign in to comment.