- KVDB/StateDB
- Pass config parameters in a Config type instead of using many
arguments in constructor.
- Add new parameter `NoLast` which disables having an opened DB with a
checkpoint to the last batchNum for thread-safe reads. Last will be
disabled in the StateDB used by the TxSelector and BatchBuilder.
- Add new parameter `NoGapsCheck` which skips checking gaps in the list
of checkpoints and returning errors if there are gaps. Gaps check
will be disabled in the StateDB used by the TxSelector and
BatchBuilder, because we expect to have gaps when there are multiple
coordinators forging (slots not forged by our coordinator will leave
gaps).
- kvdb
- Fix path in Last when doing `setNew`
- Only close if db != nil, and after closing, always set db to nil
- This will avoid a panic in the case where the db is closed but
there's an error soon after, and a future call tries to close
again. This is because pebble.Close() will panic if the db is
already closed.
- Avoid calling pebble methods when a the Storage interface already
implements that method (like Close).
- statedb
- In test, avoid calling KVDB method if the same method is available for
the StateDB (like MakeCheckpoint, CurrentBatch).
- eth
- In *EventByBlock methods, take blockHash as input argument and use it
when querying the event logs. Previously the blockHash was only taken
from the logs results *only if* there was any log. This caused the
following issue: if there was no logs, it was not possible to know if
the result was from the expected block or an uncle block! By querying
logs by blockHash we make sure that even if there are no logs, they
are from the right block.
- Note that now the function can either be called with a
blockNum or blockHash, but not both at the same time.
- sync
- If there's an error during call to Sync call resetState, which
internally resets the stateDB to avoid stale checkpoints (and a
corresponding invalid increase in the StateDB batchNum).
- During a Sync, after very batch processed, make sure that the StateDB
currentBatch corresponds to the batchNum in the smart contract
log/event.
Last db view is an opened pebble db which always contains a checkpoint from the
last batch. Methods to access this last batch are thread safe so that views of
the last checkpoint can be made anywhere and with a consistent view of the
state.
PoolL2Tx.Info contains information about the status & State of the
transaction. As for example, if the Tx has not been selected in the last
batch due not enough Balance at the Sender account, this reason would
appear at this parameter.
This will help the client (wallet, batchexplorer, etc) to reason why a
L2Tx is not selected in the forged batches.
- Close StateDB when stopping the node
- Lock the StateDB when doing checkpoints to avoid multiple instances of
oppening the pebble DB at the same time.
L2Tx.TokenID is not on the data obtained by the Synchronizer from the
blockchain, but is set by the TxProcessor when processing the
transactions in the StateDB.
- cli / node
- Update handler of SIGINT so that after 3 SIGINTs, the process terminates
unconditionally
- coordinator
- Store stats without pointer
- In all functions that send a variable via channel, check for context done
to avoid deadlock (due to no process reading from the channel, which has
no queue) when the node is stopped.
- Abstract `canForge` so that it can be used outside of the `Coordinator`
- In `canForge` check the blockNumber in current and next slot.
- Update tests due to smart contract changes in slot handling, and minimum
bid defaults
- TxManager
- Add consts, vars and stats to allow evaluating `canForge`
- Add `canForge` method (not used yet)
- Store batch and nonces status (last success and last pending)
- Track nonces internally instead of relying on the ethereum node (this
is required to work with ganache when there are pending txs)
- Handle the (common) case of the receipt not being found after the tx
is sent.
- Don't start the main loop until we get an initial messae fo the stats
and vars (so that in the loop the stats and vars are set to
synchronizer values)
- eth / ethereum client
- Add necessary methods to create the auth object for transactions manually
so that we can set the nonce, gas price, gas limit, etc manually
- Update `RollupForgeBatch` to take an auth object as input (so that the
coordinator can set parameters manually)
- synchronizer
- In stats, add `NextSlot`
- Add tests connecting TxSelector, BatchBuilder, ZKInputs, ProofServer
- Added test to check that the signatures of the PoolL2Txs from the L2DB
pool can be verified, to check that the parameters of the PoolL2Tx match
the original parameters signed before inserting them into the L2DB
- Node
- Load Coordinator Fee Account from config
- Sign the AccountCreationMsg to generate the
AccountCreationAuth
- Resolve#465
- Wait for synchronizer termination before stopping coordinator to avoid
getting stuck when closing in the following case:
- The coordinator stops reading the synchronizer msg channel,
and the node gets stuck sending a message to that channel.
- Common
- Move account creation auth signature code to common.
- Update RollupConstInputSHAConstantBytes
- Coordinator
- Set batch status in the debug file
- Propagate SCVariables on reorg
- Pipeline: Get SCVariables updates
- Resolve#457
- Fix off by 1 error in Pipeline.shouldL1L2Batch() (which shouldn't have
caused any problem, but it was not right)
- KVDB
- Delete future checkpoints after reset
- In `ResetFromSynchronizer`, remove all checkpoints first, and follow
the same logic as `reset()`.
- Cli
- Add command to generate a BabyJubJub key pair (to be used for the
Coordinator Fee Account)
- Node
- Adjust example config `Coordinator.L1BatchTimeoutPerc` to avoid
missing the L1Batch deadline with the following setup:
- a block is mined every 2 seconds
- single proof server that takes 2 seconds to calculate a proof
- TxProcessor
- Close temporary pebble used for the exit tree after usage.
- Resolve#463
- Upgrade go-merkletree version to include the last changes of Pebble
that fixes the cgo issues (which should fix#453), from:
c2b05f12d7
- TxSelector
- Remove parameter batchNum for GetL2TxSelection & GetL1L2TxSelection
- Add checks of ToBJJ & ToEthAddr when ToIdx>255
- Avoid getting the sender account twice to get the TokenID of a l2tx
- Add test to check that selected L2Txs are sorted by Nonce
- Discard L2Tx that return error at ProcessL2Txs
- executed `go mod tidy`
- StateDB
- Update GetIdxByEthAddrBJJ to return ErrToIdxNotFound when idx not found, so can be checked at upper levels
- TxSelector
- rm CoordIdxsDB that is no longer needed (also related methods)
- add `getCoordIdx` method to get the Coordinator Idx for a given TokenID
- Update coordinator account creation related to new TokenIDs from L2Txs
- Reorganize GetL1L2TxSelection
- return CoordIdxs used in the selection
- Update go-merkletree version which avoids marshaling Siblings to json
with 'null' value in case of empty array
- Refactor the migrations code so that packr is only called (via an init
function in `db/utils.go`).
- When loading the migrations, make sure there is at least one migration,
otherwise panic (this would happen if the node is built incorrectly)
Load an ethereum keystore when the node is started in coordinator mode. The
private key corresponding to the forger address must be imported into the
keystore before running the node in coordinator mode. You can see an examples
in `cli/node/load-sk-example.sh`.
On the Circuits uses the name `nTx` (and on the tests `maxTx`), but
Contracts `maxTx`. On Go we had both variables, but really only used
one, now at Go we use `MaxTx` to refer to the maximum number of
transactions.
Introduce a constructor parameter for the StateDB called `keep`, which tells
how many checkpoints to keep. When doing a new checkpoint, if the number of
existing checkpoints exeeds `keep`, the oldest ones will be deleted.
- Fix AccountCreationAuth.HashToSign (was using `[]byte("0x...")`, which
uses the bytes of the string. Now uses the bytearray of the compressed
BJJ public key (compatible with js implementation))
- Update AccountCreationAuth to last specification (add to hash
parameters ChainID & HermezAddress)
- Add missing test to AccountCreationAuth
Previously the coordinator was erroneously using Slot.BatchesLen to determine
when anyone can forge. The correct behaviour is implmenented with the boolean
flag `ForgerCommitment`, that is set to true only when there's a batch before
the deadline within a slot.
Delete Slot.BatchesLen, and the synchronization code of this value from the
Synchronizer, as this is not needed
- Implement Pipeline.prepareForgeBatchArgs()
- Add a minimal stress test for the coordinator (that also runs the
synchronizer)
- Update txprocessor.ProcessTxs() to return valid results for batches without
transactions
- Add the boilerplate for the corresponding test, leaving as TODO the
zkInput values
- Update prover client to use the same point format as proof server (projective)
- Update interface of TxSelector.GetCoordIdxs to also return the authorizations
to create accounts that go with the l1CoordinatorTxs.