Browse Source

Run go-instrument-errors to wrap errors

feature/sql-semaphore1
Eduard S 3 years ago
parent
commit
b1a8384f27
10 changed files with 30 additions and 30 deletions
  1. +2
    -2
      common/l1tx.go
  2. +2
    -2
      common/l2tx.go
  3. +2
    -2
      common/pooll2tx.go
  4. +3
    -3
      eth/auction.go
  5. +3
    -3
      eth/rollup.go
  6. +3
    -3
      eth/wdelayer.go
  7. +5
    -5
      prover/prover.go
  8. +6
    -6
      synchronizer/synchronizer.go
  9. +3
    -3
      test/ethclient.go
  10. +1
    -1
      test/til/txs.go

+ 2
- 2
common/l1tx.go

@ -53,7 +53,7 @@ type L1Tx struct {
func NewL1Tx(tx *L1Tx) (*L1Tx, error) {
txTypeOld := tx.Type
if err := tx.SetType(); err != nil {
return nil, err
return nil, tracerr.Wrap(err)
}
// If original Type doesn't match the correct one, return error
if txTypeOld != "" && txTypeOld != tx.Type {
@ -63,7 +63,7 @@ func NewL1Tx(tx *L1Tx) (*L1Tx, error) {
txIDOld := tx.TxID
if err := tx.SetID(); err != nil {
return nil, err
return nil, tracerr.Wrap(err)
}
// If original TxID doesn't match the correct one, return error
if txIDOld != (TxID{}) && txIDOld != tx.TxID {

+ 2
- 2
common/l2tx.go

@ -27,7 +27,7 @@ type L2Tx struct {
func NewL2Tx(tx *L2Tx) (*L2Tx, error) {
txTypeOld := tx.Type
if err := tx.SetType(); err != nil {
return nil, err
return nil, tracerr.Wrap(err)
}
// If original Type doesn't match the correct one, return error
if txTypeOld != "" && txTypeOld != tx.Type {
@ -37,7 +37,7 @@ func NewL2Tx(tx *L2Tx) (*L2Tx, error) {
txIDOld := tx.TxID
if err := tx.SetID(); err != nil {
return nil, err
return nil, tracerr.Wrap(err)
}
// If original TxID doesn't match the correct one, return error
if txIDOld != (TxID{}) && txIDOld != tx.TxID {

+ 2
- 2
common/pooll2tx.go

@ -53,7 +53,7 @@ type PoolL2Tx struct {
func NewPoolL2Tx(tx *PoolL2Tx) (*PoolL2Tx, error) {
txTypeOld := tx.Type
if err := tx.SetType(); err != nil {
return nil, err
return nil, tracerr.Wrap(err)
}
// If original Type doesn't match the correct one, return error
if txTypeOld != "" && txTypeOld != tx.Type {
@ -63,7 +63,7 @@ func NewPoolL2Tx(tx *PoolL2Tx) (*PoolL2Tx, error) {
txIDOld := tx.TxID
if err := tx.SetID(); err != nil {
return nil, err
return nil, tracerr.Wrap(err)
}
// If original TxID doesn't match the correct one, return error
if txIDOld != (TxID{}) && txIDOld != tx.TxID {

+ 3
- 3
eth/auction.go

@ -777,11 +777,11 @@ func (c *AuctionClient) AuctionEventInit() (*AuctionEventInitialize, int64, erro
return nil, 0, tracerr.Wrap(err)
}
if len(logs) != 1 {
return nil, 0, fmt.Errorf("no event of type InitializeHermezAuctionProtocolEvent found")
return nil, 0, tracerr.Wrap(fmt.Errorf("no event of type InitializeHermezAuctionProtocolEvent found"))
}
vLog := logs[0]
if vLog.Topics[0] != logAuctionInitialize {
return nil, 0, fmt.Errorf("event is not InitializeHermezAuctionProtocolEvent")
return nil, 0, tracerr.Wrap(fmt.Errorf("event is not InitializeHermezAuctionProtocolEvent"))
}
var auctionInit AuctionEventInitialize
@ -789,7 +789,7 @@ func (c *AuctionClient) AuctionEventInit() (*AuctionEventInitialize, int64, erro
"InitializeHermezAuctionProtocolEvent", vLog.Data); err != nil {
return nil, 0, tracerr.Wrap(err)
}
return &auctionInit, int64(vLog.BlockNumber), err
return &auctionInit, int64(vLog.BlockNumber), tracerr.Wrap(err)
}
// AuctionEventsByBlock returns the events in a block that happened in the

+ 3
- 3
eth/rollup.go

@ -710,18 +710,18 @@ func (c *RollupClient) RollupEventInit() (*RollupEventInitialize, int64, error)
return nil, 0, tracerr.Wrap(err)
}
if len(logs) != 1 {
return nil, 0, fmt.Errorf("no event of type InitializeHermezEvent found")
return nil, 0, tracerr.Wrap(fmt.Errorf("no event of type InitializeHermezEvent found"))
}
vLog := logs[0]
if vLog.Topics[0] != logHermezInitialize {
return nil, 0, fmt.Errorf("event is not InitializeHermezEvent")
return nil, 0, tracerr.Wrap(fmt.Errorf("event is not InitializeHermezEvent"))
}
var rollupInit RollupEventInitialize
if err := c.contractAbi.UnpackIntoInterface(&rollupInit, "InitializeHermezEvent", vLog.Data); err != nil {
return nil, 0, tracerr.Wrap(err)
}
return &rollupInit, int64(vLog.BlockNumber), err
return &rollupInit, int64(vLog.BlockNumber), tracerr.Wrap(err)
}
// RollupEventsByBlock returns the events in a block that happened in the Rollup Smart Contract

+ 3
- 3
eth/wdelayer.go

@ -408,11 +408,11 @@ func (c *WDelayerClient) WDelayerEventInit() (*WDelayerEventInitialize, int64, e
return nil, 0, tracerr.Wrap(err)
}
if len(logs) != 1 {
return nil, 0, fmt.Errorf("no event of type InitializeWithdrawalDelayerEvent found")
return nil, 0, tracerr.Wrap(fmt.Errorf("no event of type InitializeWithdrawalDelayerEvent found"))
}
vLog := logs[0]
if vLog.Topics[0] != logWDelayerInitialize {
return nil, 0, fmt.Errorf("event is not InitializeWithdrawalDelayerEvent")
return nil, 0, tracerr.Wrap(fmt.Errorf("event is not InitializeWithdrawalDelayerEvent"))
}
var wDelayerInit WDelayerEventInitialize
@ -420,7 +420,7 @@ func (c *WDelayerClient) WDelayerEventInit() (*WDelayerEventInitialize, int64, e
vLog.Data); err != nil {
return nil, 0, tracerr.Wrap(err)
}
return &wDelayerInit, int64(vLog.BlockNumber), err
return &wDelayerInit, int64(vLog.BlockNumber), tracerr.Wrap(err)
}
// WDelayerEventsByBlock returns the events in a block that happened in the

+ 5
- 5
prover/prover.go

@ -27,7 +27,7 @@ type bigInt big.Int
func (b *bigInt) UnmarshalText(text []byte) error {
_, ok := (*big.Int)(b).SetString(string(text), 10)
if !ok {
return fmt.Errorf("invalid big int: \"%v\"", string(text))
return tracerr.Wrap(fmt.Errorf("invalid big int: \"%v\"", string(text)))
}
return nil
}
@ -42,7 +42,7 @@ func (p *Proof) UnmarshalJSON(data []byte) error {
Protocol string `json:"protocol"`
}{}
if err := json.Unmarshal(data, &proof); err != nil {
return err
return tracerr.Wrap(err)
}
p.PiA[0] = (*big.Int)(proof.PiA[0])
p.PiA[1] = (*big.Int)(proof.PiA[1])
@ -66,7 +66,7 @@ type PublicInputs []*big.Int
func (p *PublicInputs) UnmarshalJSON(data []byte) error {
pubInputs := []*bigInt{}
if err := json.Unmarshal(data, &pubInputs); err != nil {
return err
return tracerr.Wrap(err)
}
*p = make([]*big.Int, len(pubInputs))
for i, v := range pubInputs {
@ -245,7 +245,7 @@ func (p *ProofServerClient) GetProof(ctx context.Context) (*Proof, []*big.Int, e
}
return &proof, pubInputs, nil
}
return nil, nil, fmt.Errorf("status != StatusCodeSuccess, status = %v", status.Status)
return nil, nil, tracerr.Wrap(fmt.Errorf("status != StatusCodeSuccess, status = %v", status.Status))
}
// Cancel cancels any current proof computation
@ -261,7 +261,7 @@ func (p *ProofServerClient) WaitReady(ctx context.Context) error {
return tracerr.Wrap(err)
}
if !status.Status.IsInitialized() {
return fmt.Errorf("Proof Server is not initialized")
return tracerr.Wrap(fmt.Errorf("Proof Server is not initialized"))
}
if status.Status.IsReady() {
return nil

+ 6
- 6
synchronizer/synchronizer.go

@ -226,7 +226,7 @@ func NewSynchronizer(ethClient eth.ClientInterface, historyDB *historydb.History
initVars, startBlockNums, err := getInitialVariables(ethClient, &consts)
if err != nil {
return nil, err
return nil, tracerr.Wrap(err)
}
log.Infow("Synchronizer syncing from smart contract blocks",
"rollup", startBlockNums.Rollup,
@ -587,15 +587,15 @@ func getInitialVariables(ethClient eth.ClientInterface,
consts *SCConsts) (*SCVariables, *StartBlockNums, error) {
rollupInit, rollupInitBlock, err := ethClient.RollupEventInit()
if err != nil {
return nil, nil, err
return nil, nil, tracerr.Wrap(err)
}
auctionInit, auctionInitBlock, err := ethClient.AuctionEventInit()
if err != nil {
return nil, nil, err
return nil, nil, tracerr.Wrap(err)
}
wDelayerInit, wDelayerInitBlock, err := ethClient.WDelayerEventInit()
if err != nil {
return nil, nil, err
return nil, nil, tracerr.Wrap(err)
}
rollupVars := rollupInit.RollupVariables()
auctionVars := auctionInit.AuctionVariables(consts.Auction.InitialMinimalBidding)
@ -625,7 +625,7 @@ func (s *Synchronizer) resetState(block *common.Block) error {
s.vars.Auction = *vars.Auction.Copy()
s.vars.WDelayer = *vars.WDelayer.Copy()
} else if err != nil {
return err
return tracerr.Wrap(err)
} else {
s.vars.Rollup = *rollup
s.vars.Auction = *auction
@ -805,7 +805,7 @@ func (s *Synchronizer) rollupSync(ethBlock *common.Block) (*common.RollupData, e
// Set TxID, BlockNum, BatchNum and Position to the forged L2Txs
for i := range l2Txs {
if err := l2Txs[i].SetID(); err != nil {
return nil, err
return nil, tracerr.Wrap(err)
}
l2Txs[i].EthBlockNum = blockNum
l2Txs[i].BatchNum = batchNum

+ 3
- 3
test/ethclient.go

@ -1777,14 +1777,14 @@ func (c *Client) CtlAddBlocks(blocks []common.BlockData) (err error) {
auction := nextBlock.Auction
for _, token := range block.Rollup.AddedTokens {
if _, err := c.RollupAddTokenSimple(token.EthAddr, rollup.Vars.FeeAddToken); err != nil {
return err
return tracerr.Wrap(err)
}
}
for _, tx := range block.Rollup.L1UserTxs {
c.CtlSetAddr(tx.FromEthAddr)
if _, err := c.RollupL1UserTxERC20ETH(tx.FromBJJ, int64(tx.FromIdx), tx.DepositAmount, tx.Amount,
uint32(tx.TokenID), int64(tx.ToIdx)); err != nil {
return err
return tracerr.Wrap(err)
}
}
c.CtlSetAddr(auction.Vars.BootCoordinator)
@ -1804,7 +1804,7 @@ func (c *Client) CtlAddBlocks(blocks []common.BlockData) (err error) {
ProofB: [2][2]*big.Int{}, // Intentionally empty
ProofC: [2]*big.Int{}, // Intentionally empty
}); err != nil {
return err
return tracerr.Wrap(err)
}
}
// Mine block and sync

+ 1
- 1
test/til/txs.go

@ -883,7 +883,7 @@ func (tc *Context) FillBlocksExtra(blocks []common.BlockData, cfg *ConfigExtra)
tc.extra.nonces[tx.FromIdx]++
tx.Nonce = tc.extra.nonces[tx.FromIdx]
if err := tx.SetID(); err != nil {
return err
return tracerr.Wrap(err)
}
nTx, err := common.NewL2Tx(tx)
if err != nil {

Loading…
Cancel
Save