Skip to content

Commit

Permalink
Revert "Revert "change mempool validation function (#1800)""
Browse files Browse the repository at this point in the history
This reverts commit 380aa52.
  • Loading branch information
StefanIliev545 committed Feb 26, 2024
1 parent 380aa52 commit cf36607
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
4 changes: 2 additions & 2 deletions go/enclave/nodetype/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (s *sequencer) createGenesisBatch(block *common.L1Block) error {
// this is the actual first block produced in chain
err = s.blockchain.IngestNewBlock(batch)
if err != nil {
return fmt.Errorf("unable to remove ingest new block into eth blockchain - %w", err)
return fmt.Errorf("failed to feed batch into the virtual eth chain - %w", err)
}

// the mempool can only be started after at least 1 block is in the blockchain object
Expand Down Expand Up @@ -283,7 +283,7 @@ func (s *sequencer) produceBatch(
// add the batch to the chain so it can remove pending transactions from the pool
err = s.blockchain.IngestNewBlock(cb.Batch)
if err != nil {
return nil, fmt.Errorf("unable to remove tx from mempool - %w", err)
return nil, fmt.Errorf("failed to feed batch into the virtual eth chain - %w", err)
}

return cb, nil
Expand Down
4 changes: 4 additions & 0 deletions go/enclave/nodetype/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ func (val *obsValidator) ExecuteStoredBatches() error {
if err != nil {
return fmt.Errorf("could not store executed batch %s. Cause: %w", batch.Hash(), err)
}
err = val.mempool.Chain.IngestNewBlock(batch)
if err != nil {
return fmt.Errorf("failed to feed batch into the virtual eth chain- %w", err)
}
val.batchRegistry.OnBatchExecuted(batch, receipts)
}
}
Expand Down
13 changes: 6 additions & 7 deletions go/enclave/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type TxPool struct {
txPoolConfig legacypool.Config
legacyPool *legacypool.LegacyPool
pool *gethtxpool.TxPool
blockchain *ethchainadapter.EthChainAdapter
Chain *ethchainadapter.EthChainAdapter
gasTip *big.Int
running bool
stateMutex sync.Mutex
Expand All @@ -39,7 +39,7 @@ func NewTxPool(blockchain *ethchainadapter.EthChainAdapter, gasTip *big.Int, log
legacyPool := legacypool.New(txPoolConfig, blockchain)

return &TxPool{
blockchain: blockchain,
Chain: blockchain,
txPoolConfig: txPoolConfig,
legacyPool: legacyPool,
gasTip: gasTip,
Expand All @@ -55,7 +55,7 @@ func (t *TxPool) Start() error {
return fmt.Errorf("tx pool already started")
}

memp, err := gethtxpool.New(t.gasTip, t.blockchain, []gethtxpool.SubPool{t.legacyPool})
memp, err := gethtxpool.New(t.gasTip, t.Chain, []gethtxpool.SubPool{t.legacyPool})
if err != nil {
return fmt.Errorf("unable to init geth tx pool - %w", err)
}
Expand Down Expand Up @@ -88,9 +88,11 @@ func (t *TxPool) Add(transaction *common.L2Tx) error {
//go:linkname validateTxBasics github.com/ethereum/go-ethereum/core/txpool/legacypool.(*LegacyPool).validateTxBasics
func validateTxBasics(_ *legacypool.LegacyPool, _ *types.Transaction, _ bool) error

//go:linkname validateTx github.com/ethereum/go-ethereum/core/txpool/legacypool.(*LegacyPool).validateTx
func validateTx(_ *legacypool.LegacyPool, _ *types.Transaction, _ bool) error

// Validate - run the underlying tx pool validation logic
func (t *TxPool) Validate(tx *common.L2Tx) error {
<<<<<<< HEAD
// validate against the consensus rules
err := validateTxBasics(t.legacyPool, tx, false)
if err != nil {
Expand All @@ -101,9 +103,6 @@ func (t *TxPool) Validate(tx *common.L2Tx) error {
defer t.stateMutex.Unlock()
// validate against the state. Things like nonce, balance, etc
return validateTx(t.legacyPool, tx, false)
=======
return validateTxBasics(t.legacyPool, tx, false)
>>>>>>> parent of 3a74586b (change mempool validation function (#1800))
}

func (t *TxPool) Running() bool {
Expand Down
1 change: 1 addition & 0 deletions integration/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func PrefundWallets(ctx context.Context, faucetWallet wallet.Wallet, faucetClien
txHashes := make([]gethcommon.Hash, len(wallets))
for idx, w := range wallets {
destAddr := w.Address()
fmt.Printf("L2 prefund: %s\n", destAddr.Hex())
txData := &types.LegacyTx{
Nonce: startingNonce + uint64(idx),
Value: alloc,
Expand Down
4 changes: 2 additions & 2 deletions integration/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package integration
// Tracks the start ports handed out to different tests, in a bid to minimise conflicts.
const (
StartPortEth2NetworkTests = 10000
StartPortTenscanUnitTest = 12000
StartPortNodeRunnerTest = 14000
StartPortTenGatewayUnitTest = 16000
StartPortSimulationGethInMem = 18000
StartPortSimulationInMem = 22000
StartPortSimulationFullNetwork = 26000
Expand All @@ -13,8 +15,6 @@ const (
StartPortWalletExtensionUnitTest = 38000
StartPortFaucetUnitTest = 42000
StartPortFaucetHTTPUnitTest = 48000
StartPortTenscanUnitTest = 52000
StartPortTenGatewayUnitTest = 56000

DefaultGethWSPortOffset = 100
DefaultGethAUTHPortOffset = 200
Expand Down
15 changes: 10 additions & 5 deletions integration/simulation/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ func (s *Simulation) Start() {
s.bridgeFundingToObscuro()
s.trackLogs() // Create log subscriptions, to validate that they're working correctly later.
s.prefundObscuroAccounts() // Prefund every L2 wallet
s.deployObscuroERC20s() // Deploy the Obscuro HOC and POC ERC20 contracts
s.prefundL1Accounts() // Prefund every L1 wallet
s.checkHealthStatus() // Checks the nodes health status

// wait for the validator to become up to date
time.Sleep(1 * time.Second)
s.deployObscuroERC20s() // Deploy the Obscuro HOC and POC ERC20 contracts
s.prefundL1Accounts() // Prefund every L1 wallet
s.checkHealthStatus() // Checks the nodes health status

timer := time.Now()
fmt.Printf("Starting injection\n")
Expand Down Expand Up @@ -229,6 +232,7 @@ func (s *Simulation) deployObscuroERC20s() {
// 0x526c84529b2b8c11f57d93d3f5537aca3aecef9b - this is the address of the L2 contract which is currently hardcoded.
contractBytes := erc20contract.L2BytecodeWithDefaultSupply(string(token), gethcommon.HexToAddress("0x526c84529b2b8c11f57d93d3f5537aca3aecef9b"))

fmt.Printf("Deploy contract from: %s\n", owner.Address().Hex())
deployContractTxData := types.DynamicFeeTx{
Nonce: NextNonce(s.ctx, s.RPCHandles, owner),
Gas: 5_000_000,
Expand All @@ -243,12 +247,13 @@ func (s *Simulation) deployObscuroERC20s() {
panic(err)
}

err = s.RPCHandles.ObscuroWalletRndClient(owner).SendTransaction(s.ctx, signedTx)
rpc := s.RPCHandles.ObscuroWalletClient(owner.Address(), 1)
err = rpc.SendTransaction(s.ctx, signedTx)
if err != nil {
panic(err)
}

err = testcommon.AwaitReceipt(s.ctx, s.RPCHandles.ObscuroWalletRndClient(owner), signedTx.Hash(), s.Params.ReceiptTimeout)
err = testcommon.AwaitReceipt(s.ctx, rpc, signedTx.Hash(), s.Params.ReceiptTimeout)
if err != nil {
panic(fmt.Sprintf("ERC20 deployment transaction unsuccessful. Cause: %s", err))
}
Expand Down

0 comments on commit cf36607

Please sign in to comment.