Skip to content

Commit

Permalink
remove invalid code
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-malene committed May 14, 2024
1 parent 877da93 commit ff770f7
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 169 deletions.
2 changes: 1 addition & 1 deletion integration/networktest/env/network_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func LongRunningLocalNetwork(l1WSURL string) networktest.Environment {
[]string{"ws://127.0.0.1:26901"},
genesis.TestnetPrefundedPK,
l1WSURL,
l1WSURL,
"",
)
return newTestnetEnv(connector)
}
Expand Down
1 change: 0 additions & 1 deletion integration/networktest/env/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func newTestnetConnectorWithFaucetAccount(seqRPCAddr string, validatorRPCAddress
faucetWallet: userwallet.NewUserWallet(wal, validatorRPCAddressses[0], testlog.Logger()),
l1RPCURL: l1RPCAddress,
tenGatewayURL: tenGatewayURL,
tenGatewayWSURL: "ws://127.0.0.1:3001",
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ import (
"github.com/ten-protocol/go-ten/integration/networktest"
"github.com/ten-protocol/go-ten/integration/networktest/actions"
"github.com/ten-protocol/go-ten/integration/networktest/env"
"github.com/ten-protocol/go-ten/integration/simulation/devnetwork"
)

func TestGatewayNewHeadsSubscription(t *testing.T) {
// networktest.TestOnlyRunsInIDE(t)
networktest.TestOnlyRunsInIDE(t)
networktest.Run(
"gateway-new-heads-subscription",
t,
env.LongRunningLocalNetwork("http://127.0.0.1:3000"),
env.LocalDevNetwork(devnetwork.WithGateway()),
actions.Series(
// user not technically needed, but we need a gateway address to use
&actions.CreateTestUser{UserID: 0, UseGateway: true},
actions.SetContextValue(actions.KeyNumberOfTestUsers, 1),

// Record new heads for specified duration, verify that the subscription is working
actions.RecordNewHeadsSubscription(500*time.Second),
actions.RecordNewHeadsSubscription(20*time.Second),
),
)
}
306 changes: 154 additions & 152 deletions testnet/launcher/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import (
"github.com/ten-protocol/go-ten/go/obsclient"
"github.com/ten-protocol/go-ten/go/rpc"
"github.com/ten-protocol/go-ten/testnet/launcher/eth2network"
"github.com/ten-protocol/go-ten/testnet/launcher/faucet"
"github.com/ten-protocol/go-ten/testnet/launcher/gateway"

l1cd "github.com/ten-protocol/go-ten/testnet/launcher/l1contractdeployer"
l2cd "github.com/ten-protocol/go-ten/testnet/launcher/l2contractdeployer"
)

type Testnet struct {
Expand All @@ -28,158 +30,158 @@ func (t *Testnet) Start() error {
litter.Config.HidePrivateFields = false
fmt.Printf("Starting Testnet with config: \n%s\n\n", litter.Sdump(*t.cfg))

//err := startEth2Network()
//if err != nil {
// return fmt.Errorf("unable to start eth2network - %w", err)
//}

//networkConfig, err := t.deployL1Contracts()
//if err != nil {
// return fmt.Errorf("unable to deploy l1 contracts - %w", err)
//}

//sequencerNodeConfig := node.NewNodeConfig(
// node.WithNodeName("sequencer"),
// node.WithNodeType("sequencer"),
// node.WithGenesis(true),
// node.WithSGXEnabled(t.cfg.isSGXEnabled),
// node.WithEnclaveImage(t.cfg.sequencerEnclaveDockerImage),
// node.WithEnclaveDebug(t.cfg.sequencerEnclaveDebug),
// node.WithHostImage("testnetobscuronet.azurecr.io/obscuronet/host:latest"),
// node.WithL1WebsocketURL("ws://eth2network:9000"),
// node.WithEnclaveWSPort(11000),
// node.WithHostHTTPPort(80),
// node.WithHostWSPort(81),
// node.WithHostP2PPort(15000),
// node.WithHostPublicP2PAddr("sequencer-host:15000"),
// node.WithPrivateKey("8ead642ca80dadb0f346a66cd6aa13e08a8ac7b5c6f7578d4bac96f5db01ac99"),
// node.WithHostID("0x0654D8B60033144D567f25bF41baC1FB0D60F23B"),
// node.WithSequencerP2PAddr("sequencer-host:15000"),
// node.WithManagementContractAddress(networkConfig.ManagementContractAddress),
// node.WithMessageBusContractAddress(networkConfig.MessageBusAddress),
// node.WithL1Start(networkConfig.L1StartHash),
// node.WithInMemoryHostDB(true),
// node.WithDebugNamespaceEnabled(true),
// node.WithLogLevel(t.cfg.logLevel),
// node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-4gb:v0.3.2"), // default edgeless db value
//)
//if !t.cfg.isSGXEnabled {
// sequencerNodeConfig.UpdateNodeConfig(node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-1gb:v0.3.2"))
//}
//
//sequencerNode := node.NewDockerNode(sequencerNodeConfig)
//
//err = sequencerNode.Start()
//if err != nil {
// return fmt.Errorf("unable to start the obscuro node - %w", err)
//}
//fmt.Println("Obscuro node was successfully started...")
//
//// wait until the node is healthy
//err = waitForHealthyNode(80)
//if err != nil {
// return fmt.Errorf("sequencer obscuro node not healthy - %w", err)
//}
//
//validatorNodeConfig := node.NewNodeConfig(
// node.WithNodeName("validator"),
// node.WithNodeType("validator"),
// node.WithGenesis(false),
// node.WithSGXEnabled(t.cfg.isSGXEnabled),
// node.WithEnclaveImage(t.cfg.validatorEnclaveDockerImage),
// node.WithEnclaveDebug(t.cfg.validatorEnclaveDebug),
// node.WithHostImage("testnetobscuronet.azurecr.io/obscuronet/host:latest"),
// node.WithL1WebsocketURL("ws://eth2network:9000"),
// node.WithEnclaveWSPort(11010),
// node.WithHostHTTPPort(13010),
// node.WithHostWSPort(13011),
// node.WithHostP2PPort(15010),
// node.WithHostPublicP2PAddr("validator-host:15010"),
// node.WithPrivateKey("ebca545772d6438bbbe1a16afbed455733eccf96157b52384f1722ea65ccfa89"),
// node.WithHostID("0x2f7fCaA34b38871560DaAD6Db4596860744e1e8A"),
// node.WithSequencerP2PAddr("sequencer-host:15000"),
// node.WithManagementContractAddress(networkConfig.ManagementContractAddress),
// node.WithMessageBusContractAddress(networkConfig.MessageBusAddress),
// node.WithL1Start(networkConfig.L1StartHash),
// node.WithInMemoryHostDB(true),
// node.WithDebugNamespaceEnabled(true),
// node.WithLogLevel(t.cfg.logLevel),
// node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-4gb:v0.3.2"), // default edgeless db value
//)
//
//if !t.cfg.isSGXEnabled {
// validatorNodeConfig.UpdateNodeConfig(node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-1gb:v0.3.2"))
//}
//
//validatorNode := node.NewDockerNode(validatorNodeConfig)
//
//err = validatorNode.Start()
//if err != nil {
// return fmt.Errorf("unable to start the obscuro node - %w", err)
//}
//fmt.Println("Obscuro node was successfully started...")
//
//// wait until the node it healthy
//err = waitForHealthyNode(13010)
//if err != nil {
// return fmt.Errorf("validator obscuro node not healthy - %w", err)
//}
//
//l2ContractDeployer, err := l2cd.NewDockerContractDeployer(
// l2cd.NewContractDeployerConfig(
// l2cd.WithL1HTTPURL("http://eth2network:8025"),
// l2cd.WithL2Host("sequencer-host"),
// l2cd.WithL2WSPort(81),
// l2cd.WithL1PrivateKey("f52e5418e349dccdda29b6ac8b0abe6576bb7713886aa85abea6181ba731f9bb"),
// l2cd.WithMessageBusContractAddress("0xDaBD89EEA0f08B602Ec509c3C608Cb8ED095249C"),
// l2cd.WithManagementContractAddress("0x51D43a3Ca257584E770B6188232b199E76B022A2"),
// l2cd.WithL2PrivateKey("8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b"),
// l2cd.WithHocPKString("6e384a07a01263518a09a5424c7b6bbfc3604ba7d93f47e3a455cbdd7f9f0682"),
// l2cd.WithPocPKString("4bfe14725e685901c062ccd4e220c61cf9c189897b6c78bd18d7f51291b2b8f8"),
// l2cd.WithDockerImage(t.cfg.contractDeployerDockerImage),
// l2cd.WithDebugEnabled(t.cfg.contractDeployerDebug),
// l2cd.WithFaucetFunds("10000"),
// ),
//)
//if err != nil {
// return fmt.Errorf("unable to configure the l2 contract deployer - %w", err)
//}
//
//err = l2ContractDeployer.Start()
//if err != nil {
// return fmt.Errorf("unable to start the l2 contract deployer - %w", err)
//}
//
//err = l2ContractDeployer.WaitForFinish()
//if err != nil {
// return fmt.Errorf("unexpected error waiting for l2 contract deployer { ID = %s } to finish - %w", l2ContractDeployer.GetID(), err)
//}
//fmt.Println("L2 Contracts were successfully deployed...")
//
//faucetPort := 99
//faucetInst, err := faucet.NewDockerFaucet(
// faucet.NewFaucetConfig(
// faucet.WithFaucetPort(faucetPort),
// faucet.WithTenNodePort(13010),
// faucet.WithTenNodeHost("validator-host"),
// faucet.WithFaucetPrivKey("0x8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b"),
// faucet.WithDockerImage("testnetobscuronet.azurecr.io/obscuronet/faucet:latest"),
// ),
//)
//if err != nil {
// return fmt.Errorf("unable to instantiate faucet - %w", err)
//}
//
//if err = faucetInst.Start(); err != nil {
// return fmt.Errorf("unable to start faucet - %w", err)
//}
//
//if err = faucetInst.IsReady(); err != nil {
// return fmt.Errorf("unable to wait for faucet to be ready - %w", err)
//}
//
//fmt.Printf("Faucet ready to be accessed at http://127.0.0.1:%d/ ...\n", faucetPort)
//fmt.Printf("Fund your account with `curl --request POST 'http://127.0.0.1:%d/fund/eth' --header 'Content-Type: application/json' --data-raw '{ \"address\":\"0x0....\" } `\n", faucetPort)
err := startEth2Network()
if err != nil {
return fmt.Errorf("unable to start eth2network - %w", err)
}

networkConfig, err := t.deployL1Contracts()
if err != nil {
return fmt.Errorf("unable to deploy l1 contracts - %w", err)
}

sequencerNodeConfig := node.NewNodeConfig(
node.WithNodeName("sequencer"),
node.WithNodeType("sequencer"),
node.WithGenesis(true),
node.WithSGXEnabled(t.cfg.isSGXEnabled),
node.WithEnclaveImage(t.cfg.sequencerEnclaveDockerImage),
node.WithEnclaveDebug(t.cfg.sequencerEnclaveDebug),
node.WithHostImage("testnetobscuronet.azurecr.io/obscuronet/host:latest"),
node.WithL1WebsocketURL("ws://eth2network:9000"),
node.WithEnclaveWSPort(11000),
node.WithHostHTTPPort(80),
node.WithHostWSPort(81),
node.WithHostP2PPort(15000),
node.WithHostPublicP2PAddr("sequencer-host:15000"),
node.WithPrivateKey("8ead642ca80dadb0f346a66cd6aa13e08a8ac7b5c6f7578d4bac96f5db01ac99"),
node.WithHostID("0x0654D8B60033144D567f25bF41baC1FB0D60F23B"),
node.WithSequencerP2PAddr("sequencer-host:15000"),
node.WithManagementContractAddress(networkConfig.ManagementContractAddress),
node.WithMessageBusContractAddress(networkConfig.MessageBusAddress),
node.WithL1Start(networkConfig.L1StartHash),
node.WithInMemoryHostDB(true),
node.WithDebugNamespaceEnabled(true),
node.WithLogLevel(t.cfg.logLevel),
node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-4gb:v0.3.2"), // default edgeless db value
)
if !t.cfg.isSGXEnabled {
sequencerNodeConfig.UpdateNodeConfig(node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-1gb:v0.3.2"))
}

sequencerNode := node.NewDockerNode(sequencerNodeConfig)

err = sequencerNode.Start()
if err != nil {
return fmt.Errorf("unable to start the obscuro node - %w", err)
}
fmt.Println("Obscuro node was successfully started...")

// wait until the node is healthy
err = waitForHealthyNode(80)
if err != nil {
return fmt.Errorf("sequencer obscuro node not healthy - %w", err)
}

validatorNodeConfig := node.NewNodeConfig(
node.WithNodeName("validator"),
node.WithNodeType("validator"),
node.WithGenesis(false),
node.WithSGXEnabled(t.cfg.isSGXEnabled),
node.WithEnclaveImage(t.cfg.validatorEnclaveDockerImage),
node.WithEnclaveDebug(t.cfg.validatorEnclaveDebug),
node.WithHostImage("testnetobscuronet.azurecr.io/obscuronet/host:latest"),
node.WithL1WebsocketURL("ws://eth2network:9000"),
node.WithEnclaveWSPort(11010),
node.WithHostHTTPPort(13010),
node.WithHostWSPort(13011),
node.WithHostP2PPort(15010),
node.WithHostPublicP2PAddr("validator-host:15010"),
node.WithPrivateKey("ebca545772d6438bbbe1a16afbed455733eccf96157b52384f1722ea65ccfa89"),
node.WithHostID("0x2f7fCaA34b38871560DaAD6Db4596860744e1e8A"),
node.WithSequencerP2PAddr("sequencer-host:15000"),
node.WithManagementContractAddress(networkConfig.ManagementContractAddress),
node.WithMessageBusContractAddress(networkConfig.MessageBusAddress),
node.WithL1Start(networkConfig.L1StartHash),
node.WithInMemoryHostDB(true),
node.WithDebugNamespaceEnabled(true),
node.WithLogLevel(t.cfg.logLevel),
node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-4gb:v0.3.2"), // default edgeless db value
)

if !t.cfg.isSGXEnabled {
validatorNodeConfig.UpdateNodeConfig(node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-1gb:v0.3.2"))
}

validatorNode := node.NewDockerNode(validatorNodeConfig)

err = validatorNode.Start()
if err != nil {
return fmt.Errorf("unable to start the obscuro node - %w", err)
}
fmt.Println("Obscuro node was successfully started...")

// wait until the node it healthy
err = waitForHealthyNode(13010)
if err != nil {
return fmt.Errorf("validator obscuro node not healthy - %w", err)
}

l2ContractDeployer, err := l2cd.NewDockerContractDeployer(
l2cd.NewContractDeployerConfig(
l2cd.WithL1HTTPURL("http://eth2network:8025"),
l2cd.WithL2Host("sequencer-host"),
l2cd.WithL2WSPort(81),
l2cd.WithL1PrivateKey("f52e5418e349dccdda29b6ac8b0abe6576bb7713886aa85abea6181ba731f9bb"),
l2cd.WithMessageBusContractAddress("0xDaBD89EEA0f08B602Ec509c3C608Cb8ED095249C"),
l2cd.WithManagementContractAddress("0x51D43a3Ca257584E770B6188232b199E76B022A2"),
l2cd.WithL2PrivateKey("8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b"),
l2cd.WithHocPKString("6e384a07a01263518a09a5424c7b6bbfc3604ba7d93f47e3a455cbdd7f9f0682"),
l2cd.WithPocPKString("4bfe14725e685901c062ccd4e220c61cf9c189897b6c78bd18d7f51291b2b8f8"),
l2cd.WithDockerImage(t.cfg.contractDeployerDockerImage),
l2cd.WithDebugEnabled(t.cfg.contractDeployerDebug),
l2cd.WithFaucetFunds("10000"),
),
)
if err != nil {
return fmt.Errorf("unable to configure the l2 contract deployer - %w", err)
}

err = l2ContractDeployer.Start()
if err != nil {
return fmt.Errorf("unable to start the l2 contract deployer - %w", err)
}

err = l2ContractDeployer.WaitForFinish()
if err != nil {
return fmt.Errorf("unexpected error waiting for l2 contract deployer { ID = %s } to finish - %w", l2ContractDeployer.GetID(), err)
}
fmt.Println("L2 Contracts were successfully deployed...")

faucetPort := 99
faucetInst, err := faucet.NewDockerFaucet(
faucet.NewFaucetConfig(
faucet.WithFaucetPort(faucetPort),
faucet.WithTenNodePort(13010),
faucet.WithTenNodeHost("validator-host"),
faucet.WithFaucetPrivKey("0x8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b"),
faucet.WithDockerImage("testnetobscuronet.azurecr.io/obscuronet/faucet:latest"),
),
)
if err != nil {
return fmt.Errorf("unable to instantiate faucet - %w", err)
}

if err = faucetInst.Start(); err != nil {
return fmt.Errorf("unable to start faucet - %w", err)
}

if err = faucetInst.IsReady(); err != nil {
return fmt.Errorf("unable to wait for faucet to be ready - %w", err)
}

fmt.Printf("Faucet ready to be accessed at http://127.0.0.1:%d/ ...\n", faucetPort)
fmt.Printf("Fund your account with `curl --request POST 'http://127.0.0.1:%d/fund/eth' --header 'Content-Type: application/json' --data-raw '{ \"address\":\"0x0....\" } `\n", faucetPort)

gatewayPort := 3000
gatewayInst, err := gateway.NewDockerGateway(
Expand Down
Loading

0 comments on commit ff770f7

Please sign in to comment.