Skip to content

Commit

Permalink
refactor: update dependency (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
yutianwu authored Aug 25, 2022
1 parent 6012967 commit 7fe4c16
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
)

require (
github.com/bnb-chain/zkbas-crypto v0.0.4-0.20220824105332-0a4b384e79ad
github.com/bnb-chain/zkbas-crypto v0.0.4-0.20220825082047-852b76a0f52e
github.com/bnb-chain/zkbas-eth-rpc v0.0.1
github.com/consensys/gnark v0.7.0
github.com/consensys/gnark-crypto v0.7.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqO
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
github.com/bnb-chain/bas-smt v0.0.0-20220804090937-a7712cdee391 h1:U0pz17/+58EvEzjpqmRoJJ+wy0hYWNDQb+afohYrths=
github.com/bnb-chain/bas-smt v0.0.0-20220804090937-a7712cdee391/go.mod h1:VJsBjo+k7FICpTw27+LwuAvfq9I13UJ4hUjmberr22Q=
github.com/bnb-chain/zkbas-crypto v0.0.4-0.20220824105332-0a4b384e79ad h1:49zcz2fHrFfvHpHeaoj/s+CdSpndpZAtsWBYjM0x1js=
github.com/bnb-chain/zkbas-crypto v0.0.4-0.20220824105332-0a4b384e79ad/go.mod h1:W9Daa6XJT7U48WA9+5YQTsEfwzxFs8rC3FeUQ6hGFNo=
github.com/bnb-chain/zkbas-crypto v0.0.4-0.20220825082047-852b76a0f52e h1:8WbyjU7FVTpmmH/wsNPJZEfV/cdqjztXR9TA9wkQ7Gk=
github.com/bnb-chain/zkbas-crypto v0.0.4-0.20220825082047-852b76a0f52e/go.mod h1:W9Daa6XJT7U48WA9+5YQTsEfwzxFs8rC3FeUQ6hGFNo=
github.com/bnb-chain/zkbas-eth-rpc v0.0.1 h1:5wqS5TumcxXWovdMRWE6ZWC8mU4lmfRrRCV7sI7mVvw=
github.com/bnb-chain/zkbas-eth-rpc v0.0.1/go.mod h1:t8jY6/Jt/Rw8LeU9Rhw406uaOIOou4ycVX06LKyVxKo=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
Expand Down
42 changes: 21 additions & 21 deletions service/sender/sender/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,13 @@ func (s *Sender) VerifyAndExecuteBlocks() (err error) {
// scan l1 tx sender table for handled verified and executed height
lastHandledBlock, getHandleErr := s.l1RollupTxModel.GetLatestHandledTx(l1rolluptx.TxTypeVerifyAndExecute)
if getHandleErr != nil && getHandleErr != types.DbErrNotFound {
logx.Errorf("[SendVerifiedAndExecutedBlocks] unable to get latest handled block: %v", getHandleErr)
logx.Errorf("unable to get latest handled block: %v", getHandleErr)
return getHandleErr
}
// scan l1 tx sender table for pending verified and executed height that higher than the latest handled height
pendingSender, getPendingErr := s.l1RollupTxModel.GetLatestPendingTx(l1rolluptx.TxTypeVerifyAndExecute)
if getPendingErr != nil && getPendingErr != types.DbErrNotFound {
logx.Errorf("[SendVerifiedAndExecutedBlocks] unable to get latest pending blocks: %v", getPendingErr)
logx.Errorf("unable to get latest pending blocks: %v", getPendingErr)
return getPendingErr
}
// case 1: check tx status on L1
Expand All @@ -368,7 +368,7 @@ func (s *Sender) VerifyAndExecuteBlocks() (err error) {
// drop the record
err := s.l1RollupTxModel.DeleteL1RollupTx(pendingSender)
if err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] unable to delete l1 tx sender: %v", err)
logx.Errorf("unable to delete l1 tx sender: %v", err)
return err
}
return nil
Expand All @@ -378,16 +378,16 @@ func (s *Sender) VerifyAndExecuteBlocks() (err error) {
}
// if it is pending, still waiting
if isPending {
logx.Infof("[SendVerifiedAndExecutedBlocks] tx is still pending, no need to work for anything tx hash: %s", pendingSender.L1TxHash)
logx.Infof("tx is still pending, no need to work for anything tx hash: %s", pendingSender.L1TxHash)
return nil
} else {
receipt, err := cli.GetTransactionReceipt(pendingSender.L1TxHash)
if err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] unable to get transaction receipt: %v", err)
logx.Errorf("unable to get transaction receipt: %v", err)
return err
}
if receipt.Status == 0 {
logx.Infof("[SendVerifiedAndExecutedBlocks] the transaction is failure, please check: %s", pendingSender.L1TxHash)
logx.Infof("the transaction is failure, please check: %s", pendingSender.L1TxHash)
return nil
}
}
Expand All @@ -402,7 +402,7 @@ func (s *Sender) VerifyAndExecuteBlocks() (err error) {
if time.Now().After(lastUpdatedAt.Add(time.Duration(s.config.ChainConfig.MaxWaitingTime) * time.Second)) {
// drop the record
if err := s.l1RollupTxModel.DeleteL1RollupTx(pendingSender); err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] unable to delete l1 tx sender: %v", err)
logx.Errorf("unable to delete l1 tx sender: %v", err)
return err
}
}
Expand All @@ -423,13 +423,13 @@ func (s *Sender) VerifyAndExecuteBlocks() (err error) {
// get blocks from block table
blocks, err = s.blockModel.GetBlocksForProverBetween(1, int64(s.config.ChainConfig.MaxBlockCount))
if err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] GetBlocksForProverBetween err: %v, maxBlockCount: %d",
logx.Errorf("GetBlocksForProverBetween err: %v, maxBlockCount: %d",
err, s.config.ChainConfig.MaxBlockCount)
return err
}
pendingVerifyAndExecuteBlocks, err = ConvertBlocksToVerifyAndExecuteBlockInfos(blocks)
if err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] unable to convert blocks to verify and execute block infos: %v", err)
logx.Errorf("unable to convert blocks to verify and execute block infos: %v", err)
return err
}
start = int64(1)
Expand All @@ -438,12 +438,12 @@ func (s *Sender) VerifyAndExecuteBlocks() (err error) {
blocks, err = s.blockModel.GetBlocksForProverBetween(lastHandledBlock.L2BlockHeight+1,
lastHandledBlock.L2BlockHeight+int64(s.config.ChainConfig.MaxBlockCount))
if err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] unable to get sender new blocks: %v", err)
logx.Errorf("unable to get sender new blocks: %v", err)
return err
}
pendingVerifyAndExecuteBlocks, err = ConvertBlocksToVerifyAndExecuteBlockInfos(blocks)
if err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] unable to convert blocks to commit block infos: %v", err)
logx.Errorf("unable to convert blocks to commit block infos: %v", err)
return err
}
start = lastHandledBlock.L2BlockHeight + 1
Expand All @@ -452,19 +452,19 @@ func (s *Sender) VerifyAndExecuteBlocks() (err error) {
blockProofs, err := s.proofModel.GetProofsByBlockRange(start, blocks[len(blocks)-1].BlockHeight,
s.config.ChainConfig.MaxBlockCount)
if err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] unable to get proofs: %v", err)
logx.Errorf("unable to get proofs: %v", err)
return err
}
if len(blockProofs) != len(blocks) {
logx.Errorf("[SendVerifiedAndExecutedBlocks] we haven't generated related proofs, please wait")
return errors.New("[SendVerifiedAndExecutedBlocks] we haven't generated related proofs, please wait")
logx.Errorf("we haven't generated related proofs, please wait")
return errors.New("we haven't generated related proofs, please wait")
}
var proofs []*big.Int
for _, bProof := range blockProofs {
var proofInfo *prove.FormattedProof
err = json.Unmarshal([]byte(bProof.ProofInfo), &proofInfo)
if err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] unable to unmarshal proof info: %v", err)
logx.Errorf("unable to unmarshal proof info: %v", err)
return err
}
proofs = append(proofs, proofInfo.A[:]...)
Expand All @@ -474,15 +474,15 @@ func (s *Sender) VerifyAndExecuteBlocks() (err error) {
}
gasPrice, err := s.cli.SuggestGasPrice(context.Background())
if err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] failed to fetch gas price err: %v", err)
logx.Errorf("failed to fetch gas price err: %v", err)
return err
}
// commit blocks on-chain
if len(pendingVerifyAndExecuteBlocks) != 0 {
txHash, err := zkbas.VerifyAndExecuteBlocks(cli, authCli, zkbasInstance,
pendingVerifyAndExecuteBlocks, proofs, gasPrice, s.config.ChainConfig.GasLimit)
if err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] VerifyAndExecuteBlocks err: %v", err)
logx.Errorf("VerifyAndExecuteBlocks err: %v", err)
return err
}

