common: not copy constants.go for compatibility

This commit is contained in:
Daniel Liu 2025-02-20 09:54:00 +08:00
parent 6217d1e3fb
commit 01bd024bfb
5 changed files with 221 additions and 756 deletions

190
common/constants.all.go Normal file
View file

@ -0,0 +1,190 @@
package common
import (
"maps"
"math/big"
)
// non-const variables for all network.
var (
IsTestnet bool = false
Enable0xPrefix bool = true
Rewound = uint64(0)
RollbackHash Hash
StoreRewardFolder string
TRC21GasPriceBefore = big.NewInt(2500)
TRC21GasPrice = big.NewInt(250000000)
MinGasPrice = big.NewInt(DefaultMinGasPrice)
// XDCx and XDCxlending
BasePrice = big.NewInt(1000000000000000000) // 1
RelayerLockedFund = big.NewInt(20000) // 20000 XDC
XDCXBaseFee = big.NewInt(10000) // 1 / XDCXBaseFee
XDCXBaseCancelFee = new(big.Int).Mul(XDCXBaseFee, big.NewInt(10)) // 1/ (XDCXBaseFee *10)
// XDCx
RelayerFee = big.NewInt(1000000000000000) // 0.001
RelayerCancelFee = big.NewInt(100000000000000) // 0.0001
// XDCxlending
RateTopUp = big.NewInt(90) // 90%
BaseTopUp = big.NewInt(100)
BaseRecall = big.NewInt(100)
BaseLendingInterest = big.NewInt(100000000) // 1e8
RelayerLendingFee = big.NewInt(10000000000000000) // 0.01
RelayerLendingCancelFee = big.NewInt(1000000000000000) // 0.001
)
type constant struct {
chainID uint64
blackListHFNumber uint64
maxMasternodesV2 int // Last v1 masternodes
tip2019Block *big.Int
tipSigning *big.Int
tipRandomize *big.Int
tipNoHalvingMNReward *big.Int // hardfork no halving masternodes reward
tipXDCX *big.Int
tipXDCXLending *big.Int
tipXDCXCancellationFee *big.Int
tipXDCXCancellationFeeTestnet *big.Int
tipTRC21Fee *big.Int
tipTRC21FeeTestnet *big.Int
tipIncreaseMasternodes *big.Int // Upgrade MN Count at Block.
berlinBlock *big.Int
londonBlock *big.Int
mergeBlock *big.Int
shanghaiBlock *big.Int
blockNumberGas50x *big.Int
TIPV2SwitchBlock *big.Int
tipXDCXMinerDisable *big.Int
tipXDCXReceiverDisable *big.Int
eip1559Block *big.Int
cancunBlock *big.Int
trc21IssuerSMCTestNet Address
trc21IssuerSMC Address
xdcxListingSMC Address
xdcxListingSMCTestNet Address
relayerRegistrationSMC Address
relayerRegistrationSMCTestnet Address
lendingRegistrationSMC Address
lendingRegistrationSMCTestnet Address
ignoreSignerCheckBlockArray map[uint64]struct{}
blacklist map[Address]struct{}
}
// variables for specific networks, copy values from MaintnetConstant to pass tests
var (
BlackListHFNumber = MaintnetConstant.blackListHFNumber
MaxMasternodesV2 = MaintnetConstant.maxMasternodesV2 // Last v1 masternodes
TIP2019Block = MaintnetConstant.tip2019Block
TIPSigning = MaintnetConstant.tipSigning
TIPRandomize = MaintnetConstant.tipRandomize
TIPNoHalvingMNReward = MaintnetConstant.tipNoHalvingMNReward
TIPXDCX = MaintnetConstant.tipXDCX
TIPXDCXLending = MaintnetConstant.tipXDCXLending
TIPXDCXCancellationFee = MaintnetConstant.tipXDCXCancellationFee
TIPXDCXCancellationFeeTestnet = MaintnetConstant.tipXDCXCancellationFeeTestnet
TIPTRC21Fee = MaintnetConstant.tipTRC21Fee
TIPTRC21FeeTestnet = MaintnetConstant.tipTRC21FeeTestnet
TIPIncreaseMasternodes = MaintnetConstant.tipIncreaseMasternodes
BerlinBlock = MaintnetConstant.berlinBlock
LondonBlock = MaintnetConstant.londonBlock
MergeBlock = MaintnetConstant.mergeBlock
ShanghaiBlock = MaintnetConstant.shanghaiBlock
BlockNumberGas50x = MaintnetConstant.blockNumberGas50x
TIPXDCXMinerDisable = MaintnetConstant.tipXDCXMinerDisable
TIPXDCXReceiverDisable = MaintnetConstant.tipXDCXReceiverDisable
Eip1559Block = MaintnetConstant.eip1559Block
CancunBlock = MaintnetConstant.cancunBlock
TRC21IssuerSMCTestNet = MaintnetConstant.trc21IssuerSMCTestNet
TRC21IssuerSMC = MaintnetConstant.trc21IssuerSMC
XDCXListingSMC = MaintnetConstant.xdcxListingSMC
XDCXListingSMCTestNet = MaintnetConstant.xdcxListingSMCTestNet
RelayerRegistrationSMC = MaintnetConstant.relayerRegistrationSMC
RelayerRegistrationSMCTestnet = MaintnetConstant.relayerRegistrationSMCTestnet
LendingRegistrationSMC = MaintnetConstant.lendingRegistrationSMC
LendingRegistrationSMCTestnet = MaintnetConstant.lendingRegistrationSMCTestnet
ignoreSignerCheckBlockArray = MaintnetConstant.ignoreSignerCheckBlockArray
blacklist = MaintnetConstant.blacklist
)
func IsIgnoreSignerCheckBlock(blockNumber uint64) bool {
_, ok := ignoreSignerCheckBlockArray[blockNumber]
return ok
}
func IsInBlacklist(address *Address) bool {
if address == nil {
return false
}
_, ok := blacklist[*address]
return ok
}
// CopyConstans only handles testnet, devnet, local. It does not
// handles mainnet since the default value is from mainnet.
func CopyConstans(chainID uint64) {
var c *constant
if chainID == TestnetConstant.chainID {
c = &TestnetConstant
IsTestnet = true
} else if chainID == DevnetConstant.chainID {
c = &DevnetConstant
} else if chainID == localConstant.chainID {
c = &localConstant
} else {
return
}
MaxMasternodesV2 = c.maxMasternodesV2
BlackListHFNumber = c.blackListHFNumber
TIP2019Block = c.tip2019Block
TIPSigning = c.tipSigning
TIPRandomize = c.tipRandomize
TIPNoHalvingMNReward = c.tipNoHalvingMNReward
TIPXDCX = c.tipXDCX
TIPXDCXLending = c.tipXDCXLending
TIPXDCXCancellationFee = c.tipXDCXCancellationFee
TIPXDCXCancellationFeeTestnet = c.tipXDCXCancellationFeeTestnet
TIPTRC21Fee = c.tipTRC21Fee
TIPTRC21FeeTestnet = c.tipTRC21FeeTestnet
TIPIncreaseMasternodes = c.tipIncreaseMasternodes
BerlinBlock = c.berlinBlock
LondonBlock = c.londonBlock
MergeBlock = c.mergeBlock
ShanghaiBlock = c.shanghaiBlock
BlockNumberGas50x = c.blockNumberGas50x
TIPXDCXMinerDisable = c.tipXDCXMinerDisable
TIPXDCXReceiverDisable = c.tipXDCXReceiverDisable
Eip1559Block = c.eip1559Block
CancunBlock = c.cancunBlock
TRC21IssuerSMCTestNet = c.trc21IssuerSMCTestNet
TRC21IssuerSMC = c.trc21IssuerSMC
XDCXListingSMC = c.xdcxListingSMC
XDCXListingSMCTestNet = c.xdcxListingSMCTestNet
RelayerRegistrationSMC = c.relayerRegistrationSMC
RelayerRegistrationSMCTestnet = c.relayerRegistrationSMCTestnet
LendingRegistrationSMC = c.lendingRegistrationSMC
LendingRegistrationSMCTestnet = c.lendingRegistrationSMCTestnet
clear(ignoreSignerCheckBlockArray)
maps.Copy(ignoreSignerCheckBlockArray, c.ignoreSignerCheckBlockArray)
clear(blacklist)
maps.Copy(blacklist, c.blacklist)
}

