shutter-network/rolling-shutter

Collator: initiate `shutter_submitBatch` on new decryption-keys

ezdac opened this issue · 2 comments

ezdac commented

A parallel process has to constanly check for new values of cltrdb.decryption_key (see #333 ).
Whenever there is a new key that corresponds with the last closed batch, the process has to:

  • retrieve all committed on shutter-transactions from the DB for that epoch
  • construct a new BatchTx including the rlp-encoded shutter-transactions, the determined l1-block-number (see #336 ), decryption key and additional metadata :
    type BatchTx struct {
        ChainID       *big.Int
        DecryptionKey []byte
        BatchIndex    uint64
        L1BlockNumber uint64
        Timestamp     *big.Int
        Transactions  [][]byte
    }
  • submit the RLP encoded and signed BatchTx to the shutter_submitBatch JSON RPC endpoint at the sequencer
  • eventually listen on the shutter_batchIndex endpoint to wait for successful submission of the batch
ezdac commented

#331 might be relevant for this to have a look at the reference implementation of the shutter_submitBatch method.
This test

batchTxInner := txtypes.BatchTx{
ChainID: fixtures.ChainID,
DecryptionKey: epochSecretKey.Marshal(),
BatchIndex: nextBatchIndex,
L1BlockNumber: l1BlockNumber,
Timestamp: big.NewInt(time.Now().Unix()),
Transactions: [][]byte{shtxBytes},
}
batchTx, err := txtypes.SignNewTx(fixtures.PrivkeyCollator, fixtures.Signer, &batchTxInner)
calls that method and sends a batch to the endpoint

Implemented in collator/batchsubmission.go