From 60a45eed196067ff69a964e99b0f97c8ce5ab0de Mon Sep 17 00:00:00 2001 From: otherview Date: Fri, 22 Dec 2023 15:58:41 +0000 Subject: [PATCH 01/13] update gas values --- go/config/enclave_cli_flags.go | 4 +-- go/enclave/crosschain/message_bus_manager.go | 4 +-- integration/common/constants.go | 4 +-- integration/constants.go | 28 ++++++++++---------- integration/simulation/simulation.go | 2 +- tools/hardhatdeployer/contract_deployer.go | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/go/config/enclave_cli_flags.go b/go/config/enclave_cli_flags.go index 690b43f49b..68d4e430b5 100644 --- a/go/config/enclave_cli_flags.go +++ b/go/config/enclave_cli_flags.go @@ -55,14 +55,14 @@ var EnclaveFlags = map[string]*flag.TenFlag{ MaxRollupSizeFlag: flag.NewUint64Flag(MaxRollupSizeFlag, 1024*64, "The maximum size a rollup is allowed to reach"), L2BaseFeeFlag: flag.NewUint64Flag(L2BaseFeeFlag, 1, ""), L2CoinbaseFlag: flag.NewStringFlag(L2CoinbaseFlag, "0xd6C9230053f45F873Cb66D8A02439380a37A4fbF", ""), - GasBatchExecutionLimit: flag.NewUint64Flag(GasBatchExecutionLimit, 3_000_000, "Max gas that can be executed in a single batch"), + GasBatchExecutionLimit: flag.NewUint64Flag(GasBatchExecutionLimit, 5_000_000, "Max gas that can be executed in a single batch"), ObscuroGenesisFlag: flag.NewStringFlag(ObscuroGenesisFlag, "", "The json string with the obscuro genesis"), L1ChainIDFlag: flag.NewInt64Flag(L1ChainIDFlag, 1337, "An integer representing the unique chain id of the Ethereum chain used as an L1 (default 1337)"), ObscuroChainIDFlag: flag.NewInt64Flag(ObscuroChainIDFlag, 443, "An integer representing the unique chain id of the Obscuro chain (default 443)"), UseInMemoryDBFlag: flag.NewBoolFlag(UseInMemoryDBFlag, true, "Whether the enclave will use an in-memory DB rather than persist data"), ProfilerEnabledFlag: flag.NewBoolFlag(ProfilerEnabledFlag, false, "Runs a profiler instance (Defaults to false)"), DebugNamespaceEnabledFlag: flag.NewBoolFlag(DebugNamespaceEnabledFlag, false, "Whether the debug namespace is enabled"), - GasLocalExecutionCapFlag: flag.NewUint64Flag(GasLocalExecutionCapFlag, 3_000_000, "Max gas usage when executing local transactions"), + GasLocalExecutionCapFlag: flag.NewUint64Flag(GasLocalExecutionCapFlag, 5_000_000, "Max gas usage when executing local transactions"), } // enclaveRestrictedFlags are the flags that the enclave can receive ONLY over the Ego signed enclave.json diff --git a/go/enclave/crosschain/message_bus_manager.go b/go/enclave/crosschain/message_bus_manager.go index 94bd0b9be7..3dce80eb5d 100644 --- a/go/enclave/crosschain/message_bus_manager.go +++ b/go/enclave/crosschain/message_bus_manager.go @@ -86,7 +86,7 @@ func (m *MessageBusManager) GenerateMessageBusDeployTx() (*common.L2Tx, error) { tx := &types.LegacyTx{ Nonce: 0, // The first transaction of the owner identity should always be deploying the contract Value: gethcommon.Big0, - Gas: 2_000_000, // It's quite the expensive contract. + Gas: 4_000_000, GasPrice: gethcommon.Big0, // Synthetic transactions are on the house. Or the house. Data: gethcommon.FromHex(MessageBus.MessageBusMetaData.Bin), To: nil, // Geth requires nil instead of gethcommon.Address{} which equates to zero address in order to return receipt. @@ -219,7 +219,7 @@ func (m *MessageBusManager) CreateSyntheticTransactions(messages common.CrossCha tx := &types.LegacyTx{ Nonce: startingNonce + uint64(idx), Value: gethcommon.Big0, - Gas: 2_000_000, + Gas: 4_900_000, GasPrice: gethcommon.Big0, // Synthetic transactions are on the house. Or the house. Data: data, To: m.messageBusAddress, diff --git a/integration/common/constants.go b/integration/common/constants.go index b46cbd51d4..1b1250effa 100644 --- a/integration/common/constants.go +++ b/integration/common/constants.go @@ -83,7 +83,7 @@ func DefaultEnclaveConfig() *config.EnclaveConfig { MaxRollupSize: 1024 * 64, GasPaymentAddress: gethcommon.HexToAddress("0xd6C9230053f45F873Cb66D8A02439380a37A4fbF"), BaseFee: new(big.Int).SetUint64(1), - GasLocalExecutionCapFlag: 3_000_000, - GasBatchExecutionLimit: 3_000_000, + GasLocalExecutionCapFlag: 5_000_000, + GasBatchExecutionLimit: 5_000_000, } } diff --git a/integration/constants.go b/integration/constants.go index 37dee9b2f0..aa6ff6499b 100644 --- a/integration/constants.go +++ b/integration/constants.go @@ -3,17 +3,17 @@ package integration // Tracks the start ports handed out to different tests, in a bid to minimise conflicts. const ( StartPortEth2NetworkTests = 31000 - StartPortNodeRunnerTest = 32000 - StartPortSimulationGethInMem = 34000 - StartPortSimulationInMem = 35000 - StartPortSimulationFullNetwork = 37000 - StartPortSmartContractTests = 38000 - StartPortContractDeployerTest = 39000 - StartPortWalletExtensionUnitTest = 40000 - StartPortFaucetUnitTest = 41000 - StartPortFaucetHTTPUnitTest = 42000 - StartPortTenscanUnitTest = 43000 - StartPortTenGatewayUnitTest = 44000 + StartPortNodeRunnerTest = 33000 + StartPortSimulationGethInMem = 35000 + StartPortSimulationInMem = 37000 + StartPortSimulationFullNetwork = 39000 + StartPortSmartContractTests = 41000 + StartPortContractDeployerTest = 43000 + StartPortWalletExtensionUnitTest = 45000 + StartPortFaucetUnitTest = 47000 + StartPortFaucetHTTPUnitTest = 49000 + StartPortTenscanUnitTest = 51000 + StartPortTenGatewayUnitTest = 53000 DefaultGethWSPortOffset = 100 DefaultGethAUTHPortOffset = 200 @@ -24,9 +24,9 @@ const ( DefaultEnclaveOffset = 700 // The default offset between a Geth nodes port and the enclave ports. Used in Socket Simulations. DefaultHostRPCHTTPOffset = 800 // The default offset for the host's RPC HTTP port DefaultHostRPCWSOffset = 900 // The default offset for the host's RPC websocket port - DefaultTenscanHTTPPortOffset = 910 - DefaultTenGatewayHTTPPortOffset = 930 - DefaultTenGatewayWSPortOffset = 940 + DefaultTenscanHTTPPortOffset = 1000 + DefaultTenGatewayHTTPPortOffset = 1100 + DefaultTenGatewayWSPortOffset = 1200 ) const ( diff --git a/integration/simulation/simulation.go b/integration/simulation/simulation.go index 5fe8c20068..a139b0c6a1 100644 --- a/integration/simulation/simulation.go +++ b/integration/simulation/simulation.go @@ -227,7 +227,7 @@ func (s *Simulation) deployObscuroERC20s() { deployContractTx := types.DynamicFeeTx{ Nonce: NextNonce(s.ctx, s.RPCHandles, owner), - Gas: 2_000_000, + Gas: 4_000_000, GasFeeCap: gethcommon.Big1, // This field is used to derive the gas price for dynamic fee transactions. Data: contractBytes, GasTipCap: gethcommon.Big1, diff --git a/tools/hardhatdeployer/contract_deployer.go b/tools/hardhatdeployer/contract_deployer.go index 4b8febd145..15da754447 100644 --- a/tools/hardhatdeployer/contract_deployer.go +++ b/tools/hardhatdeployer/contract_deployer.go @@ -92,7 +92,7 @@ func (cd *contractDeployer) run() (string, error) { deployContractTx := types.LegacyTx{ Nonce: cd.wallet.GetNonceAndIncrement(), GasPrice: big.NewInt(1), - Gas: uint64(2_000_000), + Gas: uint64(4_000_000), // todo @pedro review this Data: cd.contractCode, } From e79e913df28262f5e1c679b8b7828651327ec32b Mon Sep 17 00:00:00 2001 From: otherview Date: Fri, 22 Dec 2023 16:11:30 +0000 Subject: [PATCH 02/13] updating gas prices --- integration/simulation/simulation.go | 2 +- tools/hardhatdeployer/contract_deployer.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/simulation/simulation.go b/integration/simulation/simulation.go index a139b0c6a1..9859e711c5 100644 --- a/integration/simulation/simulation.go +++ b/integration/simulation/simulation.go @@ -227,7 +227,7 @@ func (s *Simulation) deployObscuroERC20s() { deployContractTx := types.DynamicFeeTx{ Nonce: NextNonce(s.ctx, s.RPCHandles, owner), - Gas: 4_000_000, + Gas: 2_900_000, GasFeeCap: gethcommon.Big1, // This field is used to derive the gas price for dynamic fee transactions. Data: contractBytes, GasTipCap: gethcommon.Big1, diff --git a/tools/hardhatdeployer/contract_deployer.go b/tools/hardhatdeployer/contract_deployer.go index 15da754447..19edf309fd 100644 --- a/tools/hardhatdeployer/contract_deployer.go +++ b/tools/hardhatdeployer/contract_deployer.go @@ -92,7 +92,7 @@ func (cd *contractDeployer) run() (string, error) { deployContractTx := types.LegacyTx{ Nonce: cd.wallet.GetNonceAndIncrement(), GasPrice: big.NewInt(1), - Gas: uint64(4_000_000), // todo @pedro review this + Gas: uint64(2_900_000), Data: cd.contractCode, } From 3792c7548cf5e97b2ea6a42a936265f9f47ef000 Mon Sep 17 00:00:00 2001 From: otherview Date: Fri, 22 Dec 2023 16:30:45 +0000 Subject: [PATCH 03/13] expand ports --- integration/constants.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/integration/constants.go b/integration/constants.go index aa6ff6499b..6191b4f932 100644 --- a/integration/constants.go +++ b/integration/constants.go @@ -2,18 +2,18 @@ package integration // Tracks the start ports handed out to different tests, in a bid to minimise conflicts. const ( - StartPortEth2NetworkTests = 31000 - StartPortNodeRunnerTest = 33000 - StartPortSimulationGethInMem = 35000 - StartPortSimulationInMem = 37000 - StartPortSimulationFullNetwork = 39000 - StartPortSmartContractTests = 41000 - StartPortContractDeployerTest = 43000 - StartPortWalletExtensionUnitTest = 45000 - StartPortFaucetUnitTest = 47000 - StartPortFaucetHTTPUnitTest = 49000 - StartPortTenscanUnitTest = 51000 - StartPortTenGatewayUnitTest = 53000 + StartPortEth2NetworkTests = 10000 + StartPortNodeRunnerTest = 14000 + StartPortSimulationGethInMem = 18000 + StartPortSimulationInMem = 22000 + StartPortSimulationFullNetwork = 26000 + StartPortSmartContractTests = 30000 + StartPortContractDeployerTest = 34000 + StartPortWalletExtensionUnitTest = 38000 + StartPortFaucetUnitTest = 42000 + StartPortFaucetHTTPUnitTest = 48000 + StartPortTenscanUnitTest = 52000 + StartPortTenGatewayUnitTest = 56000 DefaultGethWSPortOffset = 100 DefaultGethAUTHPortOffset = 200 @@ -25,8 +25,8 @@ const ( DefaultHostRPCHTTPOffset = 800 // The default offset for the host's RPC HTTP port DefaultHostRPCWSOffset = 900 // The default offset for the host's RPC websocket port DefaultTenscanHTTPPortOffset = 1000 - DefaultTenGatewayHTTPPortOffset = 1100 - DefaultTenGatewayWSPortOffset = 1200 + DefaultTenGatewayHTTPPortOffset = 1001 + DefaultTenGatewayWSPortOffset = 1002 ) const ( From 7aaafdd90edcd8b8b087de50140077ce2770276d Mon Sep 17 00:00:00 2001 From: otherview Date: Tue, 26 Dec 2023 10:33:51 +0000 Subject: [PATCH 04/13] bump gas --- go/config/enclave_cli_flags.go | 2 +- go/enclave/crosschain/message_bus_manager.go | 4 ++-- integration/common/constants.go | 2 +- integration/simulation/simulation.go | 2 +- tools/hardhatdeployer/contract_deployer.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go/config/enclave_cli_flags.go b/go/config/enclave_cli_flags.go index 68d4e430b5..0e76f15920 100644 --- a/go/config/enclave_cli_flags.go +++ b/go/config/enclave_cli_flags.go @@ -62,7 +62,7 @@ var EnclaveFlags = map[string]*flag.TenFlag{ UseInMemoryDBFlag: flag.NewBoolFlag(UseInMemoryDBFlag, true, "Whether the enclave will use an in-memory DB rather than persist data"), ProfilerEnabledFlag: flag.NewBoolFlag(ProfilerEnabledFlag, false, "Runs a profiler instance (Defaults to false)"), DebugNamespaceEnabledFlag: flag.NewBoolFlag(DebugNamespaceEnabledFlag, false, "Whether the debug namespace is enabled"), - GasLocalExecutionCapFlag: flag.NewUint64Flag(GasLocalExecutionCapFlag, 5_000_000, "Max gas usage when executing local transactions"), + GasLocalExecutionCapFlag: flag.NewUint64Flag(GasLocalExecutionCapFlag, 6_000_000, "Max gas usage when executing local transactions"), } // enclaveRestrictedFlags are the flags that the enclave can receive ONLY over the Ego signed enclave.json diff --git a/go/enclave/crosschain/message_bus_manager.go b/go/enclave/crosschain/message_bus_manager.go index 3dce80eb5d..fd21f164e4 100644 --- a/go/enclave/crosschain/message_bus_manager.go +++ b/go/enclave/crosschain/message_bus_manager.go @@ -86,7 +86,7 @@ func (m *MessageBusManager) GenerateMessageBusDeployTx() (*common.L2Tx, error) { tx := &types.LegacyTx{ Nonce: 0, // The first transaction of the owner identity should always be deploying the contract Value: gethcommon.Big0, - Gas: 4_000_000, + Gas: 4_000_000, // It's quite the expensive contract. GasPrice: gethcommon.Big0, // Synthetic transactions are on the house. Or the house. Data: gethcommon.FromHex(MessageBus.MessageBusMetaData.Bin), To: nil, // Geth requires nil instead of gethcommon.Address{} which equates to zero address in order to return receipt. @@ -219,7 +219,7 @@ func (m *MessageBusManager) CreateSyntheticTransactions(messages common.CrossCha tx := &types.LegacyTx{ Nonce: startingNonce + uint64(idx), Value: gethcommon.Big0, - Gas: 4_900_000, + Gas: 4_000_000, GasPrice: gethcommon.Big0, // Synthetic transactions are on the house. Or the house. Data: data, To: m.messageBusAddress, diff --git a/integration/common/constants.go b/integration/common/constants.go index 1b1250effa..2153292518 100644 --- a/integration/common/constants.go +++ b/integration/common/constants.go @@ -84,6 +84,6 @@ func DefaultEnclaveConfig() *config.EnclaveConfig { GasPaymentAddress: gethcommon.HexToAddress("0xd6C9230053f45F873Cb66D8A02439380a37A4fbF"), BaseFee: new(big.Int).SetUint64(1), GasLocalExecutionCapFlag: 5_000_000, - GasBatchExecutionLimit: 5_000_000, + GasBatchExecutionLimit: 6_000_000, } } diff --git a/integration/simulation/simulation.go b/integration/simulation/simulation.go index 9859e711c5..a139b0c6a1 100644 --- a/integration/simulation/simulation.go +++ b/integration/simulation/simulation.go @@ -227,7 +227,7 @@ func (s *Simulation) deployObscuroERC20s() { deployContractTx := types.DynamicFeeTx{ Nonce: NextNonce(s.ctx, s.RPCHandles, owner), - Gas: 2_900_000, + Gas: 4_000_000, GasFeeCap: gethcommon.Big1, // This field is used to derive the gas price for dynamic fee transactions. Data: contractBytes, GasTipCap: gethcommon.Big1, diff --git a/tools/hardhatdeployer/contract_deployer.go b/tools/hardhatdeployer/contract_deployer.go index 19edf309fd..4c91088d78 100644 --- a/tools/hardhatdeployer/contract_deployer.go +++ b/tools/hardhatdeployer/contract_deployer.go @@ -92,7 +92,7 @@ func (cd *contractDeployer) run() (string, error) { deployContractTx := types.LegacyTx{ Nonce: cd.wallet.GetNonceAndIncrement(), GasPrice: big.NewInt(1), - Gas: uint64(2_900_000), + Gas: uint64(4_000_000), Data: cd.contractCode, } From fdb8c051a73f679843d14474c46bb183aaf41cd8 Mon Sep 17 00:00:00 2001 From: otherview Date: Tue, 26 Dec 2023 10:54:45 +0000 Subject: [PATCH 05/13] bump gas --- .../deployment_scripts/testnet/layer2/001_whitelist_tokens.ts | 2 +- go/config/enclave_cli_flags.go | 4 ++-- go/enclave/crosschain/message_bus_manager.go | 4 ++-- integration/common/constants.go | 4 ++-- integration/simulation/simulation.go | 2 +- tools/hardhatdeployer/contract_deployer.go | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contracts/deployment_scripts/testnet/layer2/001_whitelist_tokens.ts b/contracts/deployment_scripts/testnet/layer2/001_whitelist_tokens.ts index 2e6bffd29a..5a82451c0b 100644 --- a/contracts/deployment_scripts/testnet/layer2/001_whitelist_tokens.ts +++ b/contracts/deployment_scripts/testnet/layer2/001_whitelist_tokens.ts @@ -122,7 +122,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { return l2Network.deployments.execute("CrossChainMessenger", { from: l2Accounts.deployer, log: true, - gasLimit: 2_500_000 + gasLimit: 3_000_000 }, "relayMessage", msg); }; diff --git a/go/config/enclave_cli_flags.go b/go/config/enclave_cli_flags.go index 0e76f15920..fe010a30d9 100644 --- a/go/config/enclave_cli_flags.go +++ b/go/config/enclave_cli_flags.go @@ -55,14 +55,14 @@ var EnclaveFlags = map[string]*flag.TenFlag{ MaxRollupSizeFlag: flag.NewUint64Flag(MaxRollupSizeFlag, 1024*64, "The maximum size a rollup is allowed to reach"), L2BaseFeeFlag: flag.NewUint64Flag(L2BaseFeeFlag, 1, ""), L2CoinbaseFlag: flag.NewStringFlag(L2CoinbaseFlag, "0xd6C9230053f45F873Cb66D8A02439380a37A4fbF", ""), - GasBatchExecutionLimit: flag.NewUint64Flag(GasBatchExecutionLimit, 5_000_000, "Max gas that can be executed in a single batch"), + GasBatchExecutionLimit: flag.NewUint64Flag(GasBatchExecutionLimit, 10_000_000, "Max gas that can be executed in a single batch"), ObscuroGenesisFlag: flag.NewStringFlag(ObscuroGenesisFlag, "", "The json string with the obscuro genesis"), L1ChainIDFlag: flag.NewInt64Flag(L1ChainIDFlag, 1337, "An integer representing the unique chain id of the Ethereum chain used as an L1 (default 1337)"), ObscuroChainIDFlag: flag.NewInt64Flag(ObscuroChainIDFlag, 443, "An integer representing the unique chain id of the Obscuro chain (default 443)"), UseInMemoryDBFlag: flag.NewBoolFlag(UseInMemoryDBFlag, true, "Whether the enclave will use an in-memory DB rather than persist data"), ProfilerEnabledFlag: flag.NewBoolFlag(ProfilerEnabledFlag, false, "Runs a profiler instance (Defaults to false)"), DebugNamespaceEnabledFlag: flag.NewBoolFlag(DebugNamespaceEnabledFlag, false, "Whether the debug namespace is enabled"), - GasLocalExecutionCapFlag: flag.NewUint64Flag(GasLocalExecutionCapFlag, 6_000_000, "Max gas usage when executing local transactions"), + GasLocalExecutionCapFlag: flag.NewUint64Flag(GasLocalExecutionCapFlag, 12_000_000, "Max gas usage when executing local transactions"), } // enclaveRestrictedFlags are the flags that the enclave can receive ONLY over the Ego signed enclave.json diff --git a/go/enclave/crosschain/message_bus_manager.go b/go/enclave/crosschain/message_bus_manager.go index fd21f164e4..1731a10515 100644 --- a/go/enclave/crosschain/message_bus_manager.go +++ b/go/enclave/crosschain/message_bus_manager.go @@ -86,7 +86,7 @@ func (m *MessageBusManager) GenerateMessageBusDeployTx() (*common.L2Tx, error) { tx := &types.LegacyTx{ Nonce: 0, // The first transaction of the owner identity should always be deploying the contract Value: gethcommon.Big0, - Gas: 4_000_000, // It's quite the expensive contract. + Gas: 5_000_000, // It's quite the expensive contract. GasPrice: gethcommon.Big0, // Synthetic transactions are on the house. Or the house. Data: gethcommon.FromHex(MessageBus.MessageBusMetaData.Bin), To: nil, // Geth requires nil instead of gethcommon.Address{} which equates to zero address in order to return receipt. @@ -219,7 +219,7 @@ func (m *MessageBusManager) CreateSyntheticTransactions(messages common.CrossCha tx := &types.LegacyTx{ Nonce: startingNonce + uint64(idx), Value: gethcommon.Big0, - Gas: 4_000_000, + Gas: 5_000_000, GasPrice: gethcommon.Big0, // Synthetic transactions are on the house. Or the house. Data: data, To: m.messageBusAddress, diff --git a/integration/common/constants.go b/integration/common/constants.go index 2153292518..45a1462c5b 100644 --- a/integration/common/constants.go +++ b/integration/common/constants.go @@ -83,7 +83,7 @@ func DefaultEnclaveConfig() *config.EnclaveConfig { MaxRollupSize: 1024 * 64, GasPaymentAddress: gethcommon.HexToAddress("0xd6C9230053f45F873Cb66D8A02439380a37A4fbF"), BaseFee: new(big.Int).SetUint64(1), - GasLocalExecutionCapFlag: 5_000_000, - GasBatchExecutionLimit: 6_000_000, + GasLocalExecutionCapFlag: 10_000_000, + GasBatchExecutionLimit: 12_000_000, } } diff --git a/integration/simulation/simulation.go b/integration/simulation/simulation.go index a139b0c6a1..4a3a814320 100644 --- a/integration/simulation/simulation.go +++ b/integration/simulation/simulation.go @@ -227,7 +227,7 @@ func (s *Simulation) deployObscuroERC20s() { deployContractTx := types.DynamicFeeTx{ Nonce: NextNonce(s.ctx, s.RPCHandles, owner), - Gas: 4_000_000, + Gas: 5_000_000, GasFeeCap: gethcommon.Big1, // This field is used to derive the gas price for dynamic fee transactions. Data: contractBytes, GasTipCap: gethcommon.Big1, diff --git a/tools/hardhatdeployer/contract_deployer.go b/tools/hardhatdeployer/contract_deployer.go index 4c91088d78..bc5c9b921b 100644 --- a/tools/hardhatdeployer/contract_deployer.go +++ b/tools/hardhatdeployer/contract_deployer.go @@ -92,7 +92,7 @@ func (cd *contractDeployer) run() (string, error) { deployContractTx := types.LegacyTx{ Nonce: cd.wallet.GetNonceAndIncrement(), GasPrice: big.NewInt(1), - Gas: uint64(4_000_000), + Gas: uint64(5_000_000), Data: cd.contractCode, } From 57dcce5e8d378e71ed737df5892fd97b3c2cf5be Mon Sep 17 00:00:00 2001 From: otherview Date: Tue, 26 Dec 2023 11:45:17 +0000 Subject: [PATCH 06/13] add geth checks --- .../testnet/layer2/001_whitelist_tokens.ts | 2 +- go/config/enclave_cli_flags.go | 4 +-- integration/common/constants.go | 4 +-- integration/eth2network/eth2_network.go | 36 +++++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/contracts/deployment_scripts/testnet/layer2/001_whitelist_tokens.ts b/contracts/deployment_scripts/testnet/layer2/001_whitelist_tokens.ts index 5a82451c0b..371bea2a10 100644 --- a/contracts/deployment_scripts/testnet/layer2/001_whitelist_tokens.ts +++ b/contracts/deployment_scripts/testnet/layer2/001_whitelist_tokens.ts @@ -122,7 +122,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { return l2Network.deployments.execute("CrossChainMessenger", { from: l2Accounts.deployer, log: true, - gasLimit: 3_000_000 + gasLimit: 5_000_000 }, "relayMessage", msg); }; diff --git a/go/config/enclave_cli_flags.go b/go/config/enclave_cli_flags.go index fe010a30d9..586a9e7c2a 100644 --- a/go/config/enclave_cli_flags.go +++ b/go/config/enclave_cli_flags.go @@ -55,14 +55,14 @@ var EnclaveFlags = map[string]*flag.TenFlag{ MaxRollupSizeFlag: flag.NewUint64Flag(MaxRollupSizeFlag, 1024*64, "The maximum size a rollup is allowed to reach"), L2BaseFeeFlag: flag.NewUint64Flag(L2BaseFeeFlag, 1, ""), L2CoinbaseFlag: flag.NewStringFlag(L2CoinbaseFlag, "0xd6C9230053f45F873Cb66D8A02439380a37A4fbF", ""), - GasBatchExecutionLimit: flag.NewUint64Flag(GasBatchExecutionLimit, 10_000_000, "Max gas that can be executed in a single batch"), + GasBatchExecutionLimit: flag.NewUint64Flag(GasBatchExecutionLimit, 30_000_000, "Max gas that can be executed in a single batch"), ObscuroGenesisFlag: flag.NewStringFlag(ObscuroGenesisFlag, "", "The json string with the obscuro genesis"), L1ChainIDFlag: flag.NewInt64Flag(L1ChainIDFlag, 1337, "An integer representing the unique chain id of the Ethereum chain used as an L1 (default 1337)"), ObscuroChainIDFlag: flag.NewInt64Flag(ObscuroChainIDFlag, 443, "An integer representing the unique chain id of the Obscuro chain (default 443)"), UseInMemoryDBFlag: flag.NewBoolFlag(UseInMemoryDBFlag, true, "Whether the enclave will use an in-memory DB rather than persist data"), ProfilerEnabledFlag: flag.NewBoolFlag(ProfilerEnabledFlag, false, "Runs a profiler instance (Defaults to false)"), DebugNamespaceEnabledFlag: flag.NewBoolFlag(DebugNamespaceEnabledFlag, false, "Whether the debug namespace is enabled"), - GasLocalExecutionCapFlag: flag.NewUint64Flag(GasLocalExecutionCapFlag, 12_000_000, "Max gas usage when executing local transactions"), + GasLocalExecutionCapFlag: flag.NewUint64Flag(GasLocalExecutionCapFlag, 40_000_000, "Max gas usage when executing local transactions"), } // enclaveRestrictedFlags are the flags that the enclave can receive ONLY over the Ego signed enclave.json diff --git a/integration/common/constants.go b/integration/common/constants.go index 45a1462c5b..c255c7b457 100644 --- a/integration/common/constants.go +++ b/integration/common/constants.go @@ -83,7 +83,7 @@ func DefaultEnclaveConfig() *config.EnclaveConfig { MaxRollupSize: 1024 * 64, GasPaymentAddress: gethcommon.HexToAddress("0xd6C9230053f45F873Cb66D8A02439380a37A4fbF"), BaseFee: new(big.Int).SetUint64(1), - GasLocalExecutionCapFlag: 10_000_000, - GasBatchExecutionLimit: 12_000_000, + GasLocalExecutionCapFlag: 40_000_000, + GasBatchExecutionLimit: 30_000_000, } } diff --git a/integration/eth2network/eth2_network.go b/integration/eth2network/eth2_network.go index bc85341365..9849099730 100644 --- a/integration/eth2network/eth2_network.go +++ b/integration/eth2network/eth2_network.go @@ -18,6 +18,8 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ten-protocol/go-ten/integration/datagenerator" "golang.org/x/sync/errgroup" + + gethcommon "github.com/ethereum/go-ethereum/common" ) const ( @@ -206,6 +208,10 @@ func (n *Impl) Start() error { startTime := time.Now() var eg errgroup.Group + if err := n.ensureNoDuplicatedNetwork(); err != nil { + return err + } + // initialize the genesis data on the nodes for _, nodeDataDir := range n.dataDirs { dataDir := nodeDataDir @@ -506,6 +512,11 @@ func (n *Impl) waitForMergeEvent(startTime time.Time) error { } fmt.Printf("Reached the merge block after %s\n", time.Since(startTime)) + + if err = n.prefundedBalancesActive(dial); err != nil { + fmt.Printf("Error prefunding accounts %s\n", err.Error()) + return err + } return nil } @@ -589,6 +600,31 @@ func (n *Impl) gethImportEnodes(enodes []string) error { return nil } +func (n *Impl) prefundedBalancesActive(client *ethclient.Client) error { + for _, addr := range n.preFundedMinerAddrs { + balance, err := client.BalanceAt(context.Background(), gethcommon.HexToAddress(addr), nil) + if err != nil { + return fmt.Errorf("unable to check balance for account %s - %w", addr, err) + } + if balance.Cmp(gethcommon.Big0) == 0 { + return fmt.Errorf("unexpected %s balance for account %s", balance.String(), addr) + } + fmt.Printf("Account %s prefunded with %s", addr, balance.String()) + } + + return nil +} + +func (n *Impl) ensureNoDuplicatedNetwork() error { + for nodeIdx, port := range n.gethWSPorts { + _, err := ethclient.Dial(fmt.Sprintf("ws://127.0.0.1:%d", port)) + if err == nil { + return fmt.Errorf("unexpected geth node %d is active before the network is started", nodeIdx) + } + } + return nil +} + func min(a, b int) int { if a < b { return a From a58c5981ea9d97331cc1ee5c0b641acc7aeebeeb Mon Sep 17 00:00:00 2001 From: otherview Date: Tue, 26 Dec 2023 12:11:05 +0000 Subject: [PATCH 07/13] sleep between first batches --- go/enclave/nodetype/sequencer.go | 1 + 1 file changed, 1 insertion(+) diff --git a/go/enclave/nodetype/sequencer.go b/go/enclave/nodetype/sequencer.go index 318d4adee9..1ef74129f6 100644 --- a/go/enclave/nodetype/sequencer.go +++ b/go/enclave/nodetype/sequencer.go @@ -163,6 +163,7 @@ func (s *sequencer) createGenesisBatch(block *common.L1Block) error { return err } + time.Sleep(5 * time.Second) // produce batch #2 which has the message bus and any other system contracts cb, err := s.produceBatch( big.NewInt(0).Add(batch.Header.SequencerOrderNo, big.NewInt(1)), From d12a5404c9b59f3b920f3fb3beb28fc46fb7b1bd Mon Sep 17 00:00:00 2001 From: otherview Date: Tue, 26 Dec 2023 12:29:29 +0000 Subject: [PATCH 08/13] nits --- integration/common/constants.go | 2 +- integration/common/utils.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/common/constants.go b/integration/common/constants.go index c255c7b457..80d68b5446 100644 --- a/integration/common/constants.go +++ b/integration/common/constants.go @@ -83,7 +83,7 @@ func DefaultEnclaveConfig() *config.EnclaveConfig { MaxRollupSize: 1024 * 64, GasPaymentAddress: gethcommon.HexToAddress("0xd6C9230053f45F873Cb66D8A02439380a37A4fbF"), BaseFee: new(big.Int).SetUint64(1), - GasLocalExecutionCapFlag: 40_000_000, GasBatchExecutionLimit: 30_000_000, + GasLocalExecutionCapFlag: 40_000_000, } } diff --git a/integration/common/utils.go b/integration/common/utils.go index 676e6db689..aabfea5804 100644 --- a/integration/common/utils.go +++ b/integration/common/utils.go @@ -99,7 +99,7 @@ func PrefundWallets(ctx context.Context, faucetWallet wallet.Wallet, faucetClien tx := &types.LegacyTx{ Nonce: startingNonce + uint64(idx), Value: alloc, - Gas: uint64(1_000_000), + Gas: uint64(100_000), GasPrice: gethcommon.Big1, To: &destAddr, } From 30f5fd8e36f5caec38bffd68cfcc679f4ea06514 Mon Sep 17 00:00:00 2001 From: otherview Date: Tue, 26 Dec 2023 12:54:08 +0000 Subject: [PATCH 09/13] . --- go/enclave/nodetype/sequencer.go | 2 +- integration/eth2network/eth2_network.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go/enclave/nodetype/sequencer.go b/go/enclave/nodetype/sequencer.go index 1ef74129f6..1b70086372 100644 --- a/go/enclave/nodetype/sequencer.go +++ b/go/enclave/nodetype/sequencer.go @@ -163,7 +163,7 @@ func (s *sequencer) createGenesisBatch(block *common.L1Block) error { return err } - time.Sleep(5 * time.Second) + time.Sleep(time.Second) // produce batch #2 which has the message bus and any other system contracts cb, err := s.produceBatch( big.NewInt(0).Add(batch.Header.SequencerOrderNo, big.NewInt(1)), diff --git a/integration/eth2network/eth2_network.go b/integration/eth2network/eth2_network.go index 9849099730..19bee3d939 100644 --- a/integration/eth2network/eth2_network.go +++ b/integration/eth2network/eth2_network.go @@ -609,7 +609,7 @@ func (n *Impl) prefundedBalancesActive(client *ethclient.Client) error { if balance.Cmp(gethcommon.Big0) == 0 { return fmt.Errorf("unexpected %s balance for account %s", balance.String(), addr) } - fmt.Printf("Account %s prefunded with %s", addr, balance.String()) + fmt.Printf("Account %s prefunded with %s\n", addr, balance.String()) } return nil From 3bde2ac56292520e6d59fce52299e5750856eae8 Mon Sep 17 00:00:00 2001 From: otherview Date: Tue, 26 Dec 2023 14:53:29 +0000 Subject: [PATCH 10/13] weird get tx count handling --- .github/workflows/build-pr.yml | 1 + go/enclave/enclave.go | 19 +++++++++++-------- .../smartcontract/smartcontracts_test.go | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index d0f61124ee..4d0fe8f8b8 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -44,6 +44,7 @@ jobs: integration/.build/faucet/* integration/.build/obscuroscan/* integration/.build/tengateway/* + integration/.build/smartcontracts/* retention-days: 1 diff --git a/go/enclave/enclave.go b/go/enclave/enclave.go index 5b784c0106..303ac77fa3 100644 --- a/go/enclave/enclave.go +++ b/go/enclave/enclave.go @@ -685,15 +685,18 @@ func (e *enclaveImpl) GetTransactionCount(encryptedParams common.EncryptedParams } var nonce uint64 - l2Head, err := e.storage.FetchBatchBySeqNo(e.registry.HeadBatchSeq().Uint64()) - if err == nil { - // todo - we should return an error when head state is not available, but for current test situations with race - // conditions we allow it to return zero while head state is uninitialized - s, err := e.storage.CreateStateDB(l2Head.Hash()) - if err != nil { - return nil, responses.ToInternalError(err) + headBatch := e.registry.HeadBatchSeq() + if headBatch != nil { + l2Head, err := e.storage.FetchBatchBySeqNo(headBatch.Uint64()) + if err == nil { + // todo - we should return an error when head state is not available, but for current test situations with race + // conditions we allow it to return zero while head state is uninitialized + s, err := e.storage.CreateStateDB(l2Head.Hash()) + if err != nil { + return nil, responses.ToInternalError(err) + } + nonce = s.GetNonce(address) } - nonce = s.GetNonce(address) } encoded := hexutil.EncodeUint64(nonce) diff --git a/integration/smartcontract/smartcontracts_test.go b/integration/smartcontract/smartcontracts_test.go index 1f04054db7..16b99183fc 100644 --- a/integration/smartcontract/smartcontracts_test.go +++ b/integration/smartcontract/smartcontracts_test.go @@ -38,7 +38,7 @@ var testLogs = "../.build/noderunner/" func init() { //nolint:gochecknoinits testlog.Setup(&testlog.Cfg{ LogDir: testLogs, - TestType: "noderunner", + TestType: "smartcontracts", TestSubtype: "test", LogLevel: log.LvlInfo, }) From 6f9c00e9a49b940d01888e9544da64f407c5ca9c Mon Sep 17 00:00:00 2001 From: otherview Date: Tue, 26 Dec 2023 19:26:42 +0000 Subject: [PATCH 11/13] add logs around port reuse --- integration/simulation/network/socket.go | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/integration/simulation/network/socket.go b/integration/simulation/network/socket.go index 874e5c8125..323ddb2fac 100644 --- a/integration/simulation/network/socket.go +++ b/integration/simulation/network/socket.go @@ -1,7 +1,11 @@ package network import ( + "bufio" "fmt" + "os/exec" + "regexp" + "strings" "time" "github.com/ten-protocol/go-ten/integration/noderunner" @@ -112,6 +116,10 @@ func (n *networkOfSocketNodes) Create(simParams *params.SimParams, _ *stats.Stat // start the nodes err = nodes[i].Start() if err != nil { + errCheck := checkProcessPort(err.Error()) + if errCheck != nil { + testlog.Logger().Warn("no port found on error", log.ErrKey, err) + } testlog.Logger().Crit("unable to start obscuro node ", log.ErrKey, err) } } @@ -181,3 +189,35 @@ func (n *networkOfSocketNodes) createConnections(simParams *params.SimParams) er } return nil } + +// getProcessesUsingPort returns a slice of process details using the specified port. +func checkProcessPort(errPort string) error { + re := regexp.MustCompile(`:(\d+):`) + matches := re.FindStringSubmatch(errPort) + + if len(matches) < 2 { + return fmt.Errorf("no port found in string") + } + + port := matches[1] + + cmd := exec.Command("lsof", "-i", fmt.Sprintf(":%s", port)) //nolint:gosec + + output, err := cmd.Output() + if err != nil { + return err + } + + var processes []string + scanner := bufio.NewScanner(strings.NewReader(string(output))) + for scanner.Scan() { + line := scanner.Text() + if strings.Contains(line, "LISTEN") || strings.Contains(line, "ESTABLISHED") { + processes = append(processes, line) + } + } + + fmt.Printf("Found processes still opened on port %s - %+v\n", port, processes) + + return nil +} From c540313821d7dd4d9bd009a8f18791dc3a0fd2ab Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 27 Dec 2023 11:03:37 +0000 Subject: [PATCH 12/13] Update go/enclave/nodetype/sequencer.go --- go/enclave/nodetype/sequencer.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go/enclave/nodetype/sequencer.go b/go/enclave/nodetype/sequencer.go index 1b70086372..85975994c7 100644 --- a/go/enclave/nodetype/sequencer.go +++ b/go/enclave/nodetype/sequencer.go @@ -163,6 +163,8 @@ func (s *sequencer) createGenesisBatch(block *common.L1Block) error { return err } + // errors in unit test seem to suggest that batch 2 was received before batch 1 + // this ensures that there is enough gap so that batch 1 is issued before batch 2 time.Sleep(time.Second) // produce batch #2 which has the message bus and any other system contracts cb, err := s.produceBatch( From 7bad38ddf89f66586076790a7d8c70e7b811e44f Mon Sep 17 00:00:00 2001 From: otherview Date: Wed, 27 Dec 2023 11:08:25 +0000 Subject: [PATCH 13/13] lint --- go/enclave/nodetype/sequencer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go/enclave/nodetype/sequencer.go b/go/enclave/nodetype/sequencer.go index 85975994c7..0fe421f1a3 100644 --- a/go/enclave/nodetype/sequencer.go +++ b/go/enclave/nodetype/sequencer.go @@ -163,8 +163,8 @@ func (s *sequencer) createGenesisBatch(block *common.L1Block) error { return err } - // errors in unit test seem to suggest that batch 2 was received before batch 1 - // this ensures that there is enough gap so that batch 1 is issued before batch 2 + // errors in unit test seem to suggest that batch 2 was received before batch 1 + // this ensures that there is enough gap so that batch 1 is issued before batch 2 time.Sleep(time.Second) // produce batch #2 which has the message bus and any other system contracts cb, err := s.produceBatch(