Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8f2ba5c
Add epoch data type.
mattfoley8 Apr 28, 2023
ce42544
Update func naming.
mattfoley8 Apr 28, 2023
21272d5
Fix nil error.
mattfoley8 Apr 28, 2023
d590dbe
Add prefix encoder db util.
mattfoley8 Apr 28, 2023
aa34085
Rename field to FinalBlockHeight.
mattfoley8 Apr 28, 2023
b2beb9e
Avoid snapshotting issue for now.
mattfoley8 Apr 28, 2023
0f5f949
Update ancestral record before setting in db.
mattfoley8 Apr 28, 2023
6d1ebf5
Incorporate epoch number into PoS txns.
mattfoley8 Apr 28, 2023
c7b0268
Validate stake lockup period.
mattfoley8 May 1, 2023
d2bb3aa
Validate stake lockup period.
mattfoley8 May 1, 2023
f916c0c
Clean up test file changes.
mattfoley8 May 1, 2023
e4bfe24
Add jailed status to validator entries.
mattfoley8 May 2, 2023
38e0000
Set stake lockup period to 3 epochs.
mattfoley8 May 2, 2023
d61baa8
Merge branch 'mf/validate-stake-lockup-period' into mf/add-jailed-sta…
mattfoley8 May 2, 2023
4d572e1
Set LastActiveEpochNumber to CurrentEpochNumber.
mattfoley8 May 2, 2023
299bbf0
Add unjail validator txn type.
mattfoley8 May 2, 2023
6a08b23
Add ValidatorEntry.JailedAtEpochNumber field.
mattfoley8 May 2, 2023
693844f
Merge branch 'mf/add-jailed-status-to-validator-entries' into mf/add-…
mattfoley8 May 2, 2023
e0f7457
Validate sufficient num epochs have passed to unjail.
mattfoley8 May 2, 2023
9b7f4db
Merge upstream branch. Resolve conflicts.
mattfoley8 May 4, 2023
36e837b
Resolve merge conflicts more.
mattfoley8 May 4, 2023
8f95ac7
Start adding tests for unjail connect logic.
mattfoley8 May 4, 2023
c5fe55e
Add unjail validator tests.
mattfoley8 May 4, 2023
6017710
Retrigger buildkite ci.
mattfoley8 May 4, 2023
359940c
Address PR feedback.
mattfoley8 May 8, 2023
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
7 changes: 7 additions & 0 deletions lib/block_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,10 @@ func (bav *UtxoView) DisconnectTransaction(currentTxn *MsgDeSoTxn, txnHash *Bloc
case TxnTypeUnlockStake:
return bav._disconnectUnlockStake(
OperationTypeUnlockStake, currentTxn, txnHash, utxoOpsForTxn, blockHeight)

case TxnTypeUnjailValidator:
return bav._disconnectUnjailValidator(
OperationTypeUnjailValidator, currentTxn, txnHash, utxoOpsForTxn, blockHeight)
}

return fmt.Errorf("DisconnectBlock: Unimplemented txn type %v", currentTxn.TxnMeta.GetTxnType().String())
Expand Down Expand Up @@ -3311,6 +3315,9 @@ func (bav *UtxoView) _connectTransaction(txn *MsgDeSoTxn, txHash *BlockHash,
case TxnTypeUnlockStake:
totalInput, totalOutput, utxoOpsForTxn, err = bav._connectUnlockStake(txn, txHash, blockHeight, verifySignatures)

case TxnTypeUnjailValidator:
totalInput, totalOutput, utxoOpsForTxn, err = bav._connectUnjailValidator(txn, txHash, blockHeight, verifySignatures)

default:
err = fmt.Errorf("ConnectTransaction: Unimplemented txn type %v", txn.TxnMeta.GetTxnType().String())
}
Expand Down
18 changes: 5 additions & 13 deletions lib/block_view_stake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
func TestStaking(t *testing.T) {
_testStaking(t, false)
_testStaking(t, true)
_testStakingWithDerivedKey(t)
}

