From cbc2d202cbe369c6bcde38d3291609735b9dcf20 Mon Sep 17 00:00:00 2001 From: Hussam Date: Wed, 4 Dec 2024 12:49:58 -0600 Subject: [PATCH] Remove New vs Old ConversionLockPeriod --- core/chain_indexer.go | 4 ++-- core/state_processor.go | 15 +++++---------- core/worker.go | 13 ++++--------- params/protocol_params.go | 5 ++--- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/core/chain_indexer.go b/core/chain_indexer.go index 7f50370a2..87a2e90b1 100644 --- a/core/chain_indexer.go +++ b/core/chain_indexer.go @@ -775,7 +775,7 @@ func (c *ChainIndexer) addOutpointsToIndexer(addressOutpointsWithBlockHeight map // After the BigSporkFork the minimum conversion period changes to 7200 blocks var lockup *big.Int if lockupByte == 0 { - lockup = new(big.Int).SetUint64(params.NewConversionLockPeriod) + lockup = new(big.Int).SetUint64(params.ConversionLockPeriod) } else { lockup = new(big.Int).SetUint64(params.LockupByteToBlockDepth[lockupByte]) } @@ -820,7 +820,7 @@ func (c *ChainIndexer) addOutpointsToIndexer(addressOutpointsWithBlockHeight map } } else if tx.EtxType() == types.ConversionType && tx.To().IsInQiLedgerScope() { var lockup *big.Int - lockup = new(big.Int).SetUint64(params.NewConversionLockPeriod) + lockup = new(big.Int).SetUint64(params.ConversionLockPeriod) lock := new(big.Int).Add(block.Number(nodeCtx), lockup) value := tx.Value() addr20 := tx.To().Bytes20() diff --git a/core/state_processor.go b/core/state_processor.go index fb036d529..673baab94 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -456,14 +456,9 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty return nil, nil, nil, nil, 0, 0, 0, nil, nil, fmt.Errorf("coinbase lockup byte %d is out of range", lockupByte) } var lockup *big.Int - // The first lock up period changes after the fork - if lockupByte == 0 { - lockup = new(big.Int).SetUint64(params.NewConversionLockPeriod) - } else { - lockup = new(big.Int).SetUint64(params.LockupByteToBlockDepth[lockupByte]) - if lockup.Uint64() < params.OldConversionLockPeriod { - return nil, nil, nil, nil, 0, 0, 0, nil, nil, fmt.Errorf("coinbase lockup period is less than the minimum lockup period of %d blocks", params.OldConversionLockPeriod) - } + lockup = new(big.Int).SetUint64(params.LockupByteToBlockDepth[lockupByte]) + if lockup.Uint64() < params.ConversionLockPeriod { + return nil, nil, nil, nil, 0, 0, 0, nil, nil, fmt.Errorf("coinbase lockup period is less than the minimum lockup period of %d blocks", params.ConversionLockPeriod) } lockup.Add(lockup, blockNumber) value := params.CalculateCoinbaseValueWithLockup(tx.Value(), lockupByte) @@ -507,7 +502,7 @@ func (p *StateProcessor) Process(block *types.WorkObject, batch ethdb.Batch) (ty if etx.To().IsInQiLedgerScope() { if etx.ETXSender().Location().Equal(*etx.To().Location()) { // Quai->Qi Conversion var lockup *big.Int - lockup = new(big.Int).SetUint64(params.NewConversionLockPeriod) + lockup = new(big.Int).SetUint64(params.ConversionLockPeriod) lock := new(big.Int).Add(block.Number(nodeCtx), lockup) value := etx.Value() txGas := etx.Gas() @@ -891,7 +886,7 @@ func RedeemLockedQuai(hc *HeaderChain, header *types.WorkObject, parent *types.W } var conversionPeriodValid bool - conversionPeriodValid = blockDepth == params.NewConversionLockPeriod + conversionPeriodValid = blockDepth == params.ConversionLockPeriod if types.IsConversionTx(etx) && etx.To().IsInQuaiLedgerScope() && conversionPeriodValid { internal, err := etx.To().InternalAddress() if err != nil { diff --git a/core/worker.go b/core/worker.go index c99af8a0a..fd9bf4aa9 100644 --- a/core/worker.go +++ b/core/worker.go @@ -1094,14 +1094,9 @@ func (w *worker) commitTransaction(env *environment, parent *types.WorkObject, t } if tx.To().IsInQiLedgerScope() { var lockup *big.Int - // The first lock up period changes after the fork - if lockupByte == 0 { - lockup = new(big.Int).SetUint64(params.NewConversionLockPeriod) - if lockup.Uint64() < params.NewConversionLockPeriod { - return nil, false, fmt.Errorf("coinbase lockup period is less than the minimum lockup period of %d blocks", params.NewConversionLockPeriod) - } - } else { - lockup = new(big.Int).SetUint64(params.LockupByteToBlockDepth[lockupByte]) + lockup = new(big.Int).SetUint64(params.ConversionLockPeriod) + if lockup.Uint64() < params.ConversionLockPeriod { + return nil, false, fmt.Errorf("coinbase lockup period is less than the minimum lockup period of %d blocks", params.ConversionLockPeriod) } lockup.Add(lockup, env.wo.Number(w.hc.NodeCtx())) value := params.CalculateCoinbaseValueWithLockup(tx.Value(), lockupByte) @@ -1140,7 +1135,7 @@ func (w *worker) commitTransaction(env *environment, parent *types.WorkObject, t if tx.ETXSender().Location().Equal(*tx.To().Location()) { // Quai->Qi conversion txGas := tx.Gas() var lockup *big.Int - lockup = new(big.Int).SetUint64(params.NewConversionLockPeriod) + lockup = new(big.Int).SetUint64(params.ConversionLockPeriod) lock := new(big.Int).Add(env.wo.Number(w.hc.NodeCtx()), lockup) if env.parentOrder == nil { return nil, false, errors.New("parent order not set") diff --git a/params/protocol_params.go b/params/protocol_params.go index eb86c9c61..4caebc50d 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -148,8 +148,7 @@ const ( // infrastructure, if needed, to account for the upcoming network change. TREE_EXPANSION_WAIT_COUNT = 1024 - OldConversionLockPeriod uint64 = 10 // The number of zone blocks that a conversion output is locked for - NewConversionLockPeriod uint64 = 7200 + ConversionLockPeriod uint64 = 7200 MinQiConversionDenomination = 10 ConversionConfirmationContext = common.PRIME_CTX // A conversion requires a single coincident Dom confirmation QiToQuaiConversionGas = 100000 // The gas used to convert Qi to Quai @@ -194,7 +193,7 @@ var ( ) func init() { - LockupByteToBlockDepth[0] = OldConversionLockPeriod + LockupByteToBlockDepth[0] = ConversionLockPeriod LockupByteToBlockDepth[1] = 30240 // 1.75 days LockupByteToBlockDepth[2] = 60480 // 3.5 days LockupByteToBlockDepth[3] = 120960 // 7 days