mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-06 19:06:42 +01:00
Set l1tx.EffectiveFromIdx in TxProcessor and til
This commit is contained in:
@@ -180,6 +180,7 @@ type SCConsts struct {
|
||||
// Config is the Synchronizer configuration
|
||||
type Config struct {
|
||||
StatsRefreshPeriod time.Duration
|
||||
ChainID uint16
|
||||
}
|
||||
|
||||
// Synchronizer implements the Synchronizer type
|
||||
@@ -797,17 +798,21 @@ func (s *Synchronizer) rollupSync(ethBlock *common.Block) (*common.RollupData, e
|
||||
// Transform L2 txs to PoolL2Txs
|
||||
poolL2Txs := common.L2TxsToPoolL2Txs(forgeBatchArgs.L2TxsData) // NOTE: This is a big ugly, find a better way
|
||||
|
||||
// ProcessTxs updates poolL2Txs adding: Nonce (and also TokenID, but we don't use it).
|
||||
//nolint:gomnd
|
||||
tpc := txprocessor.Config{ // TODO TMP
|
||||
NLevels: 32,
|
||||
MaxFeeTx: 64,
|
||||
MaxTx: 512,
|
||||
MaxL1Tx: 64,
|
||||
ChainID: uint16(0),
|
||||
if int(forgeBatchArgs.VerifierIdx) >= len(s.consts.Rollup.Verifiers) {
|
||||
return nil, tracerr.Wrap(fmt.Errorf("forgeBatchArgs.VerifierIdx (%v) >= "+
|
||||
" len(s.consts.Rollup.Verifiers) (%v)",
|
||||
forgeBatchArgs.VerifierIdx, len(s.consts.Rollup.Verifiers)))
|
||||
}
|
||||
tpc := txprocessor.Config{
|
||||
NLevels: uint32(s.consts.Rollup.Verifiers[forgeBatchArgs.VerifierIdx].NLevels),
|
||||
MaxTx: uint32(s.consts.Rollup.Verifiers[forgeBatchArgs.VerifierIdx].MaxTx),
|
||||
ChainID: s.cfg.ChainID,
|
||||
MaxFeeTx: common.RollupConstMaxFeeIdxCoordinator,
|
||||
MaxL1Tx: common.RollupConstMaxL1Tx,
|
||||
}
|
||||
tp := txprocessor.NewTxProcessor(s.stateDB, tpc)
|
||||
|
||||
// ProcessTxs updates poolL2Txs adding: Nonce (and also TokenID, but we don't use it).
|
||||
processTxsOut, err := tp.ProcessTxs(forgeBatchArgs.FeeIdxCoordinator,
|
||||
l1UserTxs, batchData.L1CoordinatorTxs, poolL2Txs)
|
||||
if err != nil {
|
||||
|
||||
@@ -98,6 +98,11 @@ func checkSyncBlock(t *testing.T, s *Synchronizer, blockNum int, block, syncBloc
|
||||
tx.Position == _dbTx.Position {
|
||||
dbTx = new(common.L1Tx)
|
||||
*dbTx = _dbTx
|
||||
// NOTE: Overwrite EffectiveFromIdx in L1UserTx
|
||||
// from db because we don't expect
|
||||
// EffectiveFromIdx to be set yet, as this tx
|
||||
// is not in yet forged
|
||||
dbTx.EffectiveFromIdx = 0
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -142,7 +147,18 @@ func checkSyncBlock(t *testing.T, s *Synchronizer, blockNum int, block, syncBloc
|
||||
batch.Batch.NumAccounts = len(batch.CreatedAccounts)
|
||||
|
||||
// Test field by field to facilitate debugging of errors
|
||||
assert.Equal(t, len(batch.L1UserTxs), len(syncBatch.L1UserTxs))
|
||||
// NOTE: EffectiveFromIdx is set to til L1UserTxs in
|
||||
// `FillBlocksForgedL1UserTxs` function
|
||||
for j := range syncBatch.L1UserTxs {
|
||||
assert.NotEqual(t, 0, syncBatch.L1UserTxs[j].EffectiveFromIdx)
|
||||
}
|
||||
assert.Equal(t, batch.L1UserTxs, syncBatch.L1UserTxs)
|
||||
// NOTE: EffectiveFromIdx is set to til L1CoordinatorTxs in
|
||||
// `FillBlocksExtra` function
|
||||
for j := range syncBatch.L1CoordinatorTxs {
|
||||
assert.NotEqual(t, 0, syncBatch.L1CoordinatorTxs[j].EffectiveFromIdx)
|
||||
}
|
||||
assert.Equal(t, batch.L1CoordinatorTxs, syncBatch.L1CoordinatorTxs)
|
||||
assert.Equal(t, batch.L2Txs, syncBatch.L2Txs)
|
||||
// In exit tree, we only check AccountIdx and Balance, because
|
||||
|
||||
Reference in New Issue
Block a user