Update coordinator to work better under real net

- 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`
This commit is contained in:
Eduard S
2021-01-15 19:37:39 +01:00
parent 168432c559
commit 70482605c4
20 changed files with 664 additions and 308 deletions

View File

@@ -169,7 +169,9 @@ func TestRollupForgeBatch(t *testing.T) {
args.ProofC[1] = big.NewInt(0)
argsForge = args
_, err = rollupClient.RollupForgeBatch(argsForge)
auth, err := rollupClient.client.NewAuth()
require.NoError(t, err)
_, err = rollupClient.RollupForgeBatch(argsForge, auth)
require.NoError(t, err)
currentBlockNum, err = rollupClient.client.EthLastBlock()
@@ -818,7 +820,9 @@ func TestRollupL1UserTxERC20PermitForceExit(t *testing.T) {
func TestRollupForgeBatch2(t *testing.T) {
// Forge Batch 2
_, err := rollupClient.RollupForgeBatch(argsForge)
auth, err := rollupClient.client.NewAuth()
require.NoError(t, err)
_, err = rollupClient.RollupForgeBatch(argsForge, auth)
require.NoError(t, err)
currentBlockNum, err := rollupClient.client.EthLastBlock()
require.NoError(t, err)
@@ -871,7 +875,9 @@ func TestRollupForgeBatch2(t *testing.T) {
argsForge = args
_, err = rollupClient.RollupForgeBatch(argsForge)
auth, err = rollupClient.client.NewAuth()
require.NoError(t, err)
_, err = rollupClient.RollupForgeBatch(argsForge, auth)
require.NoError(t, err)
currentBlockNum, err = rollupClient.client.EthLastBlock()