Skip to content

Commit

Permalink
Updated historydb and some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Shailu-s committed Nov 13, 2024
1 parent 86e721a commit ca92869
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
10 changes: 5 additions & 5 deletions sequencer/database/historydb/historydb.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (hdb *HistoryDB) GetLastBatch() (*common.Batch, error) {
var batch common.Batch
err := meddler.QueryRow(
hdb.dbRead, &batch, `SELECT batch.batch_num, batch.eth_block_num, batch.forger_addr,
batch.fees_collected, batch.fee_idxs_coordinator, batch.state_root,
batch.state_root,
batch.num_accounts, batch.last_idx, batch.exit_root, batch.forge_l1_txs_num,
batch.slot_num, batch.total_fees_usd, batch.gas_price, batch.gas_used, batch.ether_price_usd
FROM batch ORDER BY batch_num DESC LIMIT 1;`,
Expand Down Expand Up @@ -189,8 +189,8 @@ func (hdb *HistoryDB) GetAllBatches() ([]common.Batch, error) {
var batches []*common.Batch
err := meddler.QueryAll(
hdb.dbRead, &batches,
`SELECT batch.batch_num, batch.eth_block_num, batch.forger_addr, batch.fees_collected,
batch.fee_idxs_coordinator, batch.state_root, batch.num_accounts, batch.last_idx, batch.exit_root,
`SELECT batch.batch_num, batch.eth_block_num, batch.forger_addr,
batch.state_root, batch.num_accounts, batch.last_idx, batch.exit_root,
batch.forge_l1_txs_num, batch.slot_num, batch.total_fees_usd, batch.eth_tx_hash FROM batch
ORDER BY item_id;`,
)
Expand All @@ -202,7 +202,7 @@ func (hdb *HistoryDB) GetBatches(from, to common.BatchNum) ([]common.Batch, erro
var batches []*common.Batch
err := meddler.QueryAll(
hdb.dbRead, &batches,
`SELECT batch_num, eth_block_num, forger_addr, fees_collected, fee_idxs_coordinator,
`SELECT batch_num, eth_block_num, forger_addr,
state_root, num_accounts, last_idx, exit_root, forge_l1_txs_num, slot_num, total_fees_usd, gas_price, gas_used, ether_price_usd
FROM batch WHERE $1 <= batch_num AND batch_num < $2 ORDER BY batch_num;`,
from, to,
Expand All @@ -222,7 +222,7 @@ func (hdb *HistoryDB) GetBatch(batchNum common.BatchNum) (*common.Batch, error)
var batch common.Batch
err := meddler.QueryRow(
hdb.dbRead, &batch, `SELECT batch.batch_num, batch.eth_block_num, batch.forger_addr,
batch.fees_collected, batch.fee_idxs_coordinator, batch.state_root,
batch.state_root,
batch.num_accounts, batch.last_idx, batch.exit_root, batch.forge_l1_txs_num,
batch.slot_num, batch.total_fees_usd, batch.gas_price, batch.gas_used, batch.ether_price_usd
FROM batch WHERE batch_num = $1;`,
Expand Down
16 changes: 7 additions & 9 deletions sequencer/test/ethClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ func (r *RollupBlock) addTransaction(tx *types.Transaction) *types.Transaction {
return tx
}

var (
errBidClosed = fmt.Errorf("Bid has already been closed")
errBidNotOpen = fmt.Errorf("Bid has not been opened yet")
errBidBelowMin = fmt.Errorf("Bid below minimum")
errCoordNotReg = fmt.Errorf("Coordinator not registered")
)
// var (
// errBidClosed = fmt.Errorf("bid has already been closed")
// errBidNotOpen = fmt.Errorf("bid has not been opened yet")
// errBidBelowMin = fmt.Errorf("bid below minimum")
// errCoordNotReg = fmt.Errorf("coordinator not registered")
// )

// EthereumBlock stores all the generic data related to the an ethereum block
type EthereumBlock struct {
Expand Down Expand Up @@ -643,7 +643,6 @@ func (c *Client) RollupWithdrawMerkleProof(babyPubKey babyjub.PublicKeyComp,

type data struct {
BabyPubKey *babyjub.PublicKey
TokenID uint32
NumExitRoot int64
Idx int64
Amount *big.Int
Expand All @@ -652,7 +651,6 @@ func (c *Client) RollupWithdrawMerkleProof(babyPubKey babyjub.PublicKeyComp,
}
tx = r.addTransaction(c.newTransaction("withdrawMerkleProof", data{
BabyPubKey: babyPubKeyDecomp,
TokenID: tokenID,
NumExitRoot: numExitRoot,
Idx: idx,
Amount: amount,
Expand Down Expand Up @@ -801,7 +799,7 @@ func (c *Client) RollupEventsByBlock(blockNum int64,
return nil, common.Wrap(fmt.Errorf("Block %v doesn't exist", blockNum))
}
if blockHash != nil && *blockHash != block.Eth.Hash {
return nil, common.Wrap(fmt.Errorf("Hash mismatch, requested %v got %v",
return nil, common.Wrap(fmt.Errorf("hash mismatch, requested %v got %v",
blockHash, block.Eth.Hash))
}
return &block.Rollup.Events, nil
Expand Down

0 comments on commit ca92869

Please sign in to comment.