diff --git a/integration/networktest/env/dev_network.go b/integration/networktest/env/dev_network.go index 988a00bb3b..7a6d8c981e 100644 --- a/integration/networktest/env/dev_network.go +++ b/integration/networktest/env/dev_network.go @@ -61,12 +61,8 @@ func awaitHealthStatus(rpcAddress string, timeout time.Duration) error { }, retry.NewTimeoutStrategy(timeout, 200*time.Millisecond)) } -func LocalDevNetwork(opts ...LocalNetworkOption) networktest.Environment { - config := &LocalNetworkConfig{} - for _, opt := range opts { - opt(config) - } - return &devNetworkEnv{inMemDevNetwork: devnetwork.DefaultDevNetwork(config.TenGatewayEnabled)} +func LocalDevNetwork(opts ...devnetwork.TenConfigOption) networktest.Environment { + return &devNetworkEnv{inMemDevNetwork: devnetwork.LocalDevNetwork(opts...)} } // LocalNetworkLiveL1 creates a local network that points to a live running L1. @@ -74,15 +70,3 @@ func LocalDevNetwork(opts ...LocalNetworkOption) networktest.Environment { func LocalNetworkLiveL1(seqWallet wallet.Wallet, validatorWallets []wallet.Wallet, l1RPCURLs []string) networktest.Environment { return &devNetworkEnv{inMemDevNetwork: devnetwork.LiveL1DevNetwork(seqWallet, validatorWallets, l1RPCURLs)} } - -type LocalNetworkConfig struct { - TenGatewayEnabled bool -} - -type LocalNetworkOption func(*LocalNetworkConfig) - -func WithTenGateway() LocalNetworkOption { - return func(c *LocalNetworkConfig) { - c.TenGatewayEnabled = true - } -} diff --git a/integration/networktest/tests/gateway/gateway_test.go b/integration/networktest/tests/gateway/gateway_test.go index 3034291644..eb8d5e9c13 100644 --- a/integration/networktest/tests/gateway/gateway_test.go +++ b/integration/networktest/tests/gateway/gateway_test.go @@ -7,6 +7,7 @@ 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" ) var _transferAmount = big.NewInt(100_000_000) @@ -23,7 +24,7 @@ func TestGatewayHappyPath(t *testing.T) { networktest.Run( "gateway-happy-path", t, - env.LocalDevNetwork(env.WithTenGateway()), + env.LocalDevNetwork(devnetwork.WithGateway()), actions.Series( &actions.CreateTestUser{UserID: 0, UseGateway: true}, &actions.CreateTestUser{UserID: 1, UseGateway: true}, diff --git a/integration/networktest/tests/helpful/smoke_test.go b/integration/networktest/tests/helpful/smoke_test.go index 44ce892d60..c14777e18f 100644 --- a/integration/networktest/tests/helpful/smoke_test.go +++ b/integration/networktest/tests/helpful/smoke_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/ten-protocol/go-ten/integration/networktest/actions" + "github.com/ten-protocol/go-ten/integration/simulation/devnetwork" "github.com/ten-protocol/go-ten/integration/networktest" "github.com/ten-protocol/go-ten/integration/networktest/env" @@ -19,7 +20,7 @@ func TestExecuteNativeFundsTransfer(t *testing.T) { networktest.Run( "native-funds-smoketest", t, - env.LocalDevNetwork(), + env.LocalDevNetwork(devnetwork.WithGateway()), actions.Series( &actions.CreateTestUser{UserID: 0}, &actions.CreateTestUser{UserID: 1}, diff --git a/integration/networktest/tests/helpful/spin_up_local_network_test.go b/integration/networktest/tests/helpful/spin_up_local_network_test.go index bb5cc7d4a8..5f671fb8b4 100644 --- a/integration/networktest/tests/helpful/spin_up_local_network_test.go +++ b/integration/networktest/tests/helpful/spin_up_local_network_test.go @@ -15,6 +15,7 @@ import ( "github.com/ten-protocol/go-ten/integration/common/testlog" "github.com/ten-protocol/go-ten/integration/networktest" "github.com/ten-protocol/go-ten/integration/networktest/env" + "github.com/ten-protocol/go-ten/integration/simulation/devnetwork" ) const ( @@ -31,7 +32,7 @@ const ( func TestRunLocalNetwork(t *testing.T) { networktest.TestOnlyRunsInIDE(t) networktest.EnsureTestLogsSetUp("local-geth-network") - networkConnector, cleanUp, err := env.LocalDevNetwork(env.WithTenGateway()).Prepare() + networkConnector, cleanUp, err := env.LocalDevNetwork(devnetwork.WithGateway()).Prepare() if err != nil { t.Fatal(err) } diff --git a/integration/networktest/tests/nodescenario/sequencer_multi_enclave_test.go b/integration/networktest/tests/nodescenario/sequencer_multi_enclave_test.go new file mode 100644 index 0000000000..ce3f6b11fe --- /dev/null +++ b/integration/networktest/tests/nodescenario/sequencer_multi_enclave_test.go @@ -0,0 +1 @@ +package nodescenario diff --git a/integration/simulation/devnetwork/config.go b/integration/simulation/devnetwork/config.go index 4e2c995a69..9f000f03c3 100644 --- a/integration/simulation/devnetwork/config.go +++ b/integration/simulation/devnetwork/config.go @@ -6,7 +6,6 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/ten-protocol/go-ten/go/enclave/genesis" "github.com/ten-protocol/go-ten/go/wallet" @@ -25,40 +24,67 @@ type L1Config struct { AvgBlockDuration time.Duration } -// ObscuroConfig tells the L2 node operators how to configure the nodes -type ObscuroConfig struct { +type TenConfigOption func(*TenConfig) // option pattern - typically used as overrides to DefaultTenConfig + +// TenConfig describes the L2 network configuration we want to spin up +type TenConfig struct { PortStart int InitNumValidators int BatchInterval time.Duration RollupInterval time.Duration - L1BlockTime time.Duration - SequencerID common.Address + NumNodes int + TenGatewayEnabled bool + NumSeqEnclaves int + + // these are typically set based on the L1 network and wallet setup provided + L1BlockTime time.Duration + SequencerID common.Address } -// DefaultDevNetwork provides an off-the-shelf default config for a sim network -func DefaultDevNetwork(tenGateway bool) *InMemDevNetwork { - numNodes := 4 // Default sim currently uses 4 L1 nodes. Obscuro nodes: 1 seq, 3 validators - networkWallets := params.NewSimWallets(0, numNodes, integration.EthereumChainID, integration.TenChainID) +func DefaultTenConfig() *TenConfig { + return &TenConfig{ + PortStart: integration.StartPortNetworkTests, + NumNodes: 4, + InitNumValidators: 3, + BatchInterval: 1 * time.Second, + RollupInterval: 10 * time.Second, + TenGatewayEnabled: false, + NumSeqEnclaves: 1, // increase for HA simulation + } +} + +func LocalDevNetwork(tenConfigOpts ...TenConfigOption) *InMemDevNetwork { + tenConfig := DefaultTenConfig() + for _, opt := range tenConfigOpts { + opt(tenConfig) + } + + // 1 wallet per node + nodeOpL1Wallets := params.NewSimWallets(0, tenConfig.NumNodes, integration.EthereumChainID, integration.TenChainID) l1Config := &L1Config{ PortStart: integration.StartPortNetworkTests, - NumNodes: 4, + NumNodes: tenConfig.NumNodes, // we'll have 1 L1 node per L2 node AvgBlockDuration: 1 * time.Second, } - l1Network := NewGethNetwork(networkWallets, l1Config) + l1Network := NewGethNetwork(nodeOpL1Wallets, l1Config) + + return NewInMemDevNetwork(tenConfig, l1Network, nodeOpL1Wallets) +} + +// NewInMemDevNetwork provides an off-the-shelf default config for a sim network +// tenConfig - the requirements of the L2 network we are spinning up +// l1Network - the L1 network we are running the L2 network on +// nodeOpL1Wallets - the funded wallets for the node operators on the L1 network (expecting 1 per node) +func NewInMemDevNetwork(tenConfig *TenConfig, l1Network L1Network, nodeOpL1Wallets *params.SimWallets) *InMemDevNetwork { + // update tenConfig references to be consistent with the L1 setup + tenConfig.L1BlockTime = l1Network.GetBlockTime() + tenConfig.SequencerID = nodeOpL1Wallets.NodeWallets[0].Address() // sequencer wallet address is its ID for now return &InMemDevNetwork{ - networkWallets: networkWallets, + networkWallets: nodeOpL1Wallets, l1Network: l1Network, - obscuroConfig: ObscuroConfig{ - PortStart: integration.StartPortNetworkTests, - InitNumValidators: 3, - BatchInterval: 1 * time.Second, - RollupInterval: 10 * time.Second, - L1BlockTime: 15 * time.Second, - SequencerID: networkWallets.NodeWallets[0].Address(), - }, - tenGatewayEnabled: tenGateway, - faucetLock: sync.Mutex{}, + tenConfig: tenConfig, + faucetLock: sync.Mutex{}, } } @@ -91,13 +117,18 @@ func LiveL1DevNetwork(seqWallet wallet.Wallet, validatorWallets []wallet.Wallet, logger: testlog.Logger(), networkWallets: networkWallets, l1Network: l1Network, - obscuroConfig: ObscuroConfig{ - PortStart: integration.StartPortNetworkTests, - InitNumValidators: len(validatorWallets), - BatchInterval: 5 * time.Second, - RollupInterval: 3 * time.Minute, - L1BlockTime: 15 * time.Second, - SequencerID: seqWallet.Address(), - }, + tenConfig: DefaultTenConfig(), + } +} + +func WithGateway() TenConfigOption { + return func(tc *TenConfig) { + tc.TenGatewayEnabled = true + } +} + +func WithHASequencer() TenConfigOption { + return func(tc *TenConfig) { + tc.NumSeqEnclaves = 2 } } diff --git a/integration/simulation/devnetwork/dev_network.go b/integration/simulation/devnetwork/dev_network.go index 2d1bc96884..3ac1be6060 100644 --- a/integration/simulation/devnetwork/dev_network.go +++ b/integration/simulation/devnetwork/dev_network.go @@ -52,21 +52,19 @@ type InMemDevNetwork struct { // When Obscuro network has been initialised on the L1 network, this will be populated // - if reconnecting to an existing network it needs to be populated when initialising this object // - if it is nil when `Start()` is called then Obscuro contracts will be deployed on the L1 - l1SetupData *params.L1SetupData + l1SetupData *params.L1TenData - obscuroConfig ObscuroConfig - obscuroSequencer *InMemNodeOperator - obscuroValidators []*InMemNodeOperator + tenConfig *TenConfig + tenSequencer *InMemNodeOperator + tenValidators []*InMemNodeOperator tenGatewayContainer *container.WalletExtensionContainer - tenGatewayEnabled bool - faucet userwallet.User faucetLock sync.Mutex } func (s *InMemDevNetwork) GetGatewayURL() (string, error) { - if !s.tenGatewayEnabled { + if !s.tenConfig.TenGatewayEnabled { return "", fmt.Errorf("ten gateway not enabled") } return fmt.Sprintf("http://localhost:%d", _gwHTTPPort), nil @@ -123,15 +121,15 @@ func (s *InMemDevNetwork) GetL1Client() (ethadapter.EthClient, error) { } func (s *InMemDevNetwork) GetSequencerNode() networktest.NodeOperator { - return s.obscuroSequencer + return s.tenSequencer } func (s *InMemDevNetwork) GetValidatorNode(i int) networktest.NodeOperator { - return s.obscuroValidators[i] + return s.tenValidators[i] } func (s *InMemDevNetwork) NumValidators() int { - return len(s.obscuroValidators) + return len(s.tenValidators) } func (s *InMemDevNetwork) Start() { @@ -148,7 +146,7 @@ func (s *InMemDevNetwork) Start() { fmt.Println("Starting obscuro nodes") s.startNodes() - if s.tenGatewayEnabled { + if s.tenConfig.TenGatewayEnabled { s.startTenGateway() } // sleep to allow the nodes to start @@ -160,22 +158,22 @@ func (s *InMemDevNetwork) GetGatewayClient() (ethadapter.EthClient, error) { } func (s *InMemDevNetwork) startNodes() { - if s.obscuroSequencer == nil { - // initialise node operators - s.obscuroSequencer = NewInMemNodeOperator(0, s.obscuroConfig, common.Sequencer, s.l1SetupData, s.l1Network.GetClient(0), s.networkWallets.NodeWallets[0], s.logger) - for i := 1; i <= s.obscuroConfig.InitNumValidators; i++ { + if s.tenSequencer == nil { + // initialise node operators (sequencer is node 0, validators are 1..N) + s.tenSequencer = NewInMemNodeOperator(0, s.tenConfig, common.Sequencer, s.l1SetupData, s.l1Network.GetClient(0), s.networkWallets.NodeWallets[0], s.logger) + for i := 1; i <= s.tenConfig.InitNumValidators; i++ { l1Client := s.l1Network.GetClient(i % s.l1Network.NumNodes()) - s.obscuroValidators = append(s.obscuroValidators, NewInMemNodeOperator(i, s.obscuroConfig, common.Validator, s.l1SetupData, l1Client, s.networkWallets.NodeWallets[i], s.logger)) + s.tenValidators = append(s.tenValidators, NewInMemNodeOperator(i, s.tenConfig, common.Validator, s.l1SetupData, l1Client, s.networkWallets.NodeWallets[i], s.logger)) } } go func() { - err := s.obscuroSequencer.Start() + err := s.tenSequencer.Start() if err != nil { panic(err) } }() - for _, v := range s.obscuroValidators { + for _, v := range s.tenValidators { go func(v networktest.NodeOperator) { err := v.Start() if err != nil { @@ -218,7 +216,7 @@ func (s *InMemDevNetwork) startTenGateway() { } func (s *InMemDevNetwork) CleanUp() { - for _, v := range s.obscuroValidators { + for _, v := range s.tenValidators { go func(v networktest.NodeOperator) { err := v.Stop() if err != nil { @@ -227,7 +225,7 @@ func (s *InMemDevNetwork) CleanUp() { }(v) } go func() { - err := s.obscuroSequencer.Stop() + err := s.tenSequencer.Stop() if err != nil { fmt.Println("failed to stop sequencer", err.Error()) } diff --git a/integration/simulation/devnetwork/geth_l1.go b/integration/simulation/devnetwork/geth_l1.go index 3de0028ffd..c78376bfad 100644 --- a/integration/simulation/devnetwork/geth_l1.go +++ b/integration/simulation/devnetwork/geth_l1.go @@ -2,6 +2,7 @@ package devnetwork import ( "fmt" + "time" "github.com/ten-protocol/go-ten/integration" @@ -51,3 +52,7 @@ func (g *gethDockerNetwork) NumNodes() int { func (g *gethDockerNetwork) GetClient(_ int) ethadapter.EthClient { return g.l1Clients[0] } + +func (g *gethDockerNetwork) GetBlockTime() time.Duration { + return g.l1Config.AvgBlockDuration +} diff --git a/integration/simulation/devnetwork/l1_network.go b/integration/simulation/devnetwork/l1_network.go index 79f77b8f41..eb564b3639 100644 --- a/integration/simulation/devnetwork/l1_network.go +++ b/integration/simulation/devnetwork/l1_network.go @@ -1,6 +1,8 @@ package devnetwork import ( + "time" + "github.com/ten-protocol/go-ten/go/ethadapter" ) @@ -12,4 +14,5 @@ type L1Network interface { CleanUp() // shut down nodes if required, clean up connections NumNodes() int GetClient(i int) ethadapter.EthClient + GetBlockTime() time.Duration // expected interval between blocks } diff --git a/integration/simulation/devnetwork/live_l1.go b/integration/simulation/devnetwork/live_l1.go index d5ad085e21..57af37a23c 100644 --- a/integration/simulation/devnetwork/live_l1.go +++ b/integration/simulation/devnetwork/live_l1.go @@ -13,6 +13,7 @@ import ( type liveL1Network struct { deployWallet wallet.Wallet // wallet that can deploy to the live L1 network rpcURLs []string + blockTime time.Duration // expected interval between blocks clients []ethadapter.EthClient seqWallet wallet.Wallet @@ -51,6 +52,10 @@ func (l *liveL1Network) GetClient(i int) ethadapter.EthClient { return l.clients[i%len(l.clients)] } +func (l *liveL1Network) GetBlockTime() time.Duration { + return l.blockTime +} + func (l *liveL1Network) prepareClients() { l.clients = make([]ethadapter.EthClient, len(l.rpcURLs)) for i, addr := range l.rpcURLs { diff --git a/integration/simulation/devnetwork/node.go b/integration/simulation/devnetwork/node.go index 3fe32fe087..1095043e78 100644 --- a/integration/simulation/devnetwork/node.go +++ b/integration/simulation/devnetwork/node.go @@ -45,9 +45,9 @@ import ( // Note: InMemNodeOperator will panic when things go wrong, we want to fail fast in sims and avoid verbose error handling in usage type InMemNodeOperator struct { operatorIdx int - config ObscuroConfig + config *TenConfig nodeType common.NodeType - l1Data *params.L1SetupData + l1Data *params.L1TenData l1Client ethadapter.EthClient logger gethlog.Logger @@ -126,8 +126,7 @@ func (n *InMemNodeOperator) createHostContainer() *hostcontainer.HostContainer { MessageBusAddress: n.l1Data.MessageBusAddr, L1ChainID: integration.EthereumChainID, ObscuroChainID: integration.TenChainID, - L1StartHash: n.l1Data.ObscuroStartBlock, - SequencerID: n.config.SequencerID, + L1StartHash: n.l1Data.TenStartBlock, UseInMemoryDB: false, LevelDBPath: n.hostDBFilepath, DebugNamespaceEnabled: true, @@ -233,7 +232,7 @@ func (n *InMemNodeOperator) StopEnclave() error { return nil } -func NewInMemNodeOperator(operatorIdx int, config ObscuroConfig, nodeType common.NodeType, l1Data *params.L1SetupData, +func NewInMemNodeOperator(operatorIdx int, config *TenConfig, nodeType common.NodeType, l1Data *params.L1TenData, l1Client ethadapter.EthClient, l1Wallet wallet.Wallet, logger gethlog.Logger, ) *InMemNodeOperator { // todo (@matt) - put sqlite and levelDB storage in the same temp dir diff --git a/integration/simulation/network/geth_network.go b/integration/simulation/network/geth_network.go index 6b2eb9a30e..c40deede97 100644 --- a/integration/simulation/network/geth_network.go +++ b/integration/simulation/network/geth_network.go @@ -30,16 +30,16 @@ func NewNetworkInMemoryGeth(wallets *params.SimWallets) Network { // Create inits and starts the nodes, wires them up, and populates the network objects func (n *networkInMemGeth) Create(params *params.SimParams, _ *stats.Stats) (*RPCHandles, error) { // kickoff the network with the prefunded wallet addresses - params.L1SetupData, n.gethClients, n.eth2Network = SetUpGethNetwork( + params.L1TenData, n.gethClients, n.eth2Network = SetUpGethNetwork( n.wallets, params.StartPort, params.NumberOfNodes, int(params.AvgBlockDuration.Seconds()), ) - params.MgmtContractLib = mgmtcontractlib.NewMgmtContractLib(¶ms.L1SetupData.MgmtContractAddress, testlog.Logger()) - params.ERC20ContractLib = erc20contractlib.NewERC20ContractLib(¶ms.L1SetupData.MgmtContractAddress, - ¶ms.L1SetupData.ObxErc20Address, ¶ms.L1SetupData.EthErc20Address) + params.MgmtContractLib = mgmtcontractlib.NewMgmtContractLib(¶ms.L1TenData.MgmtContractAddress, testlog.Logger()) + params.ERC20ContractLib = erc20contractlib.NewERC20ContractLib(¶ms.L1TenData.MgmtContractAddress, + ¶ms.L1TenData.ObxErc20Address, ¶ms.L1TenData.EthErc20Address) // Start the obscuro nodes and return the handles n.l2Clients = startInMemoryObscuroNodes(params, n.eth2Network.GethGenesis(), n.gethClients) diff --git a/integration/simulation/network/geth_utils.go b/integration/simulation/network/geth_utils.go index 39504b9fb7..a8df58c26d 100644 --- a/integration/simulation/network/geth_utils.go +++ b/integration/simulation/network/geth_utils.go @@ -28,7 +28,7 @@ const ( e2eTestPrefundedL1Addr = "0x13E23Ca74DE0206C56ebaE8D51b5622EFF1E9944" ) -func SetUpGethNetwork(wallets *params.SimWallets, startPort int, nrNodes int, blockDurationSeconds int) (*params.L1SetupData, []ethadapter.EthClient, eth2network.Eth2Network) { +func SetUpGethNetwork(wallets *params.SimWallets, startPort int, nrNodes int, blockDurationSeconds int) (*params.L1TenData, []ethadapter.EthClient, eth2network.Eth2Network) { eth2Network, err := StartGethNetwork(wallets, startPort, blockDurationSeconds) if err != nil { panic(fmt.Errorf("error starting geth network %w", err)) @@ -95,7 +95,7 @@ func StartGethNetwork(wallets *params.SimWallets, startPort int, blockDurationSe return eth2Network, nil } -func DeployObscuroNetworkContracts(client ethadapter.EthClient, wallets *params.SimWallets, deployERC20s bool) (*params.L1SetupData, error) { +func DeployObscuroNetworkContracts(client ethadapter.EthClient, wallets *params.SimWallets, deployERC20s bool) (*params.L1TenData, error) { bytecode, err := constants.Bytecode() if err != nil { return nil, err @@ -135,8 +135,8 @@ func DeployObscuroNetworkContracts(client ethadapter.EthClient, wallets *params. "blockHash: ", mgmtContractReceipt.BlockHash, "l1BusAddress: ", l1BusAddress) if !deployERC20s { - return ¶ms.L1SetupData{ - ObscuroStartBlock: mgmtContractReceipt.BlockHash, + return ¶ms.L1TenData{ + TenStartBlock: mgmtContractReceipt.BlockHash, MgmtContractAddress: mgmtContractReceipt.ContractAddress, MessageBusAddr: l1BusAddress, }, nil @@ -152,8 +152,8 @@ func DeployObscuroNetworkContracts(client ethadapter.EthClient, wallets *params. erc20ContractAddr = append(erc20ContractAddr, erc20receipt.ContractAddress) } - return ¶ms.L1SetupData{ - ObscuroStartBlock: mgmtContractReceipt.BlockHash, + return ¶ms.L1TenData{ + TenStartBlock: mgmtContractReceipt.BlockHash, MgmtContractAddress: mgmtContractReceipt.ContractAddress, ObxErc20Address: erc20ContractAddr[0], EthErc20Address: erc20ContractAddr[1], diff --git a/integration/simulation/network/obscuro_node_utils.go b/integration/simulation/network/obscuro_node_utils.go index 33da3caaf6..ec3fcff229 100644 --- a/integration/simulation/network/obscuro_node_utils.go +++ b/integration/simulation/network/obscuro_node_utils.go @@ -48,8 +48,8 @@ func startInMemoryObscuroNodes(params *params.SimParams, genesisJSON []byte, l1C params.Wallets.NodeWallets[i], l1Clients[i], mockP2PNetw.NewNode(i), - params.L1SetupData.MessageBusAddr, - params.L1SetupData.ObscuroStartBlock, + params.L1TenData.MessageBusAddr, + params.L1TenData.TenStartBlock, params.AvgBlockDuration/3, true, params.AvgBlockDuration, diff --git a/integration/simulation/network/socket.go b/integration/simulation/network/socket.go index eff5eb462d..71d9fa2cc9 100644 --- a/integration/simulation/network/socket.go +++ b/integration/simulation/network/socket.go @@ -45,18 +45,18 @@ func NewNetworkOfSocketNodes(wallets *params.SimWallets) Network { func (n *networkOfSocketNodes) Create(simParams *params.SimParams, _ *stats.Stats) (*RPCHandles, error) { // kickoff the network with the prefunded wallet addresses - simParams.L1SetupData, n.gethClients, n.eth2Network = SetUpGethNetwork( + simParams.L1TenData, n.gethClients, n.eth2Network = SetUpGethNetwork( n.wallets, simParams.StartPort, simParams.NumberOfNodes, int(simParams.AvgBlockDuration.Seconds()), ) - simParams.MgmtContractLib = mgmtcontractlib.NewMgmtContractLib(&simParams.L1SetupData.MgmtContractAddress, testlog.Logger()) + simParams.MgmtContractLib = mgmtcontractlib.NewMgmtContractLib(&simParams.L1TenData.MgmtContractAddress, testlog.Logger()) simParams.ERC20ContractLib = erc20contractlib.NewERC20ContractLib( - &simParams.L1SetupData.MgmtContractAddress, - &simParams.L1SetupData.ObxErc20Address, - &simParams.L1SetupData.EthErc20Address, + &simParams.L1TenData.MgmtContractAddress, + &simParams.L1TenData.ObxErc20Address, + &simParams.L1TenData.EthErc20Address, ) // get the sequencer Address @@ -100,8 +100,8 @@ func (n *networkOfSocketNodes) Create(simParams *params.SimParams, _ *stats.Stat node.WithHostHTTPPort(simParams.StartPort+integration.DefaultHostRPCHTTPOffset+i), node.WithHostP2PPort(simParams.StartPort+integration.DefaultHostP2pOffset+i), node.WithHostPublicP2PAddr(fmt.Sprintf("127.0.0.1:%d", simParams.StartPort+integration.DefaultHostP2pOffset+i)), - node.WithManagementContractAddress(simParams.L1SetupData.MgmtContractAddress.String()), - node.WithMessageBusContractAddress(simParams.L1SetupData.MessageBusAddr.String()), + node.WithManagementContractAddress(simParams.L1TenData.MgmtContractAddress.String()), + node.WithMessageBusContractAddress(simParams.L1TenData.MessageBusAddr.String()), node.WithNodeType(nodeTypeStr), node.WithCoinbase(simParams.Wallets.L2FeesWallet.Address().Hex()), node.WithL1WebsocketURL(fmt.Sprintf("ws://%s:%d", "127.0.0.1", simParams.StartPort+100)), diff --git a/integration/simulation/params/params.go b/integration/simulation/params/params.go index 05d43b1d1d..b20b9ab178 100644 --- a/integration/simulation/params/params.go +++ b/integration/simulation/params/params.go @@ -26,7 +26,7 @@ type SimParams struct { // ERC20ContractLib allows parsing ERC20Contract txs to and from the eth txs ERC20ContractLib erc20contractlib.ERC20ContractLib - L1SetupData *L1SetupData + L1TenData *L1TenData // Contains all the wallets required by the simulation Wallets *SimWallets @@ -41,9 +41,9 @@ type SimParams struct { WithPrefunding bool } -type L1SetupData struct { - // ObscuroStartBlock is the L1 block hash where the Obscuro network activity begins (e.g. mgmt contract deployment) - ObscuroStartBlock common.Hash +type L1TenData struct { + // TenStartBlock is the L1 block hash where the Ten network activity begins (e.g. mgmt contract deployment) + TenStartBlock common.Hash // MgmtContractAddr defines the management contract address MgmtContractAddress common.Address // ObxErc20Address - the address of the "TEN" ERC20 diff --git a/integration/simulation/simulation.go b/integration/simulation/simulation.go index 6ab71178f5..d2ab17b953 100644 --- a/integration/simulation/simulation.go +++ b/integration/simulation/simulation.go @@ -127,7 +127,7 @@ func (s *Simulation) bridgeFundingToObscuro() { return } - destAddr := s.Params.L1SetupData.MessageBusAddr + destAddr := s.Params.L1TenData.MessageBusAddr value, _ := big.NewInt(0).SetString("7400000000000000000000000000000", 10) wallets := []wallet.Wallet{ diff --git a/integration/simulation/simulation_in_mem_test.go b/integration/simulation/simulation_in_mem_test.go index b29f057ab5..d3d4b22d09 100644 --- a/integration/simulation/simulation_in_mem_test.go +++ b/integration/simulation/simulation_in_mem_test.go @@ -34,7 +34,7 @@ func TestInMemoryMonteCarloSimulation(t *testing.T) { Wallets: wallets, StartPort: integration.StartPortSimulationInMem, IsInMem: true, - L1SetupData: ¶ms.L1SetupData{}, + L1TenData: ¶ms.L1TenData{}, ReceiptTimeout: 5 * time.Second, StoppingDelay: 4 * time.Second, NodeWithInboundP2PDisabled: 2, diff --git a/integration/simulation/simulation_tester.go b/integration/simulation/simulation_tester.go index 4d4e837998..9b776c963c 100644 --- a/integration/simulation/simulation_tester.go +++ b/integration/simulation/simulation_tester.go @@ -47,7 +47,7 @@ func testSimulation(t *testing.T, netw network.Network, params *params.SimParams stats, networkClients, params.Wallets, - ¶ms.L1SetupData.MgmtContractAddress, + ¶ms.L1TenData.MgmtContractAddress, params.MgmtContractLib, params.ERC20ContractLib, 0,