-
Notifications
You must be signed in to change notification settings - Fork 704
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 2 - Replace txs.ScheduledStaker with txs.Staker #2305
Changes from 3 commits
17723e2
88130e4
acc1517
3ec3cd2
19a8318
b213740
9e7f851
13d150f
6079eb0
9e5cc17
c6736b6
6f34808
a0fb538
944f309
7b79d43
0106d75
0ed0d1f
9a9897c
409008f
d17f2a2
6ab4d6e
4c4c011
905e55e
89094cd
5dd8dd8
6fe5652
698af90
0c631c6
8717574
c3e3670
9606b77
ce87dea
fd33fde
4f06497
6ea5add
b820cae
ef2443c
8260546
73d5c2f
84321ef
c353c33
d296e52
3d27b66
9bd9d60
a99a5f7
c07e2c8
105f5f1
5bb301b
e6463b7
43839ee
15d7871
5e10688
0e40da4
02ca462
a5b3875
a7daf81
a2115a4
fb85fe1
f0e490e
bfc29a1
9b97b59
02449eb
0684a8a
d914f34
89ce3c2
f0c55ef
fa9269c
e73b312
5330986
d3a6bf5
db4c048
b100a3d
b265b3c
85c41e6
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 |
---|---|---|
|
@@ -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() | ||
stakeDuration := tx.Validator.Duration() | ||
currentSupply, err := s.GetCurrentSupply(constants.PrimaryNetworkID) | ||
if err != nil { | ||
|
@@ -1341,7 +1341,7 @@ func (s *state) syncGenesis(genesisBlk block.Block, genesis *genesis.Genesis) er | |
return err | ||
} | ||
|
||
staker, err := NewCurrentStaker(vdrTx.ID(), tx, potentialReward) | ||
staker, err := NewCurrentStaker(vdrTx.ID(), tx, tx.StartTime(), potentialReward) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -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.Staker) | ||
if !ok { | ||
return fmt.Errorf("expected tx type txs.Staker but got %T", tx.Unsigned) | ||
} | ||
|
||
metadataBytes := validatorIt.Value() | ||
|
@@ -1456,16 +1460,16 @@ func (s *state) loadCurrentValidators() error { | |
// Note: we don't provide [LastUpdated] here because we expect it to | ||
// always be present on disk. | ||
} | ||
if err := parseValidatorMetadata(metadataBytes, metadata); err != nil { | ||
err = parseValidatorMetadata(metadataBytes, metadata) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
stakerTx, ok := tx.Unsigned.(txs.Staker) | ||
if !ok { | ||
return fmt.Errorf("expected tx type txs.Staker but got %T", tx.Unsigned) | ||
} | ||
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 moved up a fewl line. This should never happen, but always better to fail fast. |
||
|
||
staker, err := NewCurrentStaker(txID, stakerTx, metadata.PotentialReward) | ||
staker, err := NewCurrentStaker( | ||
txID, | ||
stakerTx.(txs.PostDurangoStaker), | ||
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. this is safe because all of our StakerTxs are also PostDurangoStakerTxs and viceversa. We type assert it for each transaction. |
||
stakerTx.StartTime(), | ||
metadata.PotentialReward) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -1507,7 +1511,12 @@ func (s *state) loadCurrentValidators() error { | |
return err | ||
} | ||
|
||
staker, err := NewCurrentStaker(txID, stakerTx, metadata.PotentialReward) | ||
staker, err := NewCurrentStaker( | ||
txID, | ||
stakerTx.(txs.PostDurangoStaker), | ||
stakerTx.StartTime(), | ||
metadata.PotentialReward, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -1537,6 +1546,11 @@ 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) | ||
} | ||
|
||
metadata := &delegatorMetadata{ | ||
txID: txID, | ||
} | ||
|
@@ -1545,12 +1559,12 @@ 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) | ||
} | ||
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 moved up a bit. Should never happen but always better to fail fast |
||
|
||
staker, err := NewCurrentStaker(txID, stakerTx, metadata.PotentialReward) | ||
staker, err := NewCurrentStaker( | ||
txID, | ||
stakerTx.(txs.PostDurangoStaker), | ||
stakerTx.StartTime(), | ||
metadata.PotentialReward, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
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.
This is the main point of this PR. Upon drop of pending stakers, we'll explicitly pass chainTime here to create the staker object. In this PR we anticipate the structural change by spreading use of txs.Staker instead of txs.ScheduledStaker wherever possible