Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
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
4 changes: 2 additions & 2 deletions plugin/evm/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type CurrentValidator struct {
Weight uint64 `json:"weight"`
StartTimestamp uint64 `json:"startTimestamp"`
IsActive bool `json:"isActive"`
IsSoV bool `json:"isSoV"`
IsL1Validator bool `json:"isL1Validator"`
IsConnected bool `json:"isConnected"`
Uptime time.Duration `json:"uptime"`
}
Expand Down Expand Up @@ -56,7 +56,7 @@ func (api *ValidatorsAPI) GetCurrentValidators(_ *http.Request, _ *struct{}, rep
StartTimestamp: validator.StartTimestamp,
Weight: validator.Weight,
IsActive: validator.IsActive,
IsSoV: validator.IsSoV,
IsL1Validator: validator.IsL1Validator,
IsConnected: isConnected,
Uptime: time.Duration(uptime.Seconds()),
})
Expand Down
2 changes: 1 addition & 1 deletion plugin/evm/validators/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func loadValidators(validatorState stateinterfaces.State, newValidators map[ids.
Weight: newVdr.Weight,
StartTimestamp: newVdr.StartTime,
IsActive: newVdr.IsActive,
IsSoV: newVdr.IsSoV,
IsL1Validator: newVdr.IsSoV,
}
if currentValidationIDs.Contains(newVID) {
if err := validatorState.UpdateValidator(currentVdr); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions plugin/evm/validators/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func TestLoadNewValidators(t *testing.T) {
Weight: validator.Weight,
StartTimestamp: validator.StartTime,
IsActive: validator.IsActive,
IsSoV: validator.IsSoV,
IsL1Validator: validator.IsSoV,
})
require.NoError(err)
}
Expand All @@ -214,7 +214,7 @@ func TestLoadNewValidators(t *testing.T) {
require.Equal(validator.Weight, v.Weight)
require.Equal(validator.StartTime, v.StartTimestamp)
require.Equal(validator.IsActive, v.IsActive)
require.Equal(validator.IsSoV, v.IsSoV)
require.Equal(validator.IsSoV, v.IsL1Validator)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/evm/validators/state/interfaces/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ type Validator struct {
Weight uint64 `json:"weight"`
StartTimestamp uint64 `json:"startTimestamp"`
IsActive bool `json:"isActive"`
IsSoV bool `json:"isSoV"`
IsL1Validator bool `json:"isL1Validator"`
}
34 changes: 17 additions & 17 deletions plugin/evm/validators/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const (
)

type validatorData struct {
UpDuration time.Duration `serialize:"true"`
LastUpdated uint64 `serialize:"true"`
NodeID ids.NodeID `serialize:"true"`
Weight uint64 `serialize:"true"`
StartTime uint64 `serialize:"true"`
IsActive bool `serialize:"true"`
IsSoV bool `serialize:"true"`
UpDuration time.Duration `serialize:"true"`
LastUpdated uint64 `serialize:"true"`
NodeID ids.NodeID `serialize:"true"`
Weight uint64 `serialize:"true"`
StartTime uint64 `serialize:"true"`
IsActive bool `serialize:"true"`
IsL1Validator bool `serialize:"true"`

validationID ids.ID // database key
}
Expand Down Expand Up @@ -105,14 +105,14 @@ func (s *state) GetStartTime(nodeID ids.NodeID) (time.Time, error) {
// the new validator is marked as updated and will be written to the disk when WriteState is called
func (s *state) AddValidator(vdr interfaces.Validator) error {
data := &validatorData{
NodeID: vdr.NodeID,
validationID: vdr.ValidationID,
IsActive: vdr.IsActive,
StartTime: vdr.StartTimestamp,
UpDuration: 0,
LastUpdated: vdr.StartTimestamp,
IsSoV: vdr.IsSoV,
Weight: vdr.Weight,
NodeID: vdr.NodeID,
validationID: vdr.ValidationID,
IsActive: vdr.IsActive,
StartTime: vdr.StartTimestamp,
UpDuration: 0,
LastUpdated: vdr.StartTimestamp,
IsL1Validator: vdr.IsL1Validator,
Weight: vdr.Weight,
}
if err := s.addData(vdr.ValidationID, data); err != nil {
return err
Expand Down Expand Up @@ -251,7 +251,7 @@ func (s *state) GetValidator(vID ids.ID) (interfaces.Validator, error) {
StartTimestamp: data.StartTime,
IsActive: data.IsActive,
Weight: data.Weight,
IsSoV: data.IsSoV,
IsL1Validator: data.IsL1Validator,
}, nil
}

Expand Down Expand Up @@ -345,6 +345,6 @@ func (v *validatorData) getStartTime() time.Time {
func (v *validatorData) constantsAreUnmodified(u interfaces.Validator) bool {
return v.validationID == u.ValidationID &&
v.NodeID == u.NodeID &&
v.IsSoV == u.IsSoV &&
v.IsL1Validator == u.IsL1Validator &&
v.StartTime == u.StartTimestamp
}
56 changes: 28 additions & 28 deletions plugin/evm/validators/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestState(t *testing.T) {
Weight: 1,
StartTimestamp: uint64(startTime.Unix()),
IsActive: true,
IsSoV: true,
IsL1Validator: true,
}
state.AddValidator(vdr)

Expand Down Expand Up @@ -98,7 +98,7 @@ func TestState(t *testing.T) {
require.ErrorIs(state.UpdateValidator(vdr), ErrImmutableField)

// set SoV should fail
vdr.IsSoV = false
vdr.IsL1Validator = false
require.ErrorIs(state.UpdateValidator(vdr), ErrImmutableField)

// set validation ID should result in not found
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestWriteValidator(t *testing.T) {
Weight: 1,
StartTimestamp: uint64(startTime.Unix()),
IsActive: true,
IsSoV: true,
IsL1Validator: true,
}))

// write state, should reflect to DB
Expand Down Expand Up @@ -176,29 +176,29 @@ func TestParseValidator(t *testing.T) {
name: "nil",
bytes: nil,
expected: &validatorData{
LastUpdated: 0,
StartTime: 0,
validationID: ids.Empty,
NodeID: ids.EmptyNodeID,
UpDuration: 0,
Weight: 0,
IsActive: false,
IsSoV: false,
LastUpdated: 0,
StartTime: 0,
validationID: ids.Empty,
NodeID: ids.EmptyNodeID,
UpDuration: 0,
Weight: 0,
IsActive: false,
IsL1Validator: false,
},
expectedErr: nil,
},
{
name: "empty",
bytes: []byte{},
expected: &validatorData{
LastUpdated: 0,
StartTime: 0,
validationID: ids.Empty,
NodeID: ids.EmptyNodeID,
UpDuration: 0,
Weight: 0,
IsActive: false,
IsSoV: false,
LastUpdated: 0,
StartTime: 0,
validationID: ids.Empty,
NodeID: ids.EmptyNodeID,
UpDuration: 0,
Weight: 0,
IsActive: false,
IsL1Validator: false,
},
expectedErr: nil,
},
Expand All @@ -225,13 +225,13 @@ func TestParseValidator(t *testing.T) {
0x01,
},
expected: &validatorData{
UpDuration: time.Duration(6000000),
LastUpdated: 900000,
NodeID: testNodeID,
StartTime: 6000000,
IsActive: true,
Weight: 1,
IsSoV: true,
UpDuration: time.Duration(6000000),
LastUpdated: 900000,
NodeID: testNodeID,
StartTime: 6000000,
IsActive: true,
Weight: 1,
IsL1Validator: true,
},
},
{
Expand Down Expand Up @@ -299,7 +299,7 @@ func TestStateListener(t *testing.T) {
Weight: 1,
StartTimestamp: uint64(initialStartTime.Unix()),
IsActive: true,
IsSoV: true,
IsL1Validator: true,
}))

// register listener
Expand All @@ -314,7 +314,7 @@ func TestStateListener(t *testing.T) {
Weight: 1,
StartTimestamp: uint64(expectedStartTime.Unix()),
IsActive: true,
IsSoV: true,
IsL1Validator: true,
}
require.NoError(state.AddValidator(vdr))

Expand Down
2 changes: 1 addition & 1 deletion warp/verifier_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func TestUptimeSignatures(t *testing.T) {
Weight: 1,
StartTimestamp: clk.Unix(),
IsActive: true,
IsSoV: true,
IsL1Validator: true,
}))
protoBytes, _ = getUptimeMessageBytes([]byte{}, validationID, 80)
_, appErr = handler.AppRequest(context.Background(), nodeID, time.Time{}, protoBytes)
Expand Down