View file

@ -1,10 +1,12 @@
// Notice: this file only saves const variables for all network.
// Please run the following commands after modify this file:
// cp common/constants.go common/constants/constants.go.testnet
// cp common/constants.go common/constants/constants.go.devnet
// cp common/constants.go common/constants/constants.go.local
package common
import (
"maps"
"math/big"
)
// const variables for all network.
const (
RewardMasterPercent = 90
RewardVoterPercent = 0
@ -30,187 +32,3 @@ const (
HexSetSecret = "34d38600"
HexSetOpening = "e11f5ba2"
)
// variables for all network.
var (
IsTestnet bool = false
Enable0xPrefix bool = true
Rewound = uint64(0)
RollbackHash Hash
StoreRewardFolder string
TRC21GasPriceBefore = big.NewInt(2500)
TRC21GasPrice = big.NewInt(250000000)
MinGasPrice = big.NewInt(DefaultMinGasPrice)
// XDCx and XDCxlending
BasePrice = big.NewInt(1000000000000000000) // 1
RelayerLockedFund = big.NewInt(20000) // 20000 XDC
XDCXBaseFee = big.NewInt(10000) // 1 / XDCXBaseFee
XDCXBaseCancelFee = new(big.Int).Mul(XDCXBaseFee, big.NewInt(10)) // 1/ (XDCXBaseFee *10)
// XDCx
RelayerFee = big.NewInt(1000000000000000) // 0.001
RelayerCancelFee = big.NewInt(100000000000000) // 0.0001
// XDCxlending
RateTopUp = big.NewInt(90) // 90%
BaseTopUp = big.NewInt(100)
BaseRecall = big.NewInt(100)
BaseLendingInterest = big.NewInt(100000000) // 1e8
RelayerLendingFee = big.NewInt(10000000000000000) // 0.01
RelayerLendingCancelFee = big.NewInt(1000000000000000) // 0.001
)
type constant struct {
chainID uint64
blackListHFNumber uint64
maxMasternodesV2 int // Last v1 masternodes
tip2019Block *big.Int
tipSigning *big.Int
tipRandomize *big.Int
tipNoHalvingMNReward *big.Int // hardfork no halving masternodes reward
tipXDCX *big.Int
tipXDCXLending *big.Int
tipXDCXCancellationFee *big.Int
tipXDCXCancellationFeeTestnet *big.Int
tipTRC21Fee *big.Int
tipTRC21FeeTestnet *big.Int
tipIncreaseMasternodes *big.Int // Upgrade MN Count at Block.
berlinBlock *big.Int
londonBlock *big.Int
mergeBlock *big.Int
shanghaiBlock *big.Int
blockNumberGas50x *big.Int
TIPV2SwitchBlock *big.Int
tipXDCXMinerDisable *big.Int
tipXDCXReceiverDisable *big.Int
eip1559Block *big.Int
cancunBlock *big.Int
trc21IssuerSMCTestNet Address
trc21IssuerSMC Address
xdcxListingSMC Address
xdcxListingSMCTestNet Address
relayerRegistrationSMC Address
relayerRegistrationSMCTestnet Address
lendingRegistrationSMC Address
lendingRegistrationSMCTestnet Address
ignoreSignerCheckBlockArray map[uint64]struct{}
blacklist map[Address]struct{}
}
// variables for specific networks, copy values from MaintnetConstant to pass tests
var (
BlackListHFNumber = MaintnetConstant.blackListHFNumber
MaxMasternodesV2 = MaintnetConstant.maxMasternodesV2 // Last v1 masternodes
TIP2019Block = MaintnetConstant.tip2019Block
TIPSigning = MaintnetConstant.tipSigning
TIPRandomize = MaintnetConstant.tipRandomize
TIPNoHalvingMNReward = MaintnetConstant.tipNoHalvingMNReward
TIPXDCX = MaintnetConstant.tipXDCX
TIPXDCXLending = MaintnetConstant.tipXDCXLending
TIPXDCXCancellationFee = MaintnetConstant.tipXDCXCancellationFee
TIPXDCXCancellationFeeTestnet = MaintnetConstant.tipXDCXCancellationFeeTestnet
TIPTRC21Fee = MaintnetConstant.tipTRC21Fee
TIPTRC21FeeTestnet = MaintnetConstant.tipTRC21FeeTestnet
TIPIncreaseMasternodes = MaintnetConstant.tipIncreaseMasternodes
BerlinBlock = MaintnetConstant.berlinBlock
LondonBlock = MaintnetConstant.londonBlock
MergeBlock = MaintnetConstant.mergeBlock
ShanghaiBlock = MaintnetConstant.shanghaiBlock
BlockNumberGas50x = MaintnetConstant.blockNumberGas50x
TIPXDCXMinerDisable = MaintnetConstant.tipXDCXMinerDisable
TIPXDCXReceiverDisable = MaintnetConstant.tipXDCXReceiverDisable
Eip1559Block = MaintnetConstant.eip1559Block
CancunBlock = MaintnetConstant.cancunBlock
TRC21IssuerSMCTestNet = MaintnetConstant.trc21IssuerSMCTestNet
TRC21IssuerSMC = MaintnetConstant.trc21IssuerSMC
XDCXListingSMC = MaintnetConstant.xdcxListingSMC
XDCXListingSMCTestNet = MaintnetConstant.xdcxListingSMCTestNet
RelayerRegistrationSMC = MaintnetConstant.relayerRegistrationSMC
RelayerRegistrationSMCTestnet = MaintnetConstant.relayerRegistrationSMCTestnet
LendingRegistrationSMC = MaintnetConstant.lendingRegistrationSMC
LendingRegistrationSMCTestnet = MaintnetConstant.lendingRegistrationSMCTestnet
ignoreSignerCheckBlockArray = MaintnetConstant.ignoreSignerCheckBlockArray
blacklist = MaintnetConstant.blacklist
)
func IsIgnoreSignerCheckBlock(blockNumber uint64) bool {
_, ok := ignoreSignerCheckBlockArray[blockNumber]
return ok
}
func IsInBlacklist(address *Address) bool {
if address == nil {
return false
}
_, ok := blacklist[*address]
return ok
}
// CopyConstans only handles testnet, devnet, local. It does not
// handles mainnet since the default value is from mainnet.
func CopyConstans(chainID uint64) {
var c *constant
if chainID == TestnetConstant.chainID {
c = &TestnetConstant
IsTestnet = true
} else if chainID == DevnetConstant.chainID {
c = &DevnetConstant
} else if chainID == localConstant.chainID {
c = &localConstant
} else {
return
}
MaxMasternodesV2 = c.maxMasternodesV2
BlackListHFNumber = c.blackListHFNumber
TIP2019Block = c.tip2019Block
TIPSigning = c.tipSigning
TIPRandomize = c.tipRandomize
TIPNoHalvingMNReward = c.tipNoHalvingMNReward
TIPXDCX = c.tipXDCX
TIPXDCXLending = c.tipXDCXLending
TIPXDCXCancellationFee = c.tipXDCXCancellationFee
TIPXDCXCancellationFeeTestnet = c.tipXDCXCancellationFeeTestnet
TIPTRC21Fee = c.tipTRC21Fee
TIPTRC21FeeTestnet = c.tipTRC21FeeTestnet
TIPIncreaseMasternodes = c.tipIncreaseMasternodes
BerlinBlock = c.berlinBlock
LondonBlock = c.londonBlock
MergeBlock = c.mergeBlock
ShanghaiBlock = c.shanghaiBlock
BlockNumberGas50x = c.blockNumberGas50x
TIPXDCXMinerDisable = c.tipXDCXMinerDisable
TIPXDCXReceiverDisable = c.tipXDCXReceiverDisable
Eip1559Block = c.eip1559Block
CancunBlock = c.cancunBlock
TRC21IssuerSMCTestNet = c.trc21IssuerSMCTestNet
TRC21IssuerSMC = c.trc21IssuerSMC
XDCXListingSMC = c.xdcxListingSMC
XDCXListingSMCTestNet = c.xdcxListingSMCTestNet
RelayerRegistrationSMC = c.relayerRegistrationSMC
RelayerRegistrationSMCTestnet = c.relayerRegistrationSMCTestnet
LendingRegistrationSMC = c.lendingRegistrationSMC
LendingRegistrationSMCTestnet = c.lendingRegistrationSMCTestnet
clear(ignoreSignerCheckBlockArray)
maps.Copy(ignoreSignerCheckBlockArray, c.ignoreSignerCheckBlockArray)
clear(blacklist)
maps.Copy(blacklist, c.blacklist)
}

View file

@ -1,10 +1,13 @@
// Notice: this file only saves const variables for all network.
// Please run the following commands after modify this file:
//
// cp common/constants.go common/constants/constants.go.devnet
// cp common/constants.go common/constants/constants.go.testnet
// cp common/constants.go common/constants/constants.go.local
package common
import (
"maps"
"math/big"
)
// const variables for all network.
const (
RewardMasterPercent = 90
RewardVoterPercent = 0
@ -30,187 +33,3 @@ const (
HexSetSecret = "34d38600"
HexSetOpening = "e11f5ba2"
)
// variables for all network.
var (
IsTestnet bool = false
Enable0xPrefix bool = true
Rewound = uint64(0)
RollbackHash Hash
StoreRewardFolder string
TRC21GasPriceBefore = big.NewInt(2500)
TRC21GasPrice = big.NewInt(250000000)
MinGasPrice = big.NewInt(DefaultMinGasPrice)
// XDCx and XDCxlending
BasePrice = big.NewInt(1000000000000000000) // 1
RelayerLockedFund = big.NewInt(20000) // 20000 XDC
XDCXBaseFee = big.NewInt(10000) // 1 / XDCXBaseFee
XDCXBaseCancelFee = new(big.Int).Mul(XDCXBaseFee, big.NewInt(10)) // 1/ (XDCXBaseFee *10)
// XDCx
RelayerFee = big.NewInt(1000000000000000) // 0.001
RelayerCancelFee = big.NewInt(100000000000000) // 0.0001
// XDCxlending
RateTopUp = big.NewInt(90) // 90%
BaseTopUp = big.NewInt(100)
BaseRecall = big.NewInt(100)
BaseLendingInterest = big.NewInt(100000000) // 1e8
RelayerLendingFee = big.NewInt(10000000000000000) // 0.01
RelayerLendingCancelFee = big.NewInt(1000000000000000) // 0.001
)
type constant struct {
chainID uint64
blackListHFNumber uint64
maxMasternodesV2 int // Last v1 masternodes
tip2019Block *big.Int
tipSigning *big.Int
tipRandomize *big.Int
tipNoHalvingMNReward *big.Int // hardfork no halving masternodes reward
tipXDCX *big.Int
tipXDCXLending *big.Int
tipXDCXCancellationFee *big.Int
tipXDCXCancellationFeeTestnet *big.Int
tipTRC21Fee *big.Int
tipTRC21FeeTestnet *big.Int
tipIncreaseMasternodes *big.Int // Upgrade MN Count at Block.
berlinBlock *big.Int
londonBlock *big.Int
mergeBlock *big.Int
shanghaiBlock *big.Int
blockNumberGas50x *big.Int
TIPV2SwitchBlock *big.Int
tipXDCXMinerDisable *big.Int
tipXDCXReceiverDisable *big.Int
eip1559Block *big.Int
cancunBlock *big.Int
trc21IssuerSMCTestNet Address
trc21IssuerSMC Address
xdcxListingSMC Address
xdcxListingSMCTestNet Address
relayerRegistrationSMC Address
relayerRegistrationSMCTestnet Address
lendingRegistrationSMC Address
lendingRegistrationSMCTestnet Address
ignoreSignerCheckBlockArray map[uint64]struct{}
blacklist map[Address]struct{}
}
// variables for specific networks, copy values from MaintnetConstant to pass tests
var (
BlackListHFNumber = MaintnetConstant.blackListHFNumber
MaxMasternodesV2 = MaintnetConstant.maxMasternodesV2 // Last v1 masternodes
TIP2019Block = MaintnetConstant.tip2019Block
TIPSigning = MaintnetConstant.tipSigning
TIPRandomize = MaintnetConstant.tipRandomize
TIPNoHalvingMNReward = MaintnetConstant.tipNoHalvingMNReward
TIPXDCX = MaintnetConstant.tipXDCX
TIPXDCXLending = MaintnetConstant.tipXDCXLending
TIPXDCXCancellationFee = MaintnetConstant.tipXDCXCancellationFee
TIPXDCXCancellationFeeTestnet = MaintnetConstant.tipXDCXCancellationFeeTestnet
TIPTRC21Fee = MaintnetConstant.tipTRC21Fee
TIPTRC21FeeTestnet = MaintnetConstant.tipTRC21FeeTestnet
TIPIncreaseMasternodes = MaintnetConstant.tipIncreaseMasternodes
BerlinBlock = MaintnetConstant.berlinBlock
LondonBlock = MaintnetConstant.londonBlock
MergeBlock = MaintnetConstant.mergeBlock
ShanghaiBlock = MaintnetConstant.shanghaiBlock
BlockNumberGas50x = MaintnetConstant.blockNumberGas50x
TIPXDCXMinerDisable = MaintnetConstant.tipXDCXMinerDisable
TIPXDCXReceiverDisable = MaintnetConstant.tipXDCXReceiverDisable
Eip1559Block = MaintnetConstant.eip1559Block
CancunBlock = MaintnetConstant.cancunBlock
TRC21IssuerSMCTestNet = MaintnetConstant.trc21IssuerSMCTestNet
TRC21IssuerSMC = MaintnetConstant.trc21IssuerSMC
XDCXListingSMC = MaintnetConstant.xdcxListingSMC
XDCXListingSMCTestNet = MaintnetConstant.xdcxListingSMCTestNet
RelayerRegistrationSMC = MaintnetConstant.relayerRegistrationSMC
RelayerRegistrationSMCTestnet = MaintnetConstant.relayerRegistrationSMCTestnet
LendingRegistrationSMC = MaintnetConstant.lendingRegistrationSMC
LendingRegistrationSMCTestnet = MaintnetConstant.lendingRegistrationSMCTestnet
ignoreSignerCheckBlockArray = MaintnetConstant.ignoreSignerCheckBlockArray
blacklist = MaintnetConstant.blacklist
)
func IsIgnoreSignerCheckBlock(blockNumber uint64) bool {
_, ok := ignoreSignerCheckBlockArray[blockNumber]
return ok
}
func IsInBlacklist(address *Address) bool {
if address == nil {
return false
}
_, ok := blacklist[*address]
return ok
}
// CopyConstans only handles testnet, devnet, local. It does not
// handles mainnet since the default value is from mainnet.
func CopyConstans(chainID uint64) {
var c *constant
if chainID == TestnetConstant.chainID {
c = &TestnetConstant
IsTestnet = true
} else if chainID == DevnetConstant.chainID {
c = &DevnetConstant
} else if chainID == localConstant.chainID {
c = &localConstant
} else {
return
}
MaxMasternodesV2 = c.maxMasternodesV2
BlackListHFNumber = c.blackListHFNumber
TIP2019Block = c.tip2019Block
TIPSigning = c.tipSigning
TIPRandomize = c.tipRandomize
TIPNoHalvingMNReward = c.tipNoHalvingMNReward
TIPXDCX = c.tipXDCX
TIPXDCXLending = c.tipXDCXLending
TIPXDCXCancellationFee = c.tipXDCXCancellationFee
TIPXDCXCancellationFeeTestnet = c.tipXDCXCancellationFeeTestnet
TIPTRC21Fee = c.tipTRC21Fee
TIPTRC21FeeTestnet = c.tipTRC21FeeTestnet
TIPIncreaseMasternodes = c.tipIncreaseMasternodes
BerlinBlock = c.berlinBlock
LondonBlock = c.londonBlock
MergeBlock = c.mergeBlock
ShanghaiBlock = c.shanghaiBlock
BlockNumberGas50x = c.blockNumberGas50x
TIPXDCXMinerDisable = c.tipXDCXMinerDisable
TIPXDCXReceiverDisable = c.tipXDCXReceiverDisable
Eip1559Block = c.eip1559Block
CancunBlock = c.cancunBlock
TRC21IssuerSMCTestNet = c.trc21IssuerSMCTestNet
TRC21IssuerSMC = c.trc21IssuerSMC
XDCXListingSMC = c.xdcxListingSMC
XDCXListingSMCTestNet = c.xdcxListingSMCTestNet
RelayerRegistrationSMC = c.relayerRegistrationSMC
RelayerRegistrationSMCTestnet = c.relayerRegistrationSMCTestnet
LendingRegistrationSMC = c.lendingRegistrationSMC
LendingRegistrationSMCTestnet = c.lendingRegistrationSMCTestnet
clear(ignoreSignerCheckBlockArray)
maps.Copy(ignoreSignerCheckBlockArray, c.ignoreSignerCheckBlockArray)
clear(blacklist)
maps.Copy(blacklist, c.blacklist)
}

View file

@ -1,10 +1,13 @@
// Notice: this file only saves const variables for all network.
// Please run the following commands after modify this file:
//
// cp common/constants.go common/constants/constants.go.devnet
// cp common/constants.go common/constants/constants.go.testnet
// cp common/constants.go common/constants/constants.go.local
package common
import (
"maps"
"math/big"
)
// const variables for all network.
const (
RewardMasterPercent = 90
RewardVoterPercent = 0
@ -30,187 +33,3 @@ const (
HexSetSecret = "34d38600"
HexSetOpening = "e11f5ba2"
)
// variables for all network.
var (
IsTestnet bool = false
Enable0xPrefix bool = true
Rewound = uint64(0)
RollbackHash Hash
StoreRewardFolder string
TRC21GasPriceBefore = big.NewInt(2500)
TRC21GasPrice = big.NewInt(250000000)
MinGasPrice = big.NewInt(DefaultMinGasPrice)
// XDCx and XDCxlending
BasePrice = big.NewInt(1000000000000000000) // 1
RelayerLockedFund = big.NewInt(20000) // 20000 XDC
XDCXBaseFee = big.NewInt(10000) // 1 / XDCXBaseFee
XDCXBaseCancelFee = new(big.Int).Mul(XDCXBaseFee, big.NewInt(10)) // 1/ (XDCXBaseFee *10)
// XDCx
RelayerFee = big.NewInt(1000000000000000) // 0.001
RelayerCancelFee = big.NewInt(100000000000000) // 0.0001
// XDCxlending
RateTopUp = big.NewInt(90) // 90%
BaseTopUp = big.NewInt(100)
BaseRecall = big.NewInt(100)
BaseLendingInterest = big.NewInt(100000000) // 1e8
RelayerLendingFee = big.NewInt(10000000000000000) // 0.01
RelayerLendingCancelFee = big.NewInt(1000000000000000) // 0.001
)
type constant struct {
chainID uint64
blackListHFNumber uint64
maxMasternodesV2 int // Last v1 masternodes
tip2019Block *big.Int
tipSigning *big.Int
tipRandomize *big.Int
tipNoHalvingMNReward *big.Int // hardfork no halving masternodes reward
tipXDCX *big.Int
tipXDCXLending *big.Int
tipXDCXCancellationFee *big.Int
tipXDCXCancellationFeeTestnet *big.Int
tipTRC21Fee *big.Int
tipTRC21FeeTestnet *big.Int
tipIncreaseMasternodes *big.Int // Upgrade MN Count at Block.
berlinBlock *big.Int
londonBlock *big.Int
mergeBlock *big.Int
shanghaiBlock *big.Int
blockNumberGas50x *big.Int
TIPV2SwitchBlock *big.Int
tipXDCXMinerDisable *big.Int
tipXDCXReceiverDisable *big.Int
eip1559Block *big.Int
cancunBlock *big.Int
trc21IssuerSMCTestNet Address
trc21IssuerSMC Address
xdcxListingSMC Address
xdcxListingSMCTestNet Address
relayerRegistrationSMC Address
relayerRegistrationSMCTestnet Address
lendingRegistrationSMC Address
lendingRegistrationSMCTestnet Address
ignoreSignerCheckBlockArray map[uint64]struct{}
blacklist map[Address]struct{}
}
// variables for specific networks, copy values from MaintnetConstant to pass tests
var (
BlackListHFNumber = MaintnetConstant.blackListHFNumber
MaxMasternodesV2 = MaintnetConstant.maxMasternodesV2 // Last v1 masternodes
TIP2019Block = MaintnetConstant.tip2019Block
TIPSigning = MaintnetConstant.tipSigning
TIPRandomize = MaintnetConstant.tipRandomize
TIPNoHalvingMNReward = MaintnetConstant.tipNoHalvingMNReward
TIPXDCX = MaintnetConstant.tipXDCX
TIPXDCXLending = MaintnetConstant.tipXDCXLending
TIPXDCXCancellationFee = MaintnetConstant.tipXDCXCancellationFee
TIPXDCXCancellationFeeTestnet = MaintnetConstant.tipXDCXCancellationFeeTestnet
TIPTRC21Fee = MaintnetConstant.tipTRC21Fee
TIPTRC21FeeTestnet = MaintnetConstant.tipTRC21FeeTestnet
TIPIncreaseMasternodes = MaintnetConstant.tipIncreaseMasternodes
BerlinBlock = MaintnetConstant.berlinBlock
LondonBlock = MaintnetConstant.londonBlock
MergeBlock = MaintnetConstant.mergeBlock
ShanghaiBlock = MaintnetConstant.shanghaiBlock
BlockNumberGas50x = MaintnetConstant.blockNumberGas50x
TIPXDCXMinerDisable = MaintnetConstant.tipXDCXMinerDisable
TIPXDCXReceiverDisable = MaintnetConstant.tipXDCXReceiverDisable
Eip1559Block = MaintnetConstant.eip1559Block
CancunBlock = MaintnetConstant.cancunBlock
TRC21IssuerSMCTestNet = MaintnetConstant.trc21IssuerSMCTestNet
TRC21IssuerSMC = MaintnetConstant.trc21IssuerSMC
XDCXListingSMC = MaintnetConstant.xdcxListingSMC
XDCXListingSMCTestNet = MaintnetConstant.xdcxListingSMCTestNet
RelayerRegistrationSMC = MaintnetConstant.relayerRegistrationSMC
RelayerRegistrationSMCTestnet = MaintnetConstant.relayerRegistrationSMCTestnet
LendingRegistrationSMC = MaintnetConstant.lendingRegistrationSMC
LendingRegistrationSMCTestnet = MaintnetConstant.lendingRegistrationSMCTestnet
ignoreSignerCheckBlockArray = MaintnetConstant.ignoreSignerCheckBlockArray
blacklist = MaintnetConstant.blacklist
)
func IsIgnoreSignerCheckBlock(blockNumber uint64) bool {
_, ok := ignoreSignerCheckBlockArray[blockNumber]
return ok
}
func IsInBlacklist(address *Address) bool {
if address == nil {
return false
}
_, ok := blacklist[*address]
return ok
}
// CopyConstans only handles testnet, devnet, local. It does not
// handles mainnet since the default value is from mainnet.
func CopyConstans(chainID uint64) {
var c *constant
if chainID == TestnetConstant.chainID {
c = &TestnetConstant
IsTestnet = true
} else if chainID == DevnetConstant.chainID {
c = &DevnetConstant
} else if chainID == localConstant.chainID {
c = &localConstant
} else {
return
}
MaxMasternodesV2 = c.maxMasternodesV2
BlackListHFNumber = c.blackListHFNumber
TIP2019Block = c.tip2019Block
TIPSigning = c.tipSigning
TIPRandomize = c.tipRandomize
TIPNoHalvingMNReward = c.tipNoHalvingMNReward
TIPXDCX = c.tipXDCX
TIPXDCXLending = c.tipXDCXLending
TIPXDCXCancellationFee = c.tipXDCXCancellationFee
TIPXDCXCancellationFeeTestnet = c.tipXDCXCancellationFeeTestnet
TIPTRC21Fee = c.tipTRC21Fee
TIPTRC21FeeTestnet = c.tipTRC21FeeTestnet
TIPIncreaseMasternodes = c.tipIncreaseMasternodes
BerlinBlock = c.berlinBlock
LondonBlock = c.londonBlock
MergeBlock = c.mergeBlock
ShanghaiBlock = c.shanghaiBlock
BlockNumberGas50x = c.blockNumberGas50x
TIPXDCXMinerDisable = c.tipXDCXMinerDisable
TIPXDCXReceiverDisable = c.tipXDCXReceiverDisable
Eip1559Block = c.eip1559Block
CancunBlock = c.cancunBlock
TRC21IssuerSMCTestNet = c.trc21IssuerSMCTestNet
TRC21IssuerSMC = c.trc21IssuerSMC
XDCXListingSMC = c.xdcxListingSMC
XDCXListingSMCTestNet = c.xdcxListingSMCTestNet
RelayerRegistrationSMC = c.relayerRegistrationSMC
RelayerRegistrationSMCTestnet = c.relayerRegistrationSMCTestnet
LendingRegistrationSMC = c.lendingRegistrationSMC
LendingRegistrationSMCTestnet = c.lendingRegistrationSMCTestnet
clear(ignoreSignerCheckBlockArray)
maps.Copy(ignoreSignerCheckBlockArray, c.ignoreSignerCheckBlockArray)
clear(blacklist)
maps.Copy(blacklist, c.blacklist)
}

View file

@ -1,10 +1,13 @@
// Notice: this file only saves const variables for all network.
// Please run the following commands after modify this file:
//
// cp common/constants.go common/constants/constants.go.devnet
// cp common/constants.go common/constants/constants.go.testnet
// cp common/constants.go common/constants/constants.go.local
package common
import (
"maps"
"math/big"
)
// const variables for all network.
const (
RewardMasterPercent = 90
RewardVoterPercent = 0
@ -30,187 +33,3 @@ const (
HexSetSecret = "34d38600"
HexSetOpening = "e11f5ba2"
)
// variables for all network.
var (
IsTestnet bool = false
Enable0xPrefix bool = true
Rewound = uint64(0)
RollbackHash Hash
StoreRewardFolder string
TRC21GasPriceBefore = big.NewInt(2500)
TRC21GasPrice = big.NewInt(250000000)
MinGasPrice = big.NewInt(DefaultMinGasPrice)
// XDCx and XDCxlending
BasePrice = big.NewInt(1000000000000000000) // 1
RelayerLockedFund = big.NewInt(20000) // 20000 XDC
XDCXBaseFee = big.NewInt(10000) // 1 / XDCXBaseFee
XDCXBaseCancelFee = new(big.Int).Mul(XDCXBaseFee, big.NewInt(10)) // 1/ (XDCXBaseFee *10)
// XDCx
RelayerFee = big.NewInt(1000000000000000) // 0.001
RelayerCancelFee = big.NewInt(100000000000000) // 0.0001
// XDCxlending
RateTopUp = big.NewInt(90) // 90%
BaseTopUp = big.NewInt(100)
BaseRecall = big.NewInt(100)
BaseLendingInterest = big.NewInt(100000000) // 1e8
RelayerLendingFee = big.NewInt(10000000000000000) // 0.01
RelayerLendingCancelFee = big.NewInt(1000000000000000) // 0.001
)
type constant struct {
chainID uint64
blackListHFNumber uint64
maxMasternodesV2 int // Last v1 masternodes
tip2019Block *big.Int
tipSigning *big.Int
tipRandomize *big.Int
tipNoHalvingMNReward *big.Int // hardfork no halving masternodes reward
tipXDCX *big.Int
tipXDCXLending *big.Int
tipXDCXCancellationFee *big.Int
tipXDCXCancellationFeeTestnet *big.Int
tipTRC21Fee *big.Int
tipTRC21FeeTestnet *big.Int
tipIncreaseMasternodes *big.Int // Upgrade MN Count at Block.
berlinBlock *big.Int
londonBlock *big.Int
mergeBlock *big.Int
shanghaiBlock *big.Int
blockNumberGas50x *big.Int
TIPV2SwitchBlock *big.Int
tipXDCXMinerDisable *big.Int
tipXDCXReceiverDisable *big.Int
eip1559Block *big.Int
cancunBlock *big.Int
trc21IssuerSMCTestNet Address
trc21IssuerSMC Address
xdcxListingSMC Address
xdcxListingSMCTestNet Address
relayerRegistrationSMC Address
relayerRegistrationSMCTestnet Address
lendingRegistrationSMC Address
lendingRegistrationSMCTestnet Address
ignoreSignerCheckBlockArray map[uint64]struct{}
blacklist map[Address]struct{}
}
// variables for specific networks, copy values from MaintnetConstant to pass tests
var (
BlackListHFNumber = MaintnetConstant.blackListHFNumber
MaxMasternodesV2 = MaintnetConstant.maxMasternodesV2 // Last v1 masternodes
TIP2019Block = MaintnetConstant.tip2019Block
TIPSigning = MaintnetConstant.tipSigning
TIPRandomize = MaintnetConstant.tipRandomize
TIPNoHalvingMNReward = MaintnetConstant.tipNoHalvingMNReward
TIPXDCX = MaintnetConstant.tipXDCX
TIPXDCXLending = MaintnetConstant.tipXDCXLending
TIPXDCXCancellationFee = MaintnetConstant.tipXDCXCancellationFee
TIPXDCXCancellationFeeTestnet = MaintnetConstant.tipXDCXCancellationFeeTestnet
TIPTRC21Fee = MaintnetConstant.tipTRC21Fee
TIPTRC21FeeTestnet = MaintnetConstant.tipTRC21FeeTestnet
TIPIncreaseMasternodes = MaintnetConstant.tipIncreaseMasternodes
BerlinBlock = MaintnetConstant.berlinBlock
LondonBlock = MaintnetConstant.londonBlock
MergeBlock = MaintnetConstant.mergeBlock
ShanghaiBlock = MaintnetConstant.shanghaiBlock
BlockNumberGas50x = MaintnetConstant.blockNumberGas50x
TIPXDCXMinerDisable = MaintnetConstant.tipXDCXMinerDisable
TIPXDCXReceiverDisable = MaintnetConstant.tipXDCXReceiverDisable
Eip1559Block = MaintnetConstant.eip1559Block
CancunBlock = MaintnetConstant.cancunBlock
TRC21IssuerSMCTestNet = MaintnetConstant.trc21IssuerSMCTestNet
TRC21IssuerSMC = MaintnetConstant.trc21IssuerSMC
XDCXListingSMC = MaintnetConstant.xdcxListingSMC
XDCXListingSMCTestNet = MaintnetConstant.xdcxListingSMCTestNet
RelayerRegistrationSMC = MaintnetConstant.relayerRegistrationSMC
RelayerRegistrationSMCTestnet = MaintnetConstant.relayerRegistrationSMCTestnet
LendingRegistrationSMC = MaintnetConstant.lendingRegistrationSMC
LendingRegistrationSMCTestnet = MaintnetConstant.lendingRegistrationSMCTestnet
ignoreSignerCheckBlockArray = MaintnetConstant.ignoreSignerCheckBlockArray
blacklist = MaintnetConstant.blacklist
)
func IsIgnoreSignerCheckBlock(blockNumber uint64) bool {
_, ok := ignoreSignerCheckBlockArray[blockNumber]
return ok
}
func IsInBlacklist(address *Address) bool {
if address == nil {
return false
}
_, ok := blacklist[*address]
return ok
}
// CopyConstans only handles testnet, devnet, local. It does not
// handles mainnet since the default value is from mainnet.
func CopyConstans(chainID uint64) {
var c *constant
if chainID == TestnetConstant.chainID {
c = &TestnetConstant
IsTestnet = true
} else if chainID == DevnetConstant.chainID {
c = &DevnetConstant
} else if chainID == localConstant.chainID {
c = &localConstant
} else {
return
}
MaxMasternodesV2 = c.maxMasternodesV2
BlackListHFNumber = c.blackListHFNumber
TIP2019Block = c.tip2019Block
TIPSigning = c.tipSigning
TIPRandomize = c.tipRandomize
TIPNoHalvingMNReward = c.tipNoHalvingMNReward
TIPXDCX = c.tipXDCX
TIPXDCXLending = c.tipXDCXLending
TIPXDCXCancellationFee = c.tipXDCXCancellationFee
TIPXDCXCancellationFeeTestnet = c.tipXDCXCancellationFeeTestnet
TIPTRC21Fee = c.tipTRC21Fee
TIPTRC21FeeTestnet = c.tipTRC21FeeTestnet
TIPIncreaseMasternodes = c.tipIncreaseMasternodes
BerlinBlock = c.berlinBlock
LondonBlock = c.londonBlock
MergeBlock = c.mergeBlock
ShanghaiBlock = c.shanghaiBlock
BlockNumberGas50x = c.blockNumberGas50x
TIPXDCXMinerDisable = c.tipXDCXMinerDisable
TIPXDCXReceiverDisable = c.tipXDCXReceiverDisable
Eip1559Block = c.eip1559Block
CancunBlock = c.cancunBlock
TRC21IssuerSMCTestNet = c.trc21IssuerSMCTestNet
TRC21IssuerSMC = c.trc21IssuerSMC
XDCXListingSMC = c.xdcxListingSMC
XDCXListingSMCTestNet = c.xdcxListingSMCTestNet
RelayerRegistrationSMC = c.relayerRegistrationSMC
RelayerRegistrationSMCTestnet = c.relayerRegistrationSMCTestnet
LendingRegistrationSMC = c.lendingRegistrationSMC
LendingRegistrationSMCTestnet = c.lendingRegistrationSMCTestnet
clear(ignoreSignerCheckBlockArray)
maps.Copy(ignoreSignerCheckBlockArray, c.ignoreSignerCheckBlockArray)
clear(blacklist)
maps.Copy(blacklist, c.blacklist)
}