-
Notifications
You must be signed in to change notification settings - Fork 702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop Pending Stakers 1 - introduced ScheduledStaker txs #2323
Changes from 12 commits
6079eb0
c6736b6
944f309
0106d75
9a9897c
d17f2a2
4c4c011
905e55e
89094cd
5dd8dd8
698af90
0c631c6
c3e3670
9606b77
ce87dea
fd33fde
6ea5add
b820cae
8260546
73d5c2f
84321ef
c353c33
d296e52
9bd9d60
a99a5f7
c07e2c8
5bb301b
e6463b7
43839ee
15d7871
5e10688
0e40da4
a5b3875
a7daf81
fb85fe1
bfc29a1
9b97b59
0684a8a
d914f34
89ce3c2
fa9269c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,11 +144,11 @@ func TestNewCurrentStaker(t *testing.T) { | |
subnetID := ids.GenerateTestID() | ||
weight := uint64(12345) | ||
startTime := time.Now() | ||
endTime := time.Now() | ||
endTime := startTime.Add(time.Hour) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just a nit, not strictly relevant to this PR, but I'd rather take it out of the way |
||
potentialReward := uint64(54321) | ||
currentPriority := txs.SubnetPermissionedValidatorCurrentPriority | ||
|
||
stakerTx := txs.NewMockStaker(ctrl) | ||
stakerTx := txs.NewMockScheduledStaker(ctrl) | ||
stakerTx.EXPECT().NodeID().Return(nodeID) | ||
stakerTx.EXPECT().PublicKey().Return(publicKey, true, nil) | ||
stakerTx.EXPECT().SubnetID().Return(subnetID) | ||
|
@@ -192,7 +192,7 @@ func TestNewPendingStaker(t *testing.T) { | |
endTime := time.Now() | ||
pendingPriority := txs.SubnetPermissionedValidatorPendingPriority | ||
|
||
stakerTx := txs.NewMockStaker(ctrl) | ||
stakerTx := txs.NewMockScheduledStaker(ctrl) | ||
stakerTx.EXPECT().NodeID().Return(nodeID) | ||
stakerTx.EXPECT().PublicKey().Return(publicKey, true, nil) | ||
stakerTx.EXPECT().SubnetID().Return(subnetID) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1324,7 +1324,7 @@ func (s *state) syncGenesis(genesisBlk block.Block, genesis *genesis.Genesis) er | |
return fmt.Errorf("expected tx type *txs.AddValidatorTx but got %T", vdrTx.Unsigned) | ||
} | ||
|
||
stakeAmount := tx.Validator.Wght | ||
stakeAmount := tx.Weight() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just a nit, not strictly relevant to this PR, but I'd rather take it out of the way |
||
stakeDuration := tx.Validator.Duration() | ||
currentSupply, err := s.GetCurrentSupply(constants.PrimaryNetworkID) | ||
if err != nil { | ||
|
@@ -1447,7 +1447,11 @@ func (s *state) loadCurrentValidators() error { | |
} | ||
tx, _, err := s.GetTx(txID) | ||
if err != nil { | ||
return err | ||
return fmt.Errorf("failed loading validator transaction txID %v, %w", txID, err) | ||
} | ||
stakerTx, ok := tx.Unsigned.(txs.ScheduledStaker) | ||
if !ok { | ||
return fmt.Errorf("expected tx type txs.Staker but got %T", tx.Unsigned) | ||
} | ||
|
||
metadataBytes := validatorIt.Value() | ||
|
@@ -1460,11 +1464,6 @@ func (s *state) loadCurrentValidators() error { | |
return err | ||
} | ||
|
||
stakerTx, ok := tx.Unsigned.(txs.Staker) | ||
if !ok { | ||
return fmt.Errorf("expected tx type txs.Staker but got %T", tx.Unsigned) | ||
} | ||
|
||
staker, err := NewCurrentStaker(txID, stakerTx, metadata.PotentialReward) | ||
if err != nil { | ||
return err | ||
|
@@ -1491,17 +1490,18 @@ func (s *state) loadCurrentValidators() error { | |
return err | ||
} | ||
|
||
stakerTx, ok := tx.Unsigned.(txs.Staker) | ||
stakerTx, ok := tx.Unsigned.(txs.ScheduledStaker) | ||
if !ok { | ||
return fmt.Errorf("expected tx type txs.Staker but got %T", tx.Unsigned) | ||
} | ||
|
||
metadataBytes := subnetValidatorIt.Value() | ||
startTime := stakerTx.StartTime() | ||
metadata := &validatorMetadata{ | ||
txID: txID, | ||
// use the start time as the fallback value | ||
// in case it's not stored in the database | ||
LastUpdated: uint64(stakerTx.StartTime().Unix()), | ||
LastUpdated: uint64(startTime.Unix()), | ||
} | ||
if err := parseValidatorMetadata(metadataBytes, metadata); err != nil { | ||
return err | ||
|
@@ -1537,6 +1537,11 @@ func (s *state) loadCurrentValidators() error { | |
return err | ||
} | ||
|
||
stakerTx, ok := tx.Unsigned.(txs.ScheduledStaker) | ||
if !ok { | ||
return fmt.Errorf("expected tx type txs.Staker but got %T", tx.Unsigned) | ||
} | ||
|
||
metadata := &delegatorMetadata{ | ||
txID: txID, | ||
} | ||
|
@@ -1545,11 +1550,6 @@ func (s *state) loadCurrentValidators() error { | |
return err | ||
} | ||
|
||
stakerTx, ok := tx.Unsigned.(txs.Staker) | ||
if !ok { | ||
return fmt.Errorf("expected tx type txs.Staker but got %T", tx.Unsigned) | ||
} | ||
|
||
staker, err := NewCurrentStaker(txID, stakerTx, metadata.PotentialReward) | ||
if err != nil { | ||
return err | ||
|
@@ -1594,7 +1594,7 @@ func (s *state) loadPendingValidators() error { | |
return err | ||
} | ||
|
||
stakerTx, ok := tx.Unsigned.(txs.Staker) | ||
stakerTx, ok := tx.Unsigned.(txs.ScheduledStaker) | ||
if !ok { | ||
return fmt.Errorf("expected tx type txs.Staker but got %T", tx.Unsigned) | ||
} | ||
|
@@ -1629,7 +1629,7 @@ func (s *state) loadPendingValidators() error { | |
return err | ||
} | ||
|
||
stakerTx, ok := tx.Unsigned.(txs.Staker) | ||
stakerTx, ok := tx.Unsigned.(txs.ScheduledStaker) | ||
if !ok { | ||
return fmt.Errorf("expected tx type txs.Staker but got %T", tx.Unsigned) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,8 @@ import ( | |
) | ||
|
||
var ( | ||
_ DelegatorTx = (*AddDelegatorTx)(nil) | ||
_ DelegatorTx = (*AddDelegatorTx)(nil) | ||
_ ScheduledStaker = (*AddDelegatorTx)(nil) | ||
Comment on lines
+22
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no change to existing tx format |
||
|
||
errDelegatorWeightMismatch = errors.New("delegator weight is not equal to total stake weight") | ||
errStakeMustBeAVAX = errors.New("stake must be AVAX") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in next PR we'll change the signature of this function to use txs.Staker instead of txs.ScheduledStaker.