arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
Run go-instrument-errors to wrap errors
Eduard S eduard@iden3.io
Fri, 18 Dec 2020 13:39:42 +0100
commit

b1a8384f2759c6b2a9f976e9fe8f7c3d6156acd8

parent

b59f790c04a0d307af77291f06319f53ddd58361

M common/l1tx.go → common/l1tx.go

@@ -53,7 +53,7 @@ // from the L1Tx values

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 @@ }

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 {
M common/l2tx.go → common/l2tx.go

@@ -27,7 +27,7 @@ // from the L2Tx values

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 @@ }

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 {
M common/pooll2tx.go → common/pooll2tx.go

@@ -53,7 +53,7 @@ // from the L2Tx values

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 @@ }

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 {
M eth/auction.go → eth/auction.go

@@ -777,11 +777,11 @@ if err != nil {

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 @@ if err := c.contractAbi.UnpackIntoInterface(&auctionInit,

"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
M eth/rollup.go → eth/rollup.go

@@ -710,18 +710,18 @@ if err != nil {

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
M eth/wdelayer.go → eth/wdelayer.go

@@ -408,11 +408,11 @@ if err != nil {

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 @@ if err := c.contractAbi.UnpackIntoInterface(&wDelayerInit, "InitializeWithdrawalDelayerEvent",

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
M prover/prover.go → prover/prover.go

@@ -27,7 +27,7 @@

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 @@ PiC [2]*bigInt `json:"pi_c"`

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 @@ // are in decimal as quoted strings

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 @@ return nil, nil, tracerr.Wrap(err)

} 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 @@ if err != nil {

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
M synchronizer/synchronizer.go → synchronizer/synchronizer.go

@@ -226,7 +226,7 @@ }

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 @@ s.vars.Rollup = *vars.Rollup.Copy()

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 @@

// 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
M test/ethclient.go → test/ethclient.go

@@ -1777,14 +1777,14 @@ rollup := nextBlock.Rollup

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 @@ ProofA: [2]*big.Int{}, // Intentionally empty

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
M test/til/txs.go → test/til/txs.go

@@ -883,7 +883,7 @@ position++

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 {