You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

506 lines
15 KiB

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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
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`.
4 years ago
  1. package synchronizer
  2. import (
  3. "context"
  4. "encoding/json"
  5. "fmt"
  6. "io/ioutil"
  7. "math/big"
  8. "os"
  9. "testing"
  10. ethCommon "github.com/ethereum/go-ethereum/common"
  11. "github.com/hermeznetwork/hermez-node/common"
  12. dbUtils "github.com/hermeznetwork/hermez-node/db"
  13. "github.com/hermeznetwork/hermez-node/db/historydb"
  14. "github.com/hermeznetwork/hermez-node/db/statedb"
  15. "github.com/hermeznetwork/hermez-node/eth"
  16. "github.com/hermeznetwork/hermez-node/test"
  17. "github.com/hermeznetwork/hermez-node/test/til"
  18. "github.com/jinzhu/copier"
  19. "github.com/stretchr/testify/assert"
  20. "github.com/stretchr/testify/require"
  21. )
  22. var tokenConsts = map[common.TokenID]eth.ERC20Consts{}
  23. var forceExits = map[int64][]common.ExitInfo{} // ForgeL1TxsNum -> []exit
  24. type timer struct {
  25. time int64
  26. }
  27. func (t *timer) Time() int64 {
  28. currentTime := t.time
  29. t.time++
  30. return currentTime
  31. }
  32. // Check Sync output and HistoryDB state against expected values generated by
  33. // til
  34. func checkSyncBlock(t *testing.T, s *Synchronizer, blockNum int, block, syncBlock *common.BlockData) {
  35. // Check Blocks
  36. dbBlocks, err := s.historyDB.GetAllBlocks()
  37. require.Nil(t, err)
  38. assert.Equal(t, blockNum, len(dbBlocks))
  39. assert.Equal(t, int64(blockNum), dbBlocks[blockNum-1].EthBlockNum)
  40. assert.NotEqual(t, dbBlocks[blockNum-1].Hash, dbBlocks[blockNum-2].Hash)
  41. assert.Greater(t, dbBlocks[blockNum-1].Timestamp.Unix(), dbBlocks[blockNum-2].Timestamp.Unix())
  42. // Check Tokens
  43. assert.Equal(t, len(block.AddedTokens), len(syncBlock.AddedTokens))
  44. dbTokens, err := s.historyDB.GetAllTokens()
  45. require.Nil(t, err)
  46. for i, token := range block.AddedTokens {
  47. dbToken := dbTokens[i]
  48. syncToken := syncBlock.AddedTokens[i]
  49. assert.Equal(t, block.Block.EthBlockNum, syncToken.EthBlockNum)
  50. assert.Equal(t, token.TokenID, syncToken.TokenID)
  51. assert.Equal(t, token.EthAddr, syncToken.EthAddr)
  52. tokenConst := tokenConsts[token.TokenID]
  53. assert.Equal(t, tokenConst.Name, syncToken.Name)
  54. assert.Equal(t, tokenConst.Symbol, syncToken.Symbol)
  55. assert.Equal(t, tokenConst.Decimals, syncToken.Decimals)
  56. var tokenCpy historydb.TokenWithUSD
  57. //nolint:gosec
  58. require.Nil(t, copier.Copy(&tokenCpy, &token)) // copy common.Token to historydb.TokenWithUSD
  59. require.Nil(t, copier.Copy(&tokenCpy, &tokenConst)) // copy common.Token to historydb.TokenWithUSD
  60. tokenCpy.ItemID = dbToken.ItemID // we don't care about ItemID
  61. assert.Equal(t, tokenCpy, dbToken)
  62. }
  63. // Check L1UserTxs
  64. assert.Equal(t, len(block.L1UserTxs), len(syncBlock.L1UserTxs))
  65. dbL1UserTxs, err := s.historyDB.GetAllL1UserTxs()
  66. require.Nil(t, err)
  67. // Ignore BatchNum in syncBlock.L1UserTxs because this value is set by the HistoryDB
  68. for i := range syncBlock.L1UserTxs {
  69. syncBlock.L1UserTxs[i].BatchNum = block.L1UserTxs[i].BatchNum
  70. }
  71. assert.Equal(t, block.L1UserTxs, syncBlock.L1UserTxs)
  72. for _, tx := range block.L1UserTxs {
  73. var dbTx *common.L1Tx
  74. // Find tx in DB output
  75. for _, _dbTx := range dbL1UserTxs {
  76. if *tx.ToForgeL1TxsNum == *_dbTx.ToForgeL1TxsNum &&
  77. tx.Position == _dbTx.Position {
  78. dbTx = new(common.L1Tx)
  79. *dbTx = _dbTx
  80. break
  81. }
  82. }
  83. assert.Equal(t, &tx, dbTx) //nolint:gosec
  84. }
  85. // Check Batches
  86. assert.Equal(t, len(block.Batches), len(syncBlock.Batches))
  87. dbBatches, err := s.historyDB.GetAllBatches()
  88. require.Nil(t, err)
  89. dbL1CoordinatorTxs, err := s.historyDB.GetAllL1CoordinatorTxs()
  90. require.Nil(t, err)
  91. // fmt.Printf("DBG dbL1CoordinatorTxs: %+v\n", dbL1CoordinatorTxs)
  92. dbL2Txs, err := s.historyDB.GetAllL2Txs()
  93. require.Nil(t, err)
  94. // fmt.Printf("DBG dbL2Txs: %+v\n", dbL2Txs)
  95. dbExits, err := s.historyDB.GetAllExits()
  96. require.Nil(t, err)
  97. // dbL1CoordinatorTxs := []common.L1Tx{}
  98. for i, batch := range block.Batches {
  99. var dbBatch *common.Batch
  100. // Find batch in DB output
  101. for _, _dbBatch := range dbBatches {
  102. if batch.Batch.BatchNum == _dbBatch.BatchNum {
  103. dbBatch = new(common.Batch)
  104. *dbBatch = _dbBatch
  105. break
  106. }
  107. }
  108. syncBatch := syncBlock.Batches[i]
  109. // We don't care about TotalFeesUSD. Use the syncBatch that
  110. // has a TotalFeesUSD inserted by the HistoryDB
  111. batch.Batch.TotalFeesUSD = syncBatch.Batch.TotalFeesUSD
  112. batch.CreatedAccounts = syncBatch.CreatedAccounts // til doesn't output CreatedAccounts
  113. // Test field by field to facilitate debugging of errors
  114. assert.Equal(t, batch.L1CoordinatorTxs, syncBatch.L1CoordinatorTxs)
  115. assert.Equal(t, batch.L2Txs, syncBatch.L2Txs)
  116. // In exit tree, we only check AccountIdx and Balance, because
  117. // it's what we have precomputed before.
  118. for j := range batch.ExitTree {
  119. exit := &batch.ExitTree[j]
  120. assert.Equal(t, exit.AccountIdx, syncBatch.ExitTree[j].AccountIdx)
  121. assert.Equal(t, exit.Balance, syncBatch.ExitTree[j].Balance)
  122. *exit = syncBatch.ExitTree[j]
  123. }
  124. assert.Equal(t, batch.Batch, syncBatch.Batch)
  125. assert.Equal(t, batch, syncBatch)
  126. assert.Equal(t, &batch.Batch, dbBatch) //nolint:gosec
  127. // Check L1CoordinatorTxs from DB
  128. for _, tx := range batch.L1CoordinatorTxs {
  129. var dbTx *common.L1Tx
  130. // Find tx in DB output
  131. for _, _dbTx := range dbL1CoordinatorTxs {
  132. if *tx.BatchNum == *_dbTx.BatchNum &&
  133. tx.Position == _dbTx.Position {
  134. dbTx = new(common.L1Tx)
  135. *dbTx = _dbTx
  136. break
  137. }
  138. }
  139. assert.Equal(t, &tx, dbTx) //nolint:gosec
  140. }
  141. // Check L2Txs from DB
  142. for _, tx := range batch.L2Txs {
  143. var dbTx *common.L2Tx
  144. // Find tx in DB output
  145. for _, _dbTx := range dbL2Txs {
  146. if tx.BatchNum == _dbTx.BatchNum &&
  147. tx.Position == _dbTx.Position {
  148. dbTx = new(common.L2Tx)
  149. *dbTx = _dbTx
  150. break
  151. }
  152. }
  153. assert.Equal(t, &tx, dbTx) //nolint:gosec
  154. }
  155. // Check Exits from DB
  156. for _, exit := range batch.ExitTree {
  157. var dbExit *common.ExitInfo
  158. // Find exit in DB output
  159. for _, _dbExit := range dbExits {
  160. if exit.BatchNum == _dbExit.BatchNum &&
  161. exit.AccountIdx == _dbExit.AccountIdx {
  162. dbExit = new(common.ExitInfo)
  163. *dbExit = _dbExit
  164. break
  165. }
  166. }
  167. // Compare MerkleProof in JSON because unmarshaled 0
  168. // big.Int leaves the internal big.Int array at nil,
  169. // and gives trouble when comparing big.Int with
  170. // internal big.Int array != nil but empty.
  171. mtp, err := json.Marshal(exit.MerkleProof)
  172. require.Nil(t, err)
  173. dbMtp, err := json.Marshal(dbExit.MerkleProof)
  174. require.Nil(t, err)
  175. assert.Equal(t, mtp, dbMtp)
  176. dbExit.MerkleProof = exit.MerkleProof
  177. assert.Equal(t, &exit, dbExit) //nolint:gosec
  178. }
  179. }
  180. }
  181. func TestSync(t *testing.T) {
  182. //
  183. // Setup
  184. //
  185. ctx := context.Background()
  186. // Int State DB
  187. dir, err := ioutil.TempDir("", "tmpdb")
  188. require.Nil(t, err)
  189. defer assert.Nil(t, os.RemoveAll(dir))
  190. stateDB, err := statedb.NewStateDB(dir, statedb.TypeSynchronizer, 32)
  191. assert.Nil(t, err)
  192. // Init History DB
  193. pass := os.Getenv("POSTGRES_PASS")
  194. db, err := dbUtils.InitSQLDB(5432, "localhost", "hermez", pass, "hermez")
  195. require.Nil(t, err)
  196. historyDB := historydb.NewHistoryDB(db)
  197. // Clear DB
  198. err = historyDB.Reorg(-1)
  199. assert.Nil(t, err)
  200. // Init eth client
  201. var timer timer
  202. clientSetup := test.NewClientSetupExample()
  203. bootCoordAddr := clientSetup.AuctionVariables.BootCoordinator
  204. client := test.NewClient(true, &timer, &ethCommon.Address{}, clientSetup)
  205. // Create Synchronizer
  206. s, err := NewSynchronizer(client, historyDB, stateDB)
  207. require.Nil(t, err)
  208. //
  209. // First Sync from an initial state
  210. //
  211. // Test Sync for rollup genesis block
  212. syncBlock, discards, err := s.Sync2(ctx, nil)
  213. require.Nil(t, err)
  214. require.Nil(t, discards)
  215. require.NotNil(t, syncBlock)
  216. assert.Equal(t, int64(1), syncBlock.Block.EthBlockNum)
  217. dbBlocks, err := s.historyDB.GetAllBlocks()
  218. require.Nil(t, err)
  219. assert.Equal(t, 1, len(dbBlocks))
  220. assert.Equal(t, int64(1), dbBlocks[0].EthBlockNum)
  221. // Sync again and expect no new blocks
  222. syncBlock, discards, err = s.Sync2(ctx, nil)
  223. require.Nil(t, err)
  224. require.Nil(t, discards)
  225. require.Nil(t, syncBlock)
  226. //
  227. // Generate blockchain and smart contract data, and fill the test smart contracts
  228. //
  229. // TODO: Test CreateAccountDepositTransfer
  230. // TODO: Test ForceTransfer
  231. // TODO: Test ForceExit
  232. // Generate blockchain data with til
  233. set1 := `
  234. Type: Blockchain
  235. AddToken(1)
  236. AddToken(2)
  237. AddToken(3)
  238. CreateAccountDeposit(1) C: 20 // Idx=256+2=258
  239. CreateAccountDeposit(2) A: 20 // Idx=256+3=259
  240. CreateAccountDeposit(1) D: 5 // Idx=256+4=260
  241. CreateAccountDeposit(2) B: 5 // Idx=256+5=261
  242. CreateAccountDeposit(2) C: 5 // Idx=256+6=262
  243. CreateAccountCoordinator(1) A // Idx=256+0=256
  244. CreateAccountCoordinator(1) B // Idx=256+1=257
  245. > batchL1 // forge L1UserTxs{nil}, freeze defined L1UserTxs
  246. > batchL1 // forge defined L1UserTxs, freeze L1UserTxs{nil}
  247. > block // blockNum=2
  248. Transfer(1) C-A: 10 (10)
  249. Exit(1) D: 3 (5)
  250. > batch
  251. > block // blockNum=3
  252. `
  253. tc := til.NewContext(eth.RollupConstMaxL1UserTx)
  254. blocks, err := tc.GenerateBlocks(set1)
  255. require.Nil(t, err)
  256. // Sanity check
  257. require.Equal(t, 2, len(blocks))
  258. // blocks 0 (blockNum=2)
  259. i := 0
  260. require.Equal(t, 2, int(blocks[i].Block.EthBlockNum))
  261. require.Equal(t, 3, len(blocks[i].AddedTokens))
  262. require.Equal(t, 5, len(blocks[i].L1UserTxs))
  263. require.Equal(t, 2, len(blocks[i].Batches))
  264. require.Equal(t, 2, len(blocks[i].Batches[0].L1CoordinatorTxs))
  265. // blocks 1 (blockNum=3)
  266. i = 1
  267. require.Equal(t, 3, int(blocks[i].Block.EthBlockNum))
  268. require.Equal(t, 1, len(blocks[i].Batches))
  269. require.Equal(t, 2, len(blocks[i].Batches[0].L2Txs))
  270. // Generate extra required data
  271. for _, block := range blocks {
  272. for _, token := range block.AddedTokens {
  273. consts := eth.ERC20Consts{
  274. Name: fmt.Sprintf("Token %d", token.TokenID),
  275. Symbol: fmt.Sprintf("TK%d", token.TokenID),
  276. Decimals: 18,
  277. }
  278. tokenConsts[token.TokenID] = consts
  279. client.CtlAddERC20(token.EthAddr, consts)
  280. }
  281. }
  282. // Add block data to the smart contracts
  283. for _, block := range blocks {
  284. for _, token := range block.AddedTokens {
  285. _, err := client.RollupAddTokenSimple(token.EthAddr, clientSetup.RollupVariables.FeeAddToken)
  286. require.Nil(t, err)
  287. }
  288. for _, tx := range block.L1UserTxs {
  289. client.CtlSetAddr(tx.FromEthAddr)
  290. _, err := client.RollupL1UserTxERC20ETH(tx.FromBJJ, int64(tx.FromIdx), tx.LoadAmount, tx.Amount,
  291. uint32(tx.TokenID), int64(tx.ToIdx))
  292. require.Nil(t, err)
  293. }
  294. client.CtlSetAddr(bootCoordAddr)
  295. for _, batch := range block.Batches {
  296. _, err := client.RollupForgeBatch(&eth.RollupForgeBatchArgs{
  297. NewLastIdx: batch.Batch.LastIdx,
  298. NewStRoot: batch.Batch.StateRoot,
  299. NewExitRoot: batch.Batch.ExitRoot,
  300. L1CoordinatorTxs: batch.L1CoordinatorTxs,
  301. L1CoordinatorTxsAuths: [][]byte{}, // Intentionally empty
  302. L2TxsData: batch.L2Txs,
  303. FeeIdxCoordinator: []common.Idx{}, // TODO
  304. // Circuit selector
  305. VerifierIdx: 0, // Intentionally empty
  306. L1Batch: batch.L1Batch,
  307. ProofA: [2]*big.Int{}, // Intentionally empty
  308. ProofB: [2][2]*big.Int{}, // Intentionally empty
  309. ProofC: [2]*big.Int{}, // Intentionally empty
  310. })
  311. require.Nil(t, err)
  312. }
  313. // Mine block and sync
  314. client.CtlMineBlock()
  315. }
  316. // Fill extra fields not generated by til in til block
  317. openToForge := int64(0)
  318. toForgeL1TxsNum := int64(0)
  319. l1UserTxsLen := map[int64]int{} // ForgeL1TxsNum -> len(L1UserTxs)
  320. for i := range blocks {
  321. block := &blocks[i]
  322. // Count number of L1UserTxs in each queue, to figure out later
  323. // position of L1CoordinatorTxs and L2Txs
  324. for j := range block.L1UserTxs {
  325. tx := &block.L1UserTxs[j]
  326. l1UserTxsLen[*tx.ToForgeL1TxsNum]++
  327. if tx.Type == common.TxTypeForceExit {
  328. forceExits[*tx.ToForgeL1TxsNum] = append(forceExits[*tx.ToForgeL1TxsNum],
  329. common.ExitInfo{
  330. AccountIdx: tx.FromIdx,
  331. Balance: tx.Amount,
  332. })
  333. }
  334. }
  335. for j := range block.Batches {
  336. batch := &block.Batches[j]
  337. if batch.L1Batch {
  338. // Set BatchNum for forged L1UserTxs to til blocks
  339. bn := batch.Batch.BatchNum
  340. for k := range blocks {
  341. block := &blocks[k]
  342. for l := range block.L1UserTxs {
  343. tx := &block.L1UserTxs[l]
  344. if *tx.ToForgeL1TxsNum == openToForge {
  345. tx.BatchNum = &bn
  346. }
  347. }
  348. }
  349. openToForge++
  350. }
  351. batch.Batch.EthBlockNum = block.Block.EthBlockNum
  352. batch.Batch.ForgerAddr = bootCoordAddr // til doesn't fill the batch forger addr
  353. if batch.L1Batch {
  354. toForgeL1TxsNumCpy := toForgeL1TxsNum
  355. batch.Batch.ForgeL1TxsNum = &toForgeL1TxsNumCpy // til doesn't fill the ForgeL1TxsNum
  356. toForgeL1TxsNum++
  357. }
  358. batchNum := batch.Batch.BatchNum
  359. for k := range batch.L1CoordinatorTxs {
  360. tx := &batch.L1CoordinatorTxs[k]
  361. tx.BatchNum = &batchNum
  362. tx.EthBlockNum = batch.Batch.EthBlockNum
  363. }
  364. }
  365. }
  366. // Fill expected positions in L1CoordinatorTxs and L2Txs
  367. for i := range blocks {
  368. block := &blocks[i]
  369. for j := range block.Batches {
  370. batch := &block.Batches[j]
  371. position := 0
  372. if batch.L1Batch {
  373. position = l1UserTxsLen[*batch.Batch.ForgeL1TxsNum]
  374. }
  375. for k := range batch.L1CoordinatorTxs {
  376. tx := &batch.L1CoordinatorTxs[k]
  377. tx.Position = position
  378. position++
  379. nTx, err := common.NewL1Tx(tx)
  380. require.Nil(t, err)
  381. *tx = *nTx
  382. }
  383. for k := range batch.L2Txs {
  384. tx := &batch.L2Txs[k]
  385. tx.Position = position
  386. position++
  387. nTx, err := common.NewL2Tx(tx)
  388. require.Nil(t, err)
  389. *tx = *nTx
  390. }
  391. }
  392. }
  393. // Fill ExitTree (only AccountIdx and Balance)
  394. for i := range blocks {
  395. block := &blocks[i]
  396. for j := range block.Batches {
  397. batch := &block.Batches[j]
  398. if batch.L1Batch {
  399. for forgeL1TxsNum, exits := range forceExits {
  400. if forgeL1TxsNum == *batch.Batch.ForgeL1TxsNum {
  401. batch.ExitTree = append(batch.ExitTree, exits...)
  402. }
  403. }
  404. }
  405. for k := range batch.L2Txs {
  406. tx := &batch.L2Txs[k]
  407. if tx.Type == common.TxTypeExit {
  408. batch.ExitTree = append(batch.ExitTree, common.ExitInfo{
  409. AccountIdx: tx.FromIdx,
  410. Balance: tx.Amount,
  411. })
  412. }
  413. }
  414. }
  415. }
  416. //
  417. // Sync to synchronize the current state from the test smart contracts,
  418. // and check the outcome
  419. //
  420. // Block 2
  421. syncBlock, discards, err = s.Sync2(ctx, nil)
  422. require.Nil(t, err)
  423. require.Nil(t, discards)
  424. require.NotNil(t, syncBlock)
  425. assert.Equal(t, int64(2), syncBlock.Block.EthBlockNum)
  426. checkSyncBlock(t, s, 2, &blocks[0], syncBlock)
  427. // Block 3
  428. syncBlock, discards, err = s.Sync2(ctx, nil)
  429. require.Nil(t, err)
  430. require.Nil(t, discards)
  431. require.NotNil(t, syncBlock)
  432. assert.Equal(t, int64(3), syncBlock.Block.EthBlockNum)
  433. checkSyncBlock(t, s, 3, &blocks[1], syncBlock)
  434. // TODO: Reorg will be properly tested once we have the mock ethClient implemented
  435. /*
  436. // Force a Reorg
  437. lastSavedBlock, err := historyDB.GetLastBlock()
  438. require.Nil(t, err)
  439. lastSavedBlock.EthBlockNum++
  440. err = historyDB.AddBlock(lastSavedBlock)
  441. require.Nil(t, err)
  442. lastSavedBlock.EthBlockNum++
  443. err = historyDB.AddBlock(lastSavedBlock)
  444. require.Nil(t, err)
  445. log.Debugf("Wait for the blockchain to generate some blocks...")
  446. time.Sleep(40 * time.Second)
  447. err = s.Sync()
  448. require.Nil(t, err)
  449. */
  450. }