diff --git a/integration/simulation/transaction_injector.go b/integration/simulation/transaction_injector.go index 497470a86c..66e142abc9 100644 --- a/integration/simulation/transaction_injector.go +++ b/integration/simulation/transaction_injector.go @@ -141,10 +141,10 @@ func (ti *TransactionInjector) Start() { }) } - wg.Go(func() error { + /*wg.Go(func() error { ti.issueRandomTransfers() return nil - }) + })*/ //todo - fix wg.Go(func() error { ti.issueRandomValueTransfers() @@ -219,7 +219,7 @@ func (ti *TransactionInjector) issueRandomTransfers() { for len(ti.wallets.SimObsWallets) > 1 && fromWallet.Address().Hex() == toWallet.Address().Hex() { toWallet = ti.rndObsWallet() } - tx := ti.newObscuroTransferTx(fromWallet, toWallet.Address(), testcommon.RndBtw(1, 500)) + tx := ti.newObscuroTransferTx(fromWallet, toWallet.Address(), testcommon.RndBtw(1, 500), testcommon.HOC) tx = obscuroClient.EstimateGasAndGasPrice(tx) signedTx, err := fromWallet.SignTransaction(tx) if err != nil { @@ -287,24 +287,22 @@ func (ti *TransactionInjector) bridgeRandomGasTransfers() { func (ti *TransactionInjector) issueRandomDeposits() { // todo (@stefan) - this implementation transfers from the hoc and poc owner contracts // a better implementation should use the bridge - fromWalletHoc := ti.wallets.Tokens[testcommon.HOC].L2Owner - fromWalletPoc := ti.wallets.Tokens[testcommon.POC].L2Owner - for txCounter := 0; ti.shouldKeepIssuing(txCounter); txCounter++ { - fromWallet := fromWalletHoc + fromWalletToken := testcommon.HOC if txCounter%2 == 0 { - fromWallet = fromWalletPoc + fromWalletToken = testcommon.POC } + fromWallet := ti.wallets.Tokens[fromWalletToken].L2Owner toWallet := ti.rndObsWallet() obscuroClient := ti.rpcHandles.ObscuroWalletRndClient(fromWallet) v := testcommon.RndBtw(500, 2000) - tx := ti.newObscuroTransferTx(fromWallet, toWallet.Address(), v) - tx = obscuroClient.EstimateGasAndGasPrice(tx) + txData := ti.newObscuroTransferTx(fromWallet, toWallet.Address(), v, fromWalletToken) + tx := obscuroClient.EstimateGasAndGasPrice(txData) signedTx, err := fromWallet.SignTransaction(tx) if err != nil { panic(err) } - ti.logger.Info("Deposit transaction injected into L2.", log.TxKey, signedTx.Hash(), "fromAddress", fromWallet.Address(), "toAddress", toWallet.Address()) + ti.logger.Info("Deposit transaction injected into L2.", log.TxKey, signedTx.Hash(), "fromAddress", fromWallet.Address(), "toAddress", toWallet.Address()) ti.stats.Deposit(big.NewInt(int64(v))) @@ -337,8 +335,9 @@ func (ti *TransactionInjector) issueInvalidL2Txs() { for len(ti.wallets.SimObsWallets) > 1 && fromWallet.Address().Hex() == toWallet.Address().Hex() { toWallet = ti.rndObsWallet() } - tx := ti.newCustomObscuroWithdrawalTx(testcommon.RndBtw(1, 100)) + txData := ti.newCustomObscuroWithdrawalTx(testcommon.RndBtw(1, 100)) + tx := ti.rpcHandles.ObscuroWalletRndClient(fromWallet).EstimateGasAndGasPrice(txData) signedTx := ti.createInvalidSignage(tx, fromWallet) err := ti.rpcHandles.ObscuroWalletRndClient(fromWallet).SendTransaction(ti.ctx, signedTx) @@ -368,24 +367,24 @@ func (ti *TransactionInjector) rndObsWallet() wallet.Wallet { return ti.wallets.SimObsWallets[rand.Intn(len(ti.wallets.SimObsWallets))] //nolint:gosec } -func (ti *TransactionInjector) newObscuroTransferTx(from wallet.Wallet, dest gethcommon.Address, amount uint64) types.TxData { +func (ti *TransactionInjector) newObscuroTransferTx(from wallet.Wallet, dest gethcommon.Address, amount uint64, ercType testcommon.ERC20) types.TxData { data := erc20contractlib.CreateTransferTxData(dest, common.ValueInWei(big.NewInt(int64(amount)))) - return ti.newTx(data, from.GetNonceAndIncrement()) + return ti.newTx(data, from.GetNonceAndIncrement(), ercType) } func (ti *TransactionInjector) newCustomObscuroWithdrawalTx(amount uint64) types.TxData { transferERC20data := erc20contractlib.CreateTransferTxData(testcommon.BridgeAddress, common.ValueInWei(big.NewInt(int64(amount)))) - return ti.newTx(transferERC20data, 1) + return ti.newTx(transferERC20data, 1, testcommon.HOC) } -func (ti *TransactionInjector) newTx(data []byte, nonce uint64) types.TxData { +func (ti *TransactionInjector) newTx(data []byte, nonce uint64, ercType testcommon.ERC20) types.TxData { return &types.LegacyTx{ Nonce: nonce, Value: gethcommon.Big0, Gas: uint64(1_000_000), GasPrice: gethcommon.Big1, Data: data, - To: ti.wallets.Tokens[testcommon.HOC].L2ContractAddress, + To: ti.wallets.Tokens[ercType].L2ContractAddress, } } diff --git a/integration/simulation/transaction_injector_tracker.go b/integration/simulation/transaction_injector_tracker.go index b0fe77dab5..b1c36a1247 100644 --- a/integration/simulation/transaction_injector_tracker.go +++ b/integration/simulation/transaction_injector_tracker.go @@ -62,7 +62,7 @@ func (m *txInjectorTracker) trackTransferL2Tx(tx *common.L2Tx) { func (m *txInjectorTracker) trackNativeValueTransferL2Tx(tx *common.L2Tx) { m.l2TransactionsLock.Lock() defer m.l2TransactionsLock.Unlock() - m.NativeValueTransferL2Transactions = append(m.TransferL2Transactions, tx) + m.NativeValueTransferL2Transactions = append(m.NativeValueTransferL2Transactions, tx) } // GetL1Transactions returns all generated L1 L2Txs diff --git a/tools/hardhatdeployer/obscuro_deployer.go b/tools/hardhatdeployer/obscuro_deployer.go index a3e4153e75..c3ab1b9cea 100644 --- a/tools/hardhatdeployer/obscuro_deployer.go +++ b/tools/hardhatdeployer/obscuro_deployer.go @@ -60,13 +60,14 @@ func fundDeployerWithFaucet(cfg *Config, client *obsclient.AuthObsClient, logger } destAddr := client.Address() - tx := &types.LegacyTx{ + txData := &types.LegacyTx{ Nonce: nonce, Value: big.NewInt(Prealloc), Gas: uint64(1_000_000), GasPrice: gethcommon.Big1, To: &destAddr, } + tx := faucetClient.EstimateGasAndGasPrice(txData) signedTx, err := faucetWallet.SignTransaction(tx) if err != nil { return fmt.Errorf("failed to sign faucet transaction: %w", err)