Skip to content

Commit ef4b8ef

Browse files
authored
Disable on xdcx receiver part (#521)
* update all IsTIPXDCXReceiver condition * add TIPXDCXReceiverDisable on testnet and devnet
1 parent bf4f915 commit ef4b8ef

File tree

9 files changed

+29
-23
lines changed

9 files changed

+29
-23
lines changed

common/constants.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ var TIPXDCX = big.NewInt(38383838)
4545
var TIPXDCXLending = big.NewInt(38383838)
4646
var TIPXDCXCancellationFee = big.NewInt(38383838)
4747
var TIPXDCXCancellationFeeTestnet = big.NewInt(38383838)
48-
var TIPXDCXDISABLE = big.NewInt(99999999900)
48+
var TIPXDCXMinerDisable = big.NewInt(88999999900)
49+
var TIPXDCXReceiverDisable = big.NewInt(99999999999)
4950
var BerlinBlock = big.NewInt(9999999999)
5051
var LondonBlock = big.NewInt(9999999999)
5152
var MergeBlock = big.NewInt(9999999999)

common/constants/constants.go.devnet

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ var TIPXDCX = big.NewInt(225000)
4545
var TIPXDCXLending = big.NewInt(225000)
4646
var TIPXDCXCancellationFee = big.NewInt(225000)
4747
var TIPXDCXCancellationFeeTestnet = big.NewInt(225000)
48-
var TIPXDCXDISABLE = big.NewInt(15894900)
48+
var TIPXDCXMinerDisable = big.NewInt(15894900)
49+
var TIPXDCXReceiverDisable = big.NewInt(9999999999)
4950
var BerlinBlock = big.NewInt(9999999999)
5051
var LondonBlock = big.NewInt(9999999999)
5152
var MergeBlock = big.NewInt(9999999999)

common/constants/constants.go.testnet

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ var TIPXDCX = big.NewInt(23779191)
4545
var TIPXDCXLending = big.NewInt(23779191)
4646
var TIPXDCXCancellationFee = big.NewInt(23779191)
4747
var TIPXDCXCancellationFeeTestnet = big.NewInt(23779191)
48-
var TIPXDCXDISABLE = big.NewInt(61290000) // Target 31st March 2024
48+
var TIPXDCXMinerDisable = big.NewInt(61290000) // Target 31st March 2024
49+
var TIPXDCXReceiverDisable = big.NewInt(9999999999)
4950
var BerlinBlock = big.NewInt(9999999999)
5051
var LondonBlock = big.NewInt(9999999999)
5152
var MergeBlock = big.NewInt(9999999999)

core/blockchain.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ func (bc *BlockChain) repair(head **types.Block) error {
607607
if ok {
608608
tradingService := engine.GetXDCXService()
609609
lendingService := engine.GetLendingService()
610-
if bc.Config().IsTIPXDCX((*head).Number()) && bc.chainConfig.XDPoS != nil && (*head).NumberU64() > bc.chainConfig.XDPoS.Epoch && tradingService != nil && lendingService != nil {
610+
if bc.Config().IsTIPXDCXReceiver((*head).Number()) && bc.chainConfig.XDPoS != nil && (*head).NumberU64() > bc.chainConfig.XDPoS.Epoch && tradingService != nil && lendingService != nil {
611611
author, _ := bc.Engine().Author((*head).Header())
612612
tradingRoot, err := tradingService.GetTradingStateRoot(*head, author)
613613
if err == nil {
@@ -913,7 +913,7 @@ func (bc *BlockChain) SaveData() {
913913
if err := triedb.Commit(recent.Root(), true); err != nil {
914914
log.Error("Failed to commit recent state trie", "err", err)
915915
}
916-
if bc.Config().IsTIPXDCX(recent.Number()) && bc.chainConfig.XDPoS != nil && recent.NumberU64() > bc.chainConfig.XDPoS.Epoch && engine != nil {
916+
if bc.Config().IsTIPXDCXReceiver(recent.Number()) && bc.chainConfig.XDPoS != nil && recent.NumberU64() > bc.chainConfig.XDPoS.Epoch && engine != nil {
917917
author, _ := bc.Engine().Author(recent.Header())
918918
if tradingService != nil {
919919
tradingRoot, _ := tradingService.GetTradingStateRoot(recent, author)
@@ -1239,7 +1239,7 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.
12391239
var tradingService utils.TradingService
12401240
var lendingTrieDb *trie.Database
12411241
var lendingService utils.LendingService
1242-
if bc.Config().IsTIPXDCX(block.Number()) && bc.chainConfig.XDPoS != nil && block.NumberU64() > bc.chainConfig.XDPoS.Epoch && engine != nil {
1242+
if bc.Config().IsTIPXDCXReceiver(block.Number()) && bc.chainConfig.XDPoS != nil && block.NumberU64() > bc.chainConfig.XDPoS.Epoch && engine != nil {
12431243
tradingService = engine.GetXDCXService()
12441244
if tradingService != nil {
12451245
tradingTrieDb = tradingService.GetStateCache().TrieDB()
@@ -1592,7 +1592,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
15921592
var tradingService utils.TradingService
15931593
var lendingService utils.LendingService
15941594
isSDKNode := false
1595-
if bc.Config().IsTIPXDCX(block.Number()) && bc.chainConfig.XDPoS != nil && engine != nil && block.NumberU64() > bc.chainConfig.XDPoS.Epoch {
1595+
if bc.Config().IsTIPXDCXReceiver(block.Number()) && bc.chainConfig.XDPoS != nil && engine != nil && block.NumberU64() > bc.chainConfig.XDPoS.Epoch {
15961596
author, err := bc.Engine().Author(block.Header()) // Ignore error, we're past header validation
15971597
if err != nil {
15981598
bc.reportBlock(block, nil, err)
@@ -1933,8 +1933,7 @@ func (bc *BlockChain) getResultBlock(block *types.Block, verifiedM2 bool) (*Resu
19331933
}
19341934
// liquidate / finalize open lendingTrades
19351935
if block.Number().Uint64()%bc.chainConfig.XDPoS.Epoch == common.LiquidateLendingTradeBlock {
1936-
finalizedTrades := map[common.Hash]*lendingstate.LendingTrade{}
1937-
finalizedTrades, _, _, _, _, err = lendingService.ProcessLiquidationData(block.Header(), bc, statedb, tradingState, lendingState)
1936+
finalizedTrades, _, _, _, _, err := lendingService.ProcessLiquidationData(block.Header(), bc, statedb, tradingState, lendingState)
19381937
if err != nil {
19391938
return nil, fmt.Errorf("failed to ProcessLiquidationData. Err: %v ", err)
19401939
}
@@ -2055,7 +2054,7 @@ func (bc *BlockChain) insertBlock(block *types.Block) ([]interface{}, []*types.L
20552054
// Only count canonical blocks for GC processing time
20562055
bc.gcproc += result.proctime
20572056
bc.UpdateBlocksHashCache(block)
2058-
if bc.chainConfig.IsTIPXDCX(block.Number()) && bc.chainConfig.XDPoS != nil && block.NumberU64() > bc.chainConfig.XDPoS.Epoch {
2057+
if bc.chainConfig.IsTIPXDCXReceiver(block.Number()) && bc.chainConfig.XDPoS != nil && block.NumberU64() > bc.chainConfig.XDPoS.Epoch {
20592058
bc.logExchangeData(block)
20602059
bc.logLendingData(block)
20612060
}
@@ -2279,7 +2278,7 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
22792278
}
22802279
}()
22812280
}
2282-
if bc.chainConfig.IsTIPXDCX(commonBlock.Number()) && bc.chainConfig.XDPoS != nil && commonBlock.NumberU64() > bc.chainConfig.XDPoS.Epoch {
2281+
if bc.chainConfig.IsTIPXDCXReceiver(commonBlock.Number()) && bc.chainConfig.XDPoS != nil && commonBlock.NumberU64() > bc.chainConfig.XDPoS.Epoch {
22832282
bc.reorgTxMatches(deletedTxs, newChain)
22842283
}
22852284
return nil

core/lending_pool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (pool *LendingPool) loop() {
273273
// reset retrieves the current state of the blockchain and ensures the content
274274
// of the transaction pool is valid with regard to the chain state.
275275
func (pool *LendingPool) reset(oldHead, newblock *types.Block) {
276-
if !pool.chainconfig.IsTIPXDCX(pool.chain.CurrentBlock().Number()) || pool.chain.Config().XDPoS == nil || pool.chain.CurrentBlock().NumberU64() <= pool.chain.Config().XDPoS.Epoch {
276+
if !pool.chainconfig.IsTIPXDCXReceiver(pool.chain.CurrentBlock().Number()) || pool.chain.Config().XDPoS == nil || pool.chain.CurrentBlock().NumberU64() <= pool.chain.Config().XDPoS.Epoch {
277277
return
278278
}
279279
// If we're reorging an old state, reinject all dropped transactions
@@ -814,7 +814,7 @@ func (pool *LendingPool) AddRemotes(txs []*types.LendingTransaction) []error {
814814

815815
// addTx enqueues a single transaction into the pool if it is valid.
816816
func (pool *LendingPool) addTx(tx *types.LendingTransaction, local bool) error {
817-
if !pool.chainconfig.IsTIPXDCX(pool.chain.CurrentBlock().Number()) {
817+
if !pool.chainconfig.IsTIPXDCXReceiver(pool.chain.CurrentBlock().Number()) {
818818
return nil
819819
}
820820
tx.CacheHash()

core/order_pool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func (pool *OrderPool) loop() {
278278
// reset retrieves the current state of the blockchain and ensures the content
279279
// of the transaction pool is valid with regard to the chain state.
280280
func (pool *OrderPool) reset(oldHead, newblock *types.Block) {
281-
if !pool.chainconfig.IsTIPXDCX(pool.chain.CurrentBlock().Number()) || pool.chain.Config().XDPoS == nil || pool.chain.CurrentBlock().NumberU64() <= pool.chain.Config().XDPoS.Epoch {
281+
if !pool.chainconfig.IsTIPXDCXReceiver(pool.chain.CurrentBlock().Number()) || pool.chain.Config().XDPoS == nil || pool.chain.CurrentBlock().NumberU64() <= pool.chain.Config().XDPoS.Epoch {
282282
return
283283
}
284284
// If we're reorging an old state, reinject all dropped transactions
@@ -729,7 +729,7 @@ func (pool *OrderPool) AddRemotes(txs []*types.OrderTransaction) []error {
729729

730730
// addTx enqueues a single transaction into the pool if it is valid.
731731
func (pool *OrderPool) addTx(tx *types.OrderTransaction, local bool) error {
732-
if !pool.chainconfig.IsTIPXDCX(pool.chain.CurrentBlock().Number()) {
732+
if !pool.chainconfig.IsTIPXDCXReceiver(pool.chain.CurrentBlock().Number()) {
733733
return nil
734734
}
735735
tx.CacheHash()

core/state_processor.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,17 @@ func ApplyTransaction(config *params.ChainConfig, tokensFee map[common.Address]*
218218
if tx.To() != nil && tx.To().String() == common.BlockSigners && config.IsTIPSigning(header.Number) {
219219
return ApplySignTransaction(config, statedb, header, tx, usedGas)
220220
}
221-
if tx.To() != nil && tx.To().String() == common.TradingStateAddr && config.IsTIPXDCX(header.Number) {
221+
if tx.To() != nil && tx.To().String() == common.TradingStateAddr && config.IsTIPXDCXReceiver(header.Number) {
222222
return ApplyEmptyTransaction(config, statedb, header, tx, usedGas)
223223
}
224-
if tx.To() != nil && tx.To().String() == common.XDCXLendingAddress && config.IsTIPXDCX(header.Number) {
224+
if tx.To() != nil && tx.To().String() == common.XDCXLendingAddress && config.IsTIPXDCXReceiver(header.Number) {
225225
return ApplyEmptyTransaction(config, statedb, header, tx, usedGas)
226226
}
227-
if tx.IsTradingTransaction() && config.IsTIPXDCX(header.Number) {
227+
if tx.IsTradingTransaction() && config.IsTIPXDCXReceiver(header.Number) {
228228
return ApplyEmptyTransaction(config, statedb, header, tx, usedGas)
229229
}
230230

231-
if tx.IsLendingFinalizedTradeTransaction() && config.IsTIPXDCX(header.Number) {
231+
if tx.IsLendingFinalizedTradeTransaction() && config.IsTIPXDCXReceiver(header.Number) {
232232
return ApplyEmptyTransaction(config, statedb, header, tx, usedGas)
233233
}
234234

core/token_validator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func RunContract(chain consensus.ChainContext, statedb *state.StateDB, contractA
8686
return unpackResult, nil
8787
}
8888

89-
//FIXME: please use copyState for this function
89+
// FIXME: please use copyState for this function
9090
// CallContractWithState executes a contract call at the given state.
9191
func CallContractWithState(call ethereum.CallMsg, chain consensus.ChainContext, statedb *state.StateDB) ([]byte, error) {
9292
// Ensure message is initialized properly.
@@ -124,7 +124,7 @@ func ValidateXDCXApplyTransaction(chain consensus.ChainContext, blockNumber *big
124124
if blockNumber == nil || blockNumber.Sign() <= 0 {
125125
blockNumber = chain.CurrentHeader().Number
126126
}
127-
if !chain.Config().IsTIPXDCX(blockNumber) {
127+
if !chain.Config().IsTIPXDCXReceiver(blockNumber) {
128128
return nil
129129
}
130130
contractABI, err := GetTokenAbi(contract.TRC21ABI)
@@ -146,7 +146,7 @@ func ValidateXDCZApplyTransaction(chain consensus.ChainContext, blockNumber *big
146146
if blockNumber == nil || blockNumber.Sign() <= 0 {
147147
blockNumber = chain.CurrentHeader().Number
148148
}
149-
if !chain.Config().IsTIPXDCX(blockNumber) {
149+
if !chain.Config().IsTIPXDCXReceiver(blockNumber) {
150150
return nil
151151
}
152152
contractABI, err := GetTokenAbi(contract.TRC21ABI)

params/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,11 @@ func (c *ChainConfig) IsTIPXDCX(num *big.Int) bool {
606606
return isForked(common.TIPXDCX, num)
607607
}
608608
func (c *ChainConfig) IsTIPXDCXMiner(num *big.Int) bool {
609-
return isForked(common.TIPXDCX, num) && !isForked(common.TIPXDCXDISABLE, num)
609+
return isForked(common.TIPXDCX, num) && !isForked(common.TIPXDCXMinerDisable, num)
610+
}
611+
612+
func (c *ChainConfig) IsTIPXDCXReceiver(num *big.Int) bool {
613+
return isForked(common.TIPXDCX, num) && !isForked(common.TIPXDCXReceiverDisable, num)
610614
}
611615

612616
func (c *ChainConfig) IsTIPXDCXLending(num *big.Int) bool {

0 commit comments

Comments
 (0)