Skip to content

Commit

Permalink
feat(gas token): add BUSD token for l2 gas token
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinlink authored and cosinlink committed Oct 24, 2022
1 parent 3f7e8aa commit 0824e08
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ IMAGE_NAME=ghcr.io/bnb-chain/zkbnb
API_SERVER = ./service/apiserver

api-server:
cd $(API_SERVER) && ${GOBIN}/goctl api go -api server.api -dir .;
cd $(API_SERVER) && goctl api go -api server.api -dir .;
@echo "Done generate server api";

deploy:
Expand Down
7 changes: 1 addition & 6 deletions deploy-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,7 @@ cd ${DEPLOY_PATH}/zkbnb && go mod tidy
echo "6. init tables on database"
go run ./cmd/zkbnb/main.go db initialize --dsn "host=localhost user=postgres password=ZkBNB@123 dbname=zkbnb port=5432 sslmode=disable" --contractAddr ${DEPLOY_PATH}/zkbnb/tools/dbinitializer/contractaddr.yaml


cd ${DEPLOY_PATH}/zkbnb/
make api-server


sleep 30s
sleep 10s


echo "7. run prover"
Expand Down
1 change: 1 addition & 0 deletions tools/dbinitializer/contractaddr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ZnsControllerProxy: 0xa9702D6c08B353E120A882a266Cc8800d5A275a3
ZnsResolverProxy: 0x5735829b5B27f788Af29F93Ec883Ce8F7b02c808
ZkBNBProxy: 0x472236Cd542663AcDDF1fF8AC1269152BCE43826
UpgradeGateKeeper: 0x3B04DFD01a556BF9F44A30Be91A67A814e24eC99
BUSDToken: 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56
LEGToken: 0xe121f36A3F3118dC58A53CA895049106f4c4BC05
REYToken: 0xf112f442B5cA7272B5e11eeC0672a5CB32BF8C70
ERC721: 0x916Abe7836BA8361bB62Dc33EDE60d85D778568E
Expand Down
1 change: 1 addition & 0 deletions tools/dbinitializer/contractaddr.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ZnsControllerProxy: 0xa9702D6c08B353E120A882a266Cc8800d5A275a3
ZnsResolverProxy: 0x5735829b5B27f788Af29F93Ec883Ce8F7b02c808
ZkBNBProxy: 0x5A29E751E8C310849aEab8A274838929f29b75ca
UpgradeGateKeeper: 0x3B04DFD01a556BF9F44A30Be91A67A814e24eC99
BUSDToken: 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56
LEGToken: 0xe121f36A3F3118dC58A53CA895049106f4c4BC05
REYToken: 0xf112f442B5cA7272B5e11eeC0672a5CB32BF8C70
ERC721: 0x916Abe7836BA8361bB62Dc33EDE60d85D778568E
Expand Down
27 changes: 24 additions & 3 deletions tools/dbinitializer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type contractAddr struct {
ZnsResolverProxy string
ZkBNBProxy string
UpgradeGateKeeper string
BUSDToken string
LEGToken string
REYToken string
ERC721 string
Expand Down Expand Up @@ -129,8 +130,19 @@ func initSysConfig(svrConf *contractAddr, bscTestNetworkRPC, localTestNetworkRPC
bnbGasFee[types.TxTypeCancelOffer] = 12000000000000
bnbGasFee[types.TxTypeWithdrawNft] = 20000000000000

busdGasFee := make(map[int]int64)
busdGasFee[types.TxTypeTransfer] = 10000000000000
busdGasFee[types.TxTypeWithdraw] = 20000000000000
busdGasFee[types.TxTypeCreateCollection] = 10000000000000
busdGasFee[types.TxTypeMintNft] = 10000000000000
busdGasFee[types.TxTypeTransferNft] = 12000000000000
busdGasFee[types.TxTypeAtomicMatch] = 18000000000000
busdGasFee[types.TxTypeCancelOffer] = 12000000000000
busdGasFee[types.TxTypeWithdrawNft] = 20000000000000

gasFeeConfig := make(map[uint32]map[int]int64) // asset id -> (tx type -> gas fee value)
gasFeeConfig[types.BNBAssetId] = bnbGasFee // bnb asset
gasFeeConfig[types.BUSDAssetId] = busdGasFee // busd asset

gas, err := json.Marshal(gasFeeConfig)
if err != nil {
Expand Down Expand Up @@ -191,17 +203,26 @@ func initSysConfig(svrConf *contractAddr, bscTestNetworkRPC, localTestNetworkRPC
}
}

func initAssetsInfo() []*asset.Asset {
func initAssetsInfo(busdAddress string) []*asset.Asset {
return []*asset.Asset{
{
AssetId: 0,
AssetId: types.BNBAssetId,
L1Address: "0x00",
AssetName: "BNB",
AssetSymbol: "BNB",
Decimals: 18,
Status: 0,
IsGasAsset: asset.IsGasAsset,
},
{
AssetId: types.BUSDAssetId,
L1Address: busdAddress,
AssetName: "BUSD",
AssetSymbol: "BUSD",
Decimals: 18,
Status: 0,
IsGasAsset: asset.IsGasAsset,
},
}
}

Expand Down Expand Up @@ -241,7 +262,7 @@ func initTable(dao *dao, svrConf *contractAddr, bscTestNetworkRPC, localTestNetw
assert.Nil(nil, dao.l1RollupTModel.CreateL1RollupTxTable())
assert.Nil(nil, dao.nftModel.CreateL2NftTable())
assert.Nil(nil, dao.nftHistoryModel.CreateL2NftHistoryTable())
rowsAffected, err := dao.assetModel.CreateAssets(initAssetsInfo())
rowsAffected, err := dao.assetModel.CreateAssets(initAssetsInfo(svrConf.BUSDToken))
if err != nil {
panic(err)
}
Expand Down
5 changes: 3 additions & 2 deletions types/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ const (
NilExpiredAt = math.MaxInt64
NilAssetAmount = "0"

GasAccount = int64(1)
BNBAssetId = 0
GasAccount = int64(1)
BNBAssetId = 0
BUSDAssetId = 1
)

var (
Expand Down

0 comments on commit 0824e08

Please sign in to comment.