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
2 changes: 1 addition & 1 deletion lib/block_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -2963,7 +2963,7 @@ func (bav *UtxoView) _connectUpdateGlobalParams(
newGlobalParamsEntry.MaxNonceExpirationBlockHeightOffset = newMaxNonceExpirationBlockHeightOffset
}

if blockHeight >= bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight {
if blockHeight >= bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight {
var bytesRead int
if len(extraData[StakeLockupEpochDuration]) > 0 {
newGlobalParamsEntry.StakeLockupEpochDuration, bytesRead = Uvarint(extraData[StakeLockupEpochDuration])
Expand Down
4 changes: 2 additions & 2 deletions lib/block_view_derived_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ func (bav *UtxoView) _connectAuthorizeDerivedKey(
}
}

// ====== Proof of Stake New Txn Types Fork ======
if blockHeight >= bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight {
// ====== Proof of Stake State Setup Fork ======
if blockHeight >= bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight {
// StakeLimitMap
for stakeLimitKey, stakingLimit := range transactionSpendingLimit.StakeLimitMap {
if err = bav.IsValidStakeLimitKey(txn.PublicKey, stakeLimitKey); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions lib/block_view_stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ func (bav *UtxoView) _connectStake(
_err error,
) {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight ||
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight ||
blockHeight < bav.Params.ForkHeights.BalanceModelBlockHeight {
return 0, 0, nil, errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_connectStake: ")
}
Expand Down Expand Up @@ -1275,7 +1275,7 @@ func (bav *UtxoView) _disconnectStake(
blockHeight uint32,
) error {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight ||
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight ||
blockHeight < bav.Params.ForkHeights.BalanceModelBlockHeight {
return errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_disconnectStake: ")
}
Expand Down Expand Up @@ -1365,7 +1365,7 @@ func (bav *UtxoView) _connectUnstake(
_err error,
) {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight ||
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight ||
blockHeight < bav.Params.ForkHeights.BalanceModelBlockHeight {
return 0, 0, nil, errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_connectUnstake: ")
}
Expand Down Expand Up @@ -1553,7 +1553,7 @@ func (bav *UtxoView) _disconnectUnstake(
blockHeight uint32,
) error {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight ||
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight ||
blockHeight < bav.Params.ForkHeights.BalanceModelBlockHeight {
return errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_disconnectUnstake: ")
}
Expand Down Expand Up @@ -1669,7 +1669,7 @@ func (bav *UtxoView) _connectUnlockStake(
_err error,
) {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight ||
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight ||
blockHeight < bav.Params.ForkHeights.BalanceModelBlockHeight {
return 0, 0, nil, errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_connectUnlockStake: ")
}
Expand Down Expand Up @@ -1795,7 +1795,7 @@ func (bav *UtxoView) _disconnectUnlockStake(
blockHeight uint32,
) error {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight ||
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight ||
blockHeight < bav.Params.ForkHeights.BalanceModelBlockHeight {
return errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_disconnectUnlockStake: ")
}
Expand Down
28 changes: 14 additions & 14 deletions lib/block_view_stake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func _testStaking(t *testing.T, flushToDB bool) {
// Local variables
var err error

// Initialize fork heights.
// Initialize balance model fork heights.
setBalanceModelBlockHeights()
defer resetBalanceModelBlockHeights()

Expand Down Expand Up @@ -94,7 +94,7 @@ func _testStaking(t *testing.T, flushToDB bool) {
}
{
// m0 registers as a validator.
params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight = uint32(1)
params.ForkHeights.ProofOfStake1StateSetupBlockHeight = uint32(1)
GlobalDeSoParams.EncoderMigrationHeights = GetEncoderMigrationHeights(&params.ForkHeights)
GlobalDeSoParams.EncoderMigrationHeightsList = GetEncoderMigrationHeightsList(&params.ForkHeights)

Expand All @@ -119,7 +119,7 @@ func _testStaking(t *testing.T, flushToDB bool) {
//
{
// RuleErrorProofOfStakeTxnBeforeBlockHeight
params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight = math.MaxUint32
params.ForkHeights.ProofOfStake1StateSetupBlockHeight = math.MaxUint32
GlobalDeSoParams.EncoderMigrationHeights = GetEncoderMigrationHeights(&params.ForkHeights)
GlobalDeSoParams.EncoderMigrationHeightsList = GetEncoderMigrationHeightsList(&params.ForkHeights)

Expand All @@ -133,7 +133,7 @@ func _testStaking(t *testing.T, flushToDB bool) {
require.Error(t, err)
require.Contains(t, err.Error(), RuleErrorProofofStakeTxnBeforeBlockHeight)

params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight = uint32(1)
params.ForkHeights.ProofOfStake1StateSetupBlockHeight = uint32(1)
GlobalDeSoParams.EncoderMigrationHeights = GetEncoderMigrationHeights(&params.ForkHeights)
GlobalDeSoParams.EncoderMigrationHeightsList = GetEncoderMigrationHeightsList(&params.ForkHeights)
}
Expand Down Expand Up @@ -272,7 +272,7 @@ func _testStaking(t *testing.T, flushToDB bool) {
//
{
// RuleErrorProofOfStakeTxnBeforeBlockHeight
params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight = math.MaxUint32
params.ForkHeights.ProofOfStake1StateSetupBlockHeight = math.MaxUint32
GlobalDeSoParams.EncoderMigrationHeights = GetEncoderMigrationHeights(&params.ForkHeights)
GlobalDeSoParams.EncoderMigrationHeightsList = GetEncoderMigrationHeightsList(&params.ForkHeights)

Expand All @@ -286,7 +286,7 @@ func _testStaking(t *testing.T, flushToDB bool) {
require.Error(t, err)
require.Contains(t, err.Error(), RuleErrorProofofStakeTxnBeforeBlockHeight)

params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight = uint32(1)
params.ForkHeights.ProofOfStake1StateSetupBlockHeight = uint32(1)
GlobalDeSoParams.EncoderMigrationHeights = GetEncoderMigrationHeights(&params.ForkHeights)
GlobalDeSoParams.EncoderMigrationHeightsList = GetEncoderMigrationHeightsList(&params.ForkHeights)
}
Expand Down Expand Up @@ -468,7 +468,7 @@ func _testStaking(t *testing.T, flushToDB bool) {
//
{
// RuleErrorProofOfStakeTxnBeforeBlockHeight
params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight = math.MaxUint32
params.ForkHeights.ProofOfStake1StateSetupBlockHeight = math.MaxUint32
GlobalDeSoParams.EncoderMigrationHeights = GetEncoderMigrationHeights(&params.ForkHeights)
GlobalDeSoParams.EncoderMigrationHeightsList = GetEncoderMigrationHeightsList(&params.ForkHeights)

Expand All @@ -483,7 +483,7 @@ func _testStaking(t *testing.T, flushToDB bool) {
require.Error(t, err)
require.Contains(t, err.Error(), RuleErrorProofofStakeTxnBeforeBlockHeight)

params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight = uint32(1)
params.ForkHeights.ProofOfStake1StateSetupBlockHeight = uint32(1)
GlobalDeSoParams.EncoderMigrationHeights = GetEncoderMigrationHeights(&params.ForkHeights)
GlobalDeSoParams.EncoderMigrationHeightsList = GetEncoderMigrationHeightsList(&params.ForkHeights)
}
Expand Down Expand Up @@ -766,9 +766,9 @@ func TestStakingWithDerivedKey(t *testing.T) {
chain, params, db := NewLowDifficultyBlockchain(t)
mempool, miner := NewTestMiner(t, chain, params, true)

// Initialize fork heights.
// Initialize PoS fork heights.
params.ForkHeights.DeSoUnlimitedDerivedKeysBlockHeight = uint32(0)
params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight = uint32(1)
params.ForkHeights.ProofOfStake1StateSetupBlockHeight = uint32(1)
GlobalDeSoParams.EncoderMigrationHeights = GetEncoderMigrationHeights(&params.ForkHeights)
GlobalDeSoParams.EncoderMigrationHeightsList = GetEncoderMigrationHeightsList(&params.ForkHeights)
chain.snapshot = nil
Expand Down Expand Up @@ -1682,7 +1682,7 @@ func TestGetLockedStakeEntriesInRange(t *testing.T) {
utxoView._setLockedStakeEntryMappings(lockedStakeEntry)
require.NoError(t, utxoView.FlushToDb(blockHeight))

// Fetch the LockedStakeEntry so it is also cached in the UtxoView.
// Fetch the LockedStakeEntry, so it is also cached in the UtxoView.
lockedStakeEntry, err = utxoView.GetLockedStakeEntry(m0PKID, m0PKID, 2)
require.NoError(t, err)
require.NotNil(t, lockedStakeEntry)
Expand Down Expand Up @@ -1770,7 +1770,7 @@ func TestStakeLockupEpochDuration(t *testing.T) {

// Initialize fork heights.
params.ForkHeights.DeSoUnlimitedDerivedKeysBlockHeight = uint32(0)
params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight = uint32(1)
params.ForkHeights.ProofOfStake1StateSetupBlockHeight = uint32(1)
GlobalDeSoParams.EncoderMigrationHeights = GetEncoderMigrationHeights(&params.ForkHeights)
GlobalDeSoParams.EncoderMigrationHeightsList = GetEncoderMigrationHeightsList(&params.ForkHeights)
chain.snapshot = nil
Expand Down Expand Up @@ -1932,8 +1932,8 @@ func testStakingToJailedValidator(t *testing.T, flushToDB bool) {
chain, params, db := NewLowDifficultyBlockchain(t)
mempool, miner := NewTestMiner(t, chain, params, true)

// Initialize fork heights.
params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight = uint32(1)
// Initialize PoS fork heights.
params.ForkHeights.ProofOfStake1StateSetupBlockHeight = uint32(1)
GlobalDeSoParams.EncoderMigrationHeights = GetEncoderMigrationHeights(&params.ForkHeights)
GlobalDeSoParams.EncoderMigrationHeightsList = GetEncoderMigrationHeightsList(&params.ForkHeights)
chain.snapshot = nil
Expand Down
12 changes: 6 additions & 6 deletions lib/block_view_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ func (op *UtxoOperation) RawEncodeWithoutMetadata(blockHeight uint64, skipMetada
}
}

if MigrationTriggered(blockHeight, ProofOfStakeNewTxnTypesMigration) {
if MigrationTriggered(blockHeight, ProofOfStake1StateSetupMigration) {
// PrevValidatorEntry
data = append(data, EncodeToBytes(blockHeight, op.PrevValidatorEntry, skipMetadata...)...)

Expand Down Expand Up @@ -1870,7 +1870,7 @@ func (op *UtxoOperation) RawDecodeWithoutMetadata(blockHeight uint64, rr *bytes.
}
}

if MigrationTriggered(blockHeight, ProofOfStakeNewTxnTypesMigration) {
if MigrationTriggered(blockHeight, ProofOfStake1StateSetupMigration) {
// PrevValidatorEntry
if op.PrevValidatorEntry, err = DecodeDeSoEncoder(&ValidatorEntry{}, rr); err != nil {
return errors.Wrapf(err, "UtxoOperation.Decode: Problem reading PrevValidatorEntry: ")
Expand Down Expand Up @@ -1900,7 +1900,7 @@ func (op *UtxoOperation) GetVersionByte(blockHeight uint64) byte {
blockHeight,
AssociationsAndAccessGroupsMigration,
BalanceModelMigration,
ProofOfStakeNewTxnTypesMigration,
ProofOfStake1StateSetupMigration,
)
}

Expand Down Expand Up @@ -3793,7 +3793,7 @@ func (gp *GlobalParamsEntry) RawEncodeWithoutMetadata(blockHeight uint64, skipMe
if MigrationTriggered(blockHeight, BalanceModelMigration) {
data = append(data, UintToBuf(gp.MaxNonceExpirationBlockHeightOffset)...)
}
if MigrationTriggered(blockHeight, ProofOfStakeNewTxnTypesMigration) {
if MigrationTriggered(blockHeight, ProofOfStake1StateSetupMigration) {
data = append(data, UintToBuf(gp.StakeLockupEpochDuration)...)
data = append(data, UintToBuf(gp.ValidatorJailEpochDuration)...)
}
Expand Down Expand Up @@ -3829,7 +3829,7 @@ func (gp *GlobalParamsEntry) RawDecodeWithoutMetadata(blockHeight uint64, rr *by
return errors.Wrapf(err, "GlobalParamsEntry.Decode: Problem reading MaxNonceExpirationBlockHeightOffset")
}
}
if MigrationTriggered(blockHeight, ProofOfStakeNewTxnTypesMigration) {
if MigrationTriggered(blockHeight, ProofOfStake1StateSetupMigration) {
gp.StakeLockupEpochDuration, err = ReadUvarint(rr)
if err != nil {
return errors.Wrapf(err, "GlobalParamsEntry.Decode: Problem reading StakeLockupEpochDuration")
Expand All @@ -3843,7 +3843,7 @@ func (gp *GlobalParamsEntry) RawDecodeWithoutMetadata(blockHeight uint64, rr *by
}

func (gp *GlobalParamsEntry) GetVersionByte(blockHeight uint64) byte {
return GetMigrationVersion(blockHeight, BalanceModelMigration, ProofOfStakeNewTxnTypesMigration)
return GetMigrationVersion(blockHeight, BalanceModelMigration, ProofOfStake1StateSetupMigration)
}

func (gp *GlobalParamsEntry) GetEncoderType() EncoderType {
Expand Down
12 changes: 6 additions & 6 deletions lib/block_view_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ func (bav *UtxoView) _connectRegisterAsValidator(
_err error,
) {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight {
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight {
return 0, 0, nil, errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_connectRegisterAsValidator: ")
}

Expand Down Expand Up @@ -1115,7 +1115,7 @@ func (bav *UtxoView) _disconnectRegisterAsValidator(
blockHeight uint32,
) error {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight {
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight {
return errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_disconnectRegisterAsValidator: ")
}

Expand Down Expand Up @@ -1178,7 +1178,7 @@ func (bav *UtxoView) _connectUnregisterAsValidator(
_err error,
) {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight {
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight {
return 0, 0, nil, errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_connectUnregisterAsValidator: ")
}

Expand Down Expand Up @@ -1350,7 +1350,7 @@ func (bav *UtxoView) _disconnectUnregisterAsValidator(
blockHeight uint32,
) error {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight {
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight {
return errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_disconnectUnregisterAsValidator: ")
}

Expand Down Expand Up @@ -1436,7 +1436,7 @@ func (bav *UtxoView) _connectUnjailValidator(
_err error,
) {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight {
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight {
return 0, 0, nil, errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_connectUnjailValidator: ")
}

Expand Down Expand Up @@ -1541,7 +1541,7 @@ func (bav *UtxoView) _disconnectUnjailValidator(
blockHeight uint32,
) error {
// Validate the starting block height.
if blockHeight < bav.Params.ForkHeights.ProofOfStakeNewTxnTypesBlockHeight {
if blockHeight < bav.Params.ForkHeights.ProofOfStake1StateSetupBlockHeight {
return errors.Wrapf(RuleErrorProofofStakeTxnBeforeBlockHeight, "_disconnectUnjailValidator: ")
}

Expand Down
Loading