func _testStaking(t *testing.T, flushToDB bool) {
Expand Down Expand Up @@ -103,9 +102,7 @@ func _testStaking(t *testing.T, flushToDB bool) {
registerAsValidatorMetadata := &RegisterAsValidatorMetadata{
Domains: [][]byte{[]byte("https://example.com")},
}
_, _, _, err = _submitRegisterAsValidatorTxn(
testMeta, m0Pub, m0Priv, registerAsValidatorMetadata, nil, flushToDB,
)
_, err = _submitRegisterAsValidatorTxn(testMeta, m0Pub, m0Priv, registerAsValidatorMetadata, nil, flushToDB)
require.NoError(t, err)

validatorEntry, err := utxoView().GetValidatorByPKID(m0PKID)
Expand Down Expand Up @@ -755,7 +752,7 @@ func _submitUnlockStakeTxn(
return fees, nil
}

func _testStakingWithDerivedKey(t *testing.T) {
func TestStakingWithDerivedKey(t *testing.T) {
var derivedKeyPriv string
var err error

Expand Down Expand Up @@ -957,19 +954,15 @@ func _testStakingWithDerivedKey(t *testing.T) {
registerAsValidatorMetadata := &RegisterAsValidatorMetadata{
Domains: [][]byte{[]byte("https://example1.com")},
}
_, _, _, err = _submitRegisterAsValidatorTxn(
testMeta, m0Pub, m0Priv, registerAsValidatorMetadata, nil, true,
)
_, err = _submitRegisterAsValidatorTxn(testMeta, m0Pub, m0Priv, registerAsValidatorMetadata, nil, true)
require.NoError(t, err)
}
{
// m1 registers as a validator.
registerAsValidatorMetadata := &RegisterAsValidatorMetadata{
Domains: [][]byte{[]byte("https://example2.com")},
}
_, _, _, err = _submitRegisterAsValidatorTxn(
testMeta, m1Pub, m1Priv, registerAsValidatorMetadata, nil, true,
)
_, err = _submitRegisterAsValidatorTxn(testMeta, m1Pub, m1Priv, registerAsValidatorMetadata, nil, true)
require.NoError(t, err)
}
{
Expand Down Expand Up @@ -1783,7 +1776,6 @@ func TestStakeLockupEpochDuration(t *testing.T) {
chain.snapshot = nil

// For these tests, we set StakeLockupEpochDuration to 3.
// We test the lockup logic in a separate test.
params.StakeLockupEpochDuration = 3

// Mine a few blocks to give the senderPkString some money.
Expand Down Expand Up @@ -1843,7 +1835,7 @@ func TestStakeLockupEpochDuration(t *testing.T) {
registerMetadata := &RegisterAsValidatorMetadata{
Domains: [][]byte{[]byte("https://m1.com")},
}
_, _, _, err = _submitRegisterAsValidatorTxn(testMeta, m0Pub, m0Priv, registerMetadata, nil, true)
_, err = _submitRegisterAsValidatorTxn(testMeta, m0Pub, m0Priv, registerMetadata, nil, true)
require.NoError(t, err)

validatorEntry, err := newUtxoView().GetValidatorByPKID(m0PKID)
Expand Down
10 changes: 8 additions & 2 deletions lib/block_view_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ const (
EncoderTypeStakeTxindexMetadata EncoderType = 1000032
EncoderTypeUnstakeTxindexMetadata EncoderType = 1000033
EncoderTypeUnlockStakeTxindexMetadata EncoderType = 1000034
EncoderTypeUnjailValidatorTxindexMetadata EncoderType = 1000035

// EncoderTypeEndTxIndex encoder type should be at the end and is used for automated tests.
EncoderTypeEndTxIndex EncoderType = 1000035
EncoderTypeEndTxIndex EncoderType = 1000036
)

// This function translates the EncoderType into an empty DeSoEncoder struct.
Expand Down Expand Up @@ -327,6 +328,8 @@ func (encoderType EncoderType) New() DeSoEncoder {
return &UnstakeTxindexMetadata{}
case EncoderTypeUnlockStakeTxindexMetadata:
return &UnlockStakeTxindexMetadata{}
case EncoderTypeUnjailValidatorTxindexMetadata:
return &UnjailValidatorTxindexMetadata{}
default:
return nil
}
Expand Down Expand Up @@ -626,8 +629,9 @@ const (
OperationTypeStake OperationType = 41
OperationTypeUnstake OperationType = 42
OperationTypeUnlockStake OperationType = 43
OperationTypeUnjailValidator OperationType = 44

// NEXT_TAG = 44
// NEXT_TAG = 45
)

func (op OperationType) String() string {
Expand Down Expand Up @@ -718,6 +722,8 @@ func (op OperationType) String() string {
return "OperationTypeUnstake"
case OperationTypeUnlockStake:
return "OperationTypeUnlockStake"
case OperationTypeUnjailValidator:
return "OperationTypeUnjailValidator"
}
return "OperationTypeUNKNOWN"
}
Expand Down
Loading