Expand All @@ -494,14 +494,14 @@ func (s *Sender) VerifyAndExecuteBlocks() (err error) {
}
isValid, err := s.l1RollupTxModel.CreateL1RollupTx(newRollupTx)
if err != nil {
logx.Errorf("[SendVerifiedAndExecutedBlocks] CreateL1TxSender err: %v", err)
logx.Errorf("CreateL1TxSender err: %v", err)
return err
}
if !isValid {
logx.Errorf("[SendVerifiedAndExecutedBlocks] cannot create new senders")
return errors.New("[SendVerifiedAndExecutedBlocks] cannot create new senders")
logx.Errorf("cannot create new senders")
return errors.New("cannot create new senders")
}
logx.Errorf("[SendVerifiedAndExecutedBlocks] new blocks have been verified and executed(height): %d", newRollupTx.L2BlockHeight)
logx.Errorf("new blocks have been verified and executed(height): %d", newRollupTx.L2BlockHeight)
return nil
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type AccountInfo struct {
}

func (ai *AccountInfo) DeepCopy() (*AccountInfo, error) {
var assetInfo map[int64]*AccountAsset
assetInfo := make(map[int64]*AccountAsset)
for assetId, asset := range ai.AssetInfo {
assetInfo[assetId] = asset.DeepCopy()
}
Expand Down

0 comments on commit 7fe4c16

Please sign in to comment.