Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment thread
wjrjerome marked this conversation as resolved.
var BerlinBlock = big.NewInt(9999999999)
var LondonBlock = big.NewInt(9999999999)

Expand Down
1 change: 1 addition & 0 deletions common/constants/constants.go.devnet
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions common/constants/constants.go.testnet
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
45 changes: 22 additions & 23 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand All @@ -735,6 +740,9 @@ func (self *worker) commitNewWork() {
if XDCX.IsSDKNode() {
self.chain.AddLendingResult(lendingTransaction.Hash(), lendingMatchingResults)
}
if lendingTransaction != nil {
specialTxs = append(specialTxs, lendingTransaction)
}
}
}

Expand All @@ -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.
Expand Down
9 changes: 4 additions & 5 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down