Update txs constructors and helpers

For each tx, move the logic of setting the Type and TxID to separate functions,
so that they can be called when necessary.

In synchronizer, set all the required fields using the `SetID` and `SetType`
for l2txs when needed.  This is necessary because the `ProcessTxs()` works with
`common.PoolL2Tx`, which misses some fields from `common.L2Tx`, and because
`ProcessTxs()` needs the Type to be set, but at the same time `ProcessTxs()`
sets the Nonce, which is required for the `TxID`.
This commit is contained in:
Eduard S
2020-12-16 15:25:55 +01:00
parent 61255d730c
commit 7a30294688
6 changed files with 207 additions and 157 deletions

View File

@@ -882,6 +882,9 @@ func (tc *Context) FillBlocksExtra(blocks []common.BlockData, cfg *ConfigExtra)
position++
tc.extra.nonces[tx.FromIdx]++
tx.Nonce = tc.extra.nonces[tx.FromIdx]
if err := tx.SetID(); err != nil {
return err
}
nTx, err := common.NewL2Tx(tx)
if err != nil {
return tracerr.Wrap(err)