diff --git a/common/constants.go b/common/constants.go index 7020e8fd682b..f68c90b6bc90 100644 --- a/common/constants.go +++ b/common/constants.go @@ -45,6 +45,7 @@ var TIPXDCX = big.NewInt(38383838) var TIPXDCXLending = big.NewInt(38383838) var TIPXDCXCancellationFee = big.NewInt(38383838) var TIPXDCXCancellationFeeTestnet = big.NewInt(38383838) +var TIPXDCXDISABLE = big.NewInt(99999999900) var BerlinBlock = big.NewInt(9999999999) var LondonBlock = big.NewInt(9999999999) diff --git a/common/constants/constants.go.devnet b/common/constants/constants.go.devnet index 58351e020bf0..7115db6b4ef7 100644 --- a/common/constants/constants.go.devnet +++ b/common/constants/constants.go.devnet @@ -45,6 +45,7 @@ var TIPXDCX = big.NewInt(225000) var TIPXDCXLending = big.NewInt(225000) var TIPXDCXCancellationFee = big.NewInt(225000) var TIPXDCXCancellationFeeTestnet = big.NewInt(225000) +var TIPXDCXDISABLE = big.NewInt(15894900) var BerlinBlock = big.NewInt(9999999999) var LondonBlock = big.NewInt(9999999999) diff --git a/common/constants/constants.go.testnet b/common/constants/constants.go.testnet index eae07aa11647..ba422c99d16b 100644 --- a/common/constants/constants.go.testnet +++ b/common/constants/constants.go.testnet @@ -45,6 +45,7 @@ var TIPXDCX = big.NewInt(23779191) var TIPXDCXLending = big.NewInt(23779191) var TIPXDCXCancellationFee = big.NewInt(23779191) var TIPXDCXCancellationFeeTestnet = big.NewInt(23779191) +var TIPXDCXDISABLE = big.NewInt(99999999900) var BerlinBlock = big.NewInt(9999999999) var LondonBlock = big.NewInt(9999999999) diff --git a/miner/worker.go b/miner/worker.go index bc3982094e87..6967ae5207eb 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -652,7 +652,7 @@ func (self *worker) commitNewWork() { log.Warn("Can't find coinbase account wallet", "coinbase", self.coinbase, "err", err) return } - if self.config.XDPoS != nil && self.chain.Config().IsTIPXDCX(header.Number) { + if self.config.XDPoS != nil && self.chain.Config().IsTIPXDCXMiner(header.Number) { XDCX := self.eth.GetXDCX() XDCXLending := self.eth.GetXDCXLending() if XDCX != nil && header.Number.Uint64() > self.config.XDPoS.Epoch { @@ -710,8 +710,13 @@ func (self *worker) commitNewWork() { if XDCX.IsSDKNode() { self.chain.AddMatchingResult(tradingTransaction.Hash(), tradingMatchingResults) } + // force adding trading, lending transaction to this block + if tradingTransaction != nil { + specialTxs = append(specialTxs, tradingTransaction) + } } } + if len(lendingInput) > 0 { // lending transaction lendingBatch := &lendingstate.TxLendingBatch{ @@ -735,6 +740,9 @@ func (self *worker) commitNewWork() { if XDCX.IsSDKNode() { self.chain.AddLendingResult(lendingTransaction.Hash(), lendingMatchingResults) } + if lendingTransaction != nil { + specialTxs = append(specialTxs, lendingTransaction) + } } } @@ -756,32 +764,23 @@ func (self *worker) commitNewWork() { if XDCX.IsSDKNode() { self.chain.AddFinalizedTrades(lendingFinalizedTradeTransaction.Hash(), updatedTrades) } + if lendingFinalizedTradeTransaction != nil { + specialTxs = append(specialTxs, lendingFinalizedTradeTransaction) + } } } } + XDCxStateRoot := work.tradingState.IntermediateRoot() + LendingStateRoot := work.lendingState.IntermediateRoot() + txData := append(XDCxStateRoot.Bytes(), LendingStateRoot.Bytes()...) + tx := types.NewTransaction(work.state.GetNonce(self.coinbase), common.HexToAddress(common.TradingStateAddr), big.NewInt(0), txMatchGasLimit, big.NewInt(0), txData) + txStateRoot, err := wallet.SignTx(accounts.Account{Address: self.coinbase}, tx, self.config.ChainId) + if err != nil { + log.Error("Fail to create tx state root", "error", err) + return + } + specialTxs = append(specialTxs, txStateRoot) } - - // force adding trading, lending transaction to this block - if tradingTransaction != nil { - specialTxs = append(specialTxs, tradingTransaction) - } - if lendingTransaction != nil { - specialTxs = append(specialTxs, lendingTransaction) - } - if lendingFinalizedTradeTransaction != nil { - specialTxs = append(specialTxs, lendingFinalizedTradeTransaction) - } - - XDCxStateRoot := work.tradingState.IntermediateRoot() - LendingStateRoot := work.lendingState.IntermediateRoot() - txData := append(XDCxStateRoot.Bytes(), LendingStateRoot.Bytes()...) - tx := types.NewTransaction(work.state.GetNonce(self.coinbase), common.HexToAddress(common.TradingStateAddr), big.NewInt(0), txMatchGasLimit, big.NewInt(0), txData) - txStateRoot, err := wallet.SignTx(accounts.Account{Address: self.coinbase}, tx, self.config.ChainId) - if err != nil { - log.Error("Fail to create tx state root", "error", err) - return - } - specialTxs = append(specialTxs, txStateRoot) } work.commitTransactions(self.mux, feeCapacity, txs, specialTxs, self.chain, self.coinbase) // compute uncles for the new block. diff --git a/params/config.go b/params/config.go index a75f7a40538a..c12d0b8321bd 100644 --- a/params/config.go +++ b/params/config.go @@ -591,11 +591,10 @@ func (c *ChainConfig) IsTIPNoHalvingMNReward(num *big.Int) bool { return isForked(common.TIPNoHalvingMNReward, num) } func (c *ChainConfig) IsTIPXDCX(num *big.Int) bool { - if common.IsTestnet { - return isForked(common.TIPXDCXTestnet, num) - } else { - return isForked(common.TIPXDCX, num) - } + return isForked(common.TIPXDCX, num) +} +func (c *ChainConfig) IsTIPXDCXMiner(num *big.Int) bool { + return isForked(common.TIPXDCX, num) && !isForked(common.TIPXDCXDISABLE, num) } func (c *ChainConfig) IsTIPXDCXLending(num *big.Int) bool {