Update missing parts, improve til, and more

- Node
	- Updated configuration to initialize the interface to all the smart
	  contracts
- Common
	- Moved BlockData and BatchData types to common so that they can be
	  shared among: historydb, til and synchronizer
	- Remove hash.go (it was never used)
	- Remove slot.go (it was never used)
	- Remove smartcontractparams.go (it was never used, and appropriate
	  structs are defined in `eth/`)
	- Comment state / status method until requirements of this method are
	  properly defined, and move it to Synchronizer
- Synchronizer
	- Simplify `Sync` routine to only sync one block per call, and return
	  useful information.
	- Use BlockData and BatchData from common
	- Check that events belong to the expected block hash
	- In L1Batch, query L1UserTxs from HistoryDB
	- Fill ERC20 token information
	- Test AddTokens with test.Client
- HistryDB
	- Use BlockData and BatchData from common
	- Add `GetAllTokens` method
	- Uncomment and update GetL1UserTxs (with corresponding tests)
- Til
	- Rename all instances of RegisterToken to AddToken (to follow the smart
	  contract implementation naming)
	- Use BlockData and BatchData from common
		- Move testL1CoordinatorTxs and testL2Txs to a separate struct
		  from BatchData in Context
	- Start Context with BatchNum = 1 (which the protocol defines to be the
	  first batchNum)
	- In every Batch, set StateRoot and ExitRoot to a non-nil big.Int
	  (zero).
	- In all L1Txs, if LoadAmount is not used, set it to 0; if Amount is not
	  used, set it to 0; so that no *big.Int is nil.
	- In L1UserTx, don't set BatchNum, because when L1UserTxs are created
	  and obtained by the synchronizer, the BatchNum is not known yet (it's
	  a synchronizer job to set it)
	- In L1UserTxs, set `UserOrigin` and set `ToForgeL1TxsNum`.
This commit is contained in:
Eduard S
2020-10-09 12:54:16 +02:00
parent 24bca9e3b0
commit 827e917fa0
23 changed files with 739 additions and 547 deletions

View File

@@ -60,11 +60,11 @@ func GenBatches(nBatches int, blocks []common.Block) []common.Batch {
//nolint:gomnd
ForgerAddr: ethCommon.BigToAddress(big.NewInt(6886723)),
CollectedFees: collectedFees,
StateRoot: common.Hash([]byte("duhdqlwiucgwqeiu")),
StateRoot: big.NewInt(int64(i) * 5), //nolint:gomnd
//nolint:gomnd
NumAccounts: 30,
ExitRoot: common.Hash([]byte("tykertheuhtgenuer3iuw3b")),
SlotNum: common.SlotNum(i),
ExitRoot: big.NewInt(int64(i) * 16), //nolint:gomnd
SlotNum: int64(i),
}
if i%2 == 0 {
toForge := new(int64)
@@ -324,7 +324,7 @@ func GenBids(nBids int, blocks []common.Block, coords []common.Coordinator) []co
bids := []common.Bid{}
for i := 0; i < nBids; i++ {
bids = append(bids, common.Bid{
SlotNum: common.SlotNum(i),
SlotNum: int64(i),
BidValue: big.NewInt(int64(i)),
EthBlockNum: blocks[i%len(blocks)].EthBlockNum,
Bidder: coords[i%len(blocks)].Bidder,