diff --git a/common/prove/change_pub_key.go b/common/prove/change_pub_key.go index 69089c204..9f48f3ccf 100644 --- a/common/prove/change_pub_key.go +++ b/common/prove/change_pub_key.go @@ -59,7 +59,6 @@ func toCryptoChangePubKeyTx(txInfo *txtypes.ChangePubKeyInfo) (info *cryptoTypes AccountIndex: txInfo.AccountIndex, L1Address: common.AddressStrToBytes(txInfo.L1Address), PubKey: pk, - Nonce: txInfo.Nonce, GasFeeAssetId: txInfo.GasFeeAssetId, GasFeeAssetAmount: packedFee, } diff --git a/common/prove/create_collection.go b/common/prove/create_collection.go index 3db0cac80..9b85e82b8 100644 --- a/common/prove/create_collection.go +++ b/common/prove/create_collection.go @@ -57,8 +57,6 @@ func toCryptoCreateCollectionTx(txInfo *txtypes.CreateCollectionTxInfo) (info *c GasAccountIndex: txInfo.GasAccountIndex, GasFeeAssetId: txInfo.GasFeeAssetId, GasFeeAssetAmount: packedFee, - ExpiredAt: txInfo.ExpiredAt, - Nonce: txInfo.Nonce, } return info, nil } diff --git a/common/prove/mint_nft.go b/common/prove/mint_nft.go index f2f56890f..a63047909 100644 --- a/common/prove/mint_nft.go +++ b/common/prove/mint_nft.go @@ -63,7 +63,6 @@ func toCryptoMintNftTx(txInfo *txtypes.MintNftTxInfo) (info *cryptoTypes.MintNft GasFeeAssetId: txInfo.GasFeeAssetId, GasFeeAssetAmount: packedFee, CollectionId: txInfo.NftCollectionId, - ExpiredAt: txInfo.ExpiredAt, NftContentType: txInfo.NftContentType, } return info, nil diff --git a/common/prove/withdraw.go b/common/prove/withdraw.go index a9a00664a..5a36d08d5 100644 --- a/common/prove/withdraw.go +++ b/common/prove/withdraw.go @@ -18,8 +18,6 @@ package prove import ( - "math/big" - "github.com/consensys/gnark-crypto/ecc/bn254/twistededwards/eddsa" cryptoTypes "github.com/bnb-chain/zkbnb-crypto/circuit/types" @@ -53,7 +51,6 @@ func toCryptoWithdrawTx(txInfo *txtypes.WithdrawTxInfo) (info *cryptoTypes.Withd if err != nil { return nil, err } - addrBytes := txtypes.PaddingAddressToBytes32(txInfo.ToAddress) info = &cryptoTypes.WithdrawTx{ FromAccountIndex: txInfo.FromAccountIndex, AssetId: txInfo.AssetId, @@ -61,7 +58,7 @@ func toCryptoWithdrawTx(txInfo *txtypes.WithdrawTxInfo) (info *cryptoTypes.Withd GasAccountIndex: txInfo.GasAccountIndex, GasFeeAssetId: txInfo.GasFeeAssetId, GasFeeAssetAmount: packedFee, - ToAddress: new(big.Int).SetBytes(addrBytes), + ToAddress: common.AddressStrToBytes(txInfo.ToAddress), } return info, nil } diff --git a/common/prove/withdraw_nft.go b/common/prove/withdraw_nft.go index 63c769012..2ef1061f9 100644 --- a/common/prove/withdraw_nft.go +++ b/common/prove/withdraw_nft.go @@ -58,7 +58,7 @@ func toCryptoWithdrawNftTx(txInfo *txtypes.WithdrawNftTxInfo) (info *cryptoTypes RoyaltyRate: txInfo.RoyaltyRate, NftIndex: txInfo.NftIndex, NftContentHash: txInfo.NftContentHash, - ToAddress: txInfo.ToAddress, + ToAddress: common.AddressStrToBytes(txInfo.ToAddress), GasAccountIndex: txInfo.GasAccountIndex, GasFeeAssetId: txInfo.GasFeeAssetId, GasFeeAssetAmount: packedFee, diff --git a/common/prove/witness_helper.go b/common/prove/witness_helper.go index 5893ed92b..d07e5e6a2 100644 --- a/common/prove/witness_helper.go +++ b/common/prove/witness_helper.go @@ -334,6 +334,7 @@ func (w *WitnessHelper) constructAccountWitness( w.gasAccountInfo.Nonce = nonce w.gasAccountInfo.CollectionNonce = collectionNonce w.gasAccountInfo.AssetRoot = common.Bytes2Hex(w.assetTrees.Get(accountKey).Root()) + w.gasAccountInfo.PublicKey = nPubKey } // set account info before @@ -841,6 +842,7 @@ func (w *WitnessHelper) ResetCache(height int64) error { gasAccount.CollectionNonce = history.CollectionNonce gasAccount.AssetInfo = history.AssetInfo gasAccount.AssetRoot = history.AssetRoot + gasAccount.PublicKey = history.PublicKey formatGasAccount, err := chain.ToFormatAccountInfo(gasAccount) if err != nil { return err diff --git a/go.mod b/go.mod index 98b70b9b8..4156bbc7e 100644 --- a/go.mod +++ b/go.mod @@ -197,7 +197,7 @@ require ( ) require ( - github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230605064829-ad6dbe39b843 + github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230627022843-b2a562cd2f69 github.com/bnb-chain/zkbnb-eth-rpc v0.0.3-0.20230605074525-1c3e46d3b694 github.com/bnb-chain/zkbnb-smt v0.0.3-0.20230519064631-0f9993341ee0 github.com/consensys/gnark v0.8.0 @@ -217,5 +217,4 @@ require ( replace ( github.com/consensys/gnark => github.com/bnb-chain/gnark v0.7.2-0.20230425010344-8e482963e1ae github.com/consensys/gnark-crypto => github.com/bnb-chain/gnark-crypto v0.8.1-0.20230412133626-30223a679fb7 - ) diff --git a/go.sum b/go.sum index 74cf4e506..f42c3f362 100644 --- a/go.sum +++ b/go.sum @@ -173,8 +173,8 @@ github.com/bnb-chain/gnark v0.7.2-0.20230425010344-8e482963e1ae h1:4b/b0pp1RAWQ6 github.com/bnb-chain/gnark v0.7.2-0.20230425010344-8e482963e1ae/go.mod h1:fmHUzzss1n32K3COWMvrQj7uo7GjIeIr1wXzjj5gmj8= github.com/bnb-chain/gnark-crypto v0.8.1-0.20230412133626-30223a679fb7 h1:ME5Nif4WgGgWKH2omB6ybic5bsU22bHy43xBsgMBHgM= github.com/bnb-chain/gnark-crypto v0.8.1-0.20230412133626-30223a679fb7/go.mod h1:a2DQL4+5ywF6safEeZFEPGRiiGbjzGFRUN2sg06VuU4= -github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230605064829-ad6dbe39b843 h1:mR62qjgA0HzH+Gal5DzjEYZ79zDGSwypko/LlwCIWhg= -github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230605064829-ad6dbe39b843/go.mod h1:Bi+kI5RYhV3Fgu6upQyAXz2HVxp+Ah9AzvwIBuBDYMM= +github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230627022843-b2a562cd2f69 h1:Nqt3ttCcUFVVl2rYRcfamIPGUpDVL/LEeURD57RtFRQ= +github.com/bnb-chain/zkbnb-crypto v0.0.8-0.20230627022843-b2a562cd2f69/go.mod h1:Bi+kI5RYhV3Fgu6upQyAXz2HVxp+Ah9AzvwIBuBDYMM= github.com/bnb-chain/zkbnb-eth-rpc v0.0.3-0.20230605074525-1c3e46d3b694 h1:UeTRF5m2TmCXFTaMxbwhY5PYp5QYFyXv5+MGCCb1L28= github.com/bnb-chain/zkbnb-eth-rpc v0.0.3-0.20230605074525-1c3e46d3b694/go.mod h1:zZ9uTj1GJOc5OxgojQbA8TZjEQhESUnp4MEWOYk/OVs= github.com/bnb-chain/zkbnb-go-sdk v1.0.7-0.20230522134048-bcfa8070ef7e h1:jwUKimro0Rgv0kO7yenoVvL5BaEXxGZ7JZddX45m+FY= diff --git a/service/apiserver/internal/logic/asset/getassetlogic.go b/service/apiserver/internal/logic/asset/getassetlogic.go index 128fe0aee..9a1977f93 100644 --- a/service/apiserver/internal/logic/asset/getassetlogic.go +++ b/service/apiserver/internal/logic/asset/getassetlogic.go @@ -18,7 +18,8 @@ const ( queryBySymbol = "symbol" // iconBaseUrl is used for showing icons for assets, asset owners should upload png files to the github repo - iconBaseUrl = "https://teststatic.zkbnbchain.org/shared/icon/coin/%s.svg" + //iconBaseUrl = "https://teststatic.zkbnbchain.org/shared/icon/coin/%s.svg" + iconBaseUrl = "https://zkbnb-static-cdn.bnbchain.org/shared/icon/coin/%s.svg" ) type GetAssetLogic struct { diff --git a/service/sender/sender/sender.go b/service/sender/sender/sender.go index 01d1ff509..cd06c29bc 100644 --- a/service/sender/sender/sender.go +++ b/service/sender/sender/sender.go @@ -1467,13 +1467,13 @@ func (s *Sender) getZkBnbClient(cli *rpc.ProviderClient) *zkbnb.ZkBNBClient { logx.Severef("fatal error, GenerateConstructorForCommit raises error:%v", err) panic("fatal error, GenerateConstructorForCommit raises error:" + err.Error()) } - logx.Info("commit address from CommitKeyId,value is :%s", commitConstructor.GetL1Address().Hex()) + logx.Infof("commit address from CommitKeyId,value is :%s", commitConstructor.GetL1Address().Hex()) verifyConstructor, err := s.GenerateConstructorForVerifyAndExecute() if err != nil { logx.Severef("fatal error, GenerateConstructorForVerifyAndExecute raises error:%v", err) panic("fatal error, GenerateConstructorForVerifyAndExecute raises error:" + err.Error()) } - logx.Info("verify address from VerifyKeyId,value is :%s", verifyConstructor.GetL1Address().Hex()) + logx.Infof("verify address from VerifyKeyId,value is :%s", verifyConstructor.GetL1Address().Hex()) zkBnbClient, err := zkbnb.NewZkBNBClient(cli, s.ZkBNBContractAddress) if err != nil { diff --git a/tools/desertexit/desertexit/perform_desert.go b/tools/desertexit/desertexit/perform_desert.go index 32fb9da8a..fa5714dfb 100644 --- a/tools/desertexit/desertexit/perform_desert.go +++ b/tools/desertexit/desertexit/perform_desert.go @@ -170,14 +170,14 @@ func (m *PerformDesert) WithdrawPendingBalance(owner common.Address, token commo logx.Errorf("failed to get pending balance: %v", err) return err } - logx.Infof("get pending balance,pendingBalanceBefore=%d", pendingBalanceBefore.Int64()) + logx.Infof("get pending balance,pendingBalanceBefore=%s", pendingBalanceBefore.String()) balanceBefore, err := m.GetBalance(owner, token) if err != nil { logx.Errorf("failed to get balance: %v", err) return err } - logx.Infof("get balance,balanceBefore=%d", balanceBefore.Int64()) + logx.Infof("get balance,balanceBefore=%s", balanceBefore.String()) gasPrice, err := m.cli.SuggestGasPrice(context.Background()) if err != nil { @@ -202,7 +202,7 @@ func (m *PerformDesert) WithdrawPendingBalance(owner common.Address, token commo logx.Errorf("failed to get pending balance: %v", err) return err } - logx.Infof("get pending balance,pendingBalanceAfter=%d", pendingBalanceAfter.Int64()) + logx.Infof("get pending balance,pendingBalanceAfter=%s", pendingBalanceAfter.String()) //time.Sleep(30 * time.Second) balanceAfter, err := m.GetBalance(owner, token) @@ -210,7 +210,7 @@ func (m *PerformDesert) WithdrawPendingBalance(owner common.Address, token commo logx.Errorf("failed to get balance: %v", err) return err } - logx.Infof("get balance,balanceAfter=%d", balanceAfter.Int64()) + logx.Infof("get balance,balanceAfter=%s", balanceAfter.String()) return nil } @@ -356,7 +356,7 @@ func (m *PerformDesert) GetBalance(address common.Address, assetAddr common.Addr if err != nil { return nil, err } - logx.Infof("get balance,balance=%d", amount.Int64()) + logx.Infof("get balance,balance=%s", amount.String()) return amount, nil } @@ -370,7 +370,7 @@ func (m *PerformDesert) GetBalance(address common.Address, assetAddr common.Addr if err != nil { return nil, err } - logx.Infof("get balance,balance=%d", amount.Int64()) + logx.Infof("get balance,balance=%s", amount.String()) return amount, nil } @@ -380,7 +380,7 @@ func (m *PerformDesert) GetPendingBalance(address common.Address, token common.A logx.Errorf("failed to get pending balance: %v", err) return nil, err } - logx.Infof("get pending balance,pendingBalance=%d", amount.Int64()) + logx.Infof("get pending balance,pendingBalance=%s", amount.String()) return amount, nil } @@ -414,6 +414,7 @@ func (m *PerformDesert) checkTxSuccess(txHash string) error { if time.Now().After(startDate.Add(time.Duration(m.Config.ChainConfig.MaxWaitingTime) * time.Second)) { return fmt.Errorf("failed to sent tx, tx_hash=%s,error=%s", txHash, err) } + time.Sleep(3*time.Second) continue } diff --git a/tools/desertexit/desertexit/witness.go b/tools/desertexit/desertexit/witness.go index 2f2a4d14c..f46400af8 100644 --- a/tools/desertexit/desertexit/witness.go +++ b/tools/desertexit/desertexit/witness.go @@ -4,7 +4,9 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" + "github.com/bnb-chain/zkbnb-crypto/circuit" "github.com/bnb-chain/zkbnb-crypto/circuit/desert" desertTypes "github.com/bnb-chain/zkbnb-crypto/circuit/desert/types" @@ -161,6 +163,10 @@ func (c *GenerateProof) generateWitness(blockHeight int64, accountIndex int64, n pubData = GenerateExitPubData(exitTxInfo) } else { nftInfo, err := c.bc.DB().L2NftModel.GetNft(nftIndex) + if err != nil { + logx.Errorf("get nft failed: %s", err) + return desertInfo, pubData, err + } nft = &cryptoTypes.Nft{ NftIndex: nftInfo.NftIndex, NftContentHash: common.FromHex(nftInfo.NftContentHash), @@ -170,9 +176,9 @@ func (c *GenerateProof) generateWitness(blockHeight int64, accountIndex int64, n CollectionId: nftInfo.CollectionId, NftContentType: nftInfo.NftContentType, } - if err != nil { - logx.Errorf("get nft failed: %s", err) - return desertInfo, pubData, err + if nftInfo.NftContentHash == "0" { + logx.Errorf("nft %d is already withdrawed to L1", nft.NftIndex) + return desertInfo, pubData, errors.New(fmt.Sprintf("Nft %d Already withdrawed to L1", nft.NftIndex)) } nftMerkleProofs, err := nftTree.GetProof(uint64(nftIndex)) if err != nil {