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
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import tech.pegasys.teku.api.DataProvider;
import tech.pegasys.teku.api.NetworkDataProvider;
import tech.pegasys.teku.api.peer.Eth2PeerWithEnr;
import tech.pegasys.teku.api.response.v1.node.Direction;
import tech.pegasys.teku.api.response.v1.node.State;
import tech.pegasys.teku.api.provider.Direction;
import tech.pegasys.teku.api.provider.State;
import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition;
import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition;
import tech.pegasys.teku.infrastructure.restapi.endpoints.EndpointMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package tech.pegasys.teku.api;

import static java.util.Collections.emptyList;
import static tech.pegasys.teku.api.response.v1.beacon.ValidatorResponse.getValidatorStatus;
import static tech.pegasys.teku.api.response.ValidatorStatusUtil.getValidatorStatus;
import static tech.pegasys.teku.infrastructure.unsigned.UInt64.ONE;
import static tech.pegasys.teku.infrastructure.unsigned.UInt64.ZERO;
import static tech.pegasys.teku.spec.config.SpecConfig.FAR_FUTURE_EPOCH;
Expand Down Expand Up @@ -44,8 +44,8 @@
import tech.pegasys.teku.api.migrated.StateSyncCommitteesData;
import tech.pegasys.teku.api.migrated.StateValidatorBalanceData;
import tech.pegasys.teku.api.migrated.SyncCommitteeRewardData;
import tech.pegasys.teku.api.provider.GenesisData;
import tech.pegasys.teku.api.response.ValidatorStatus;
import tech.pegasys.teku.api.response.v1.beacon.GenesisData;
import tech.pegasys.teku.api.rewards.EpochAttestationRewardsCalculator;
import tech.pegasys.teku.api.stateselector.StateSelectorFactory;
import tech.pegasys.teku.bls.BLSPublicKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import java.util.function.Function;
import org.apache.tuweni.units.bigints.UInt256;
import tech.pegasys.teku.api.peer.Eth2PeerWithEnr;
import tech.pegasys.teku.api.response.v1.node.Direction;
import tech.pegasys.teku.api.response.v1.node.Peer;
import tech.pegasys.teku.api.response.v1.node.State;
import tech.pegasys.teku.api.provider.Direction;
import tech.pegasys.teku.api.provider.Peer;
import tech.pegasys.teku.api.provider.State;
import tech.pegasys.teku.ethereum.json.types.node.PeerCount;
import tech.pegasys.teku.ethereum.json.types.node.PeerCountBuilder;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
import tech.pegasys.teku.api.migrated.BlockRewardData;
import tech.pegasys.teku.api.migrated.StateSyncCommitteesData;
import tech.pegasys.teku.api.migrated.SyncCommitteeRewardData;
import tech.pegasys.teku.api.provider.GenesisData;
import tech.pegasys.teku.api.response.ValidatorStatus;
import tech.pegasys.teku.api.response.v1.beacon.GenesisData;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.async.SafeFutureAssert;
import tech.pegasys.teku.infrastructure.bytes.Bytes20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
import tech.pegasys.teku.api.migrated.BlockHeadersResponse;
import tech.pegasys.teku.api.migrated.StateSyncCommitteesData;
import tech.pegasys.teku.api.migrated.SyncCommitteeRewardData;
import tech.pegasys.teku.api.provider.GenesisData;
import tech.pegasys.teku.api.response.ValidatorStatus;
import tech.pegasys.teku.api.response.v1.beacon.GenesisData;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.bytes.Bytes4;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ public class PublicKeyException extends RuntimeException {
public PublicKeyException(final String message, final Throwable cause) {
super(message, cause);
}

public PublicKeyException(final String err) {
super(err);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.api.response.v1.node;
package tech.pegasys.teku.api.provider;

@SuppressWarnings("JavaCase")
public enum Direction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.api.response.v1.beacon;

import static tech.pegasys.teku.api.schema.SchemaConstants.EXAMPLE_BYTES32;
import static tech.pegasys.teku.api.schema.SchemaConstants.PATTERN_BYTES32;
package tech.pegasys.teku.api.provider;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand All @@ -35,7 +32,10 @@ public class GenesisData {
public final UInt64 genesisTime;

@JsonProperty("genesis_validators_root")
@Schema(type = "string", example = EXAMPLE_BYTES32, pattern = PATTERN_BYTES32)
@Schema(
type = "string",
example = "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
pattern = "^0x[a-fA-F0-9]{64}$")
public final Bytes32 genesisValidatorsRoot;

@JsonProperty("genesis_fork_version")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.api.response.v1.node;
package tech.pegasys.teku.api.provider;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.api.response.v1.node;
package tech.pegasys.teku.api.provider;

@SuppressWarnings("JavaCase")
public enum State {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright Consensys Software Inc., 2025
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.api.response;

import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.datastructures.state.Validator;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;

public class ValidatorStatusUtil {
Comment thread
rolfyone marked this conversation as resolved.
public static ValidatorStatus getValidatorStatus(
final BeaconState state,
final Integer validatorIndex,
final UInt64 epoch,
final UInt64 farFutureEpoch) {
return getValidatorStatus(epoch, state.getValidators().get(validatorIndex), farFutureEpoch);
}

public static ValidatorStatus getValidatorStatus(
final UInt64 epoch, final Validator validator, final UInt64 farFutureEpoch) {
// pending
if (validator.getActivationEpoch().isGreaterThan(epoch)) {
return validator.getActivationEligibilityEpoch().equals(farFutureEpoch)
? ValidatorStatus.pending_initialized
: ValidatorStatus.pending_queued;
}
// active
if (validator.getActivationEpoch().isLessThanOrEqualTo(epoch)
&& epoch.isLessThan(validator.getExitEpoch())) {
if (validator.getExitEpoch().equals(farFutureEpoch)) {
return ValidatorStatus.active_ongoing;
}
return validator.isSlashed()
? ValidatorStatus.active_slashed
: ValidatorStatus.active_exiting;
}

// exited
if (validator.getExitEpoch().isLessThanOrEqualTo(epoch)
&& epoch.isLessThan(validator.getWithdrawableEpoch())) {
return validator.isSlashed()
? ValidatorStatus.exited_slashed
: ValidatorStatus.exited_unslashed;
}

// withdrawal
if (validator.getWithdrawableEpoch().isLessThanOrEqualTo(epoch)) {
return validator.getEffectiveBalance().isGreaterThan(UInt64.ZERO)
? ValidatorStatus.withdrawal_possible
: ValidatorStatus.withdrawal_done;
}
throw new IllegalStateException("Unable to determine validator status");
}
}

This file was deleted.

This file was deleted.

Loading