Commit 76fec17e authored by luxq's avatar luxq

update file

parent a946b8e6
jar { enabled = false }
repositories {
mavenCentral() // Ensure Maven Central is included
}
dependencies {
implementation project(':infrastructure:async')
implementation 'com.github.briandilley.jsonrpc4j:jsonrpc4j:1.7'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.2'
}
description = 'Teku Attacker Client'
\ No newline at end of file
package tech.pegasys.teku.attacker2;
package tech.pegasys.teku.attacker;
import com.googlecode.jsonrpc4j.JsonRpcHttpClient;
import tech.pegasys.teku.attacker.client.*;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
public class AttackService {
......
/*
* 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.attacker;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* AttackerCommand defines the command types that can be returned by the attacker client API. This
* matches the Go implementation in tsinghua-cel/attacker-client-go/client/type.go.
*/
public enum AttackerCommand {
CMD_NULL(0),
CMD_CONTINUE(1),
CMD_RETURN(2),
CMD_ABORT(3),
CMD_SKIP(4),
CMD_ROLE_TO_NORMAL(5), // Role changes to normal node
CMD_ROLE_TO_ATTACKER(6), // Role changes to attacker
CMD_EXIT(7),
CMD_UPDATE_STATE(8),
CMP_DELAY_BROAD_CAST(9);
private final int value;
AttackerCommand(int value) {
this.value = value;
}
@JsonValue
public int getValue() {
return value;
}
@JsonCreator
public static AttackerCommand fromValue(int value) {
for (AttackerCommand command : AttackerCommand.values()) {
if (command.value == value) {
return command;
}
}
throw new IllegalArgumentException("Unknown AttackerCommand value: " + value);
}
}
/*
* 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.attacker;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* AttackerResponse defines the response from the attacker client API. This matches the Go
* implementation in tsinghua-cel/attacker-client-go/client/type.go.
*/
public class AttackerResponse {
@JsonProperty("cmd")
private AttackerCommand cmd;
@JsonProperty("result")
private String result;
public AttackerResponse() {
// Default constructor for Jackson deserialization
}
public AttackerResponse(AttackerCommand cmd, String result) {
this.cmd = cmd;
this.result = result;
}
public AttackerCommand getCmd() {
return cmd;
}
public String getResult() {
return result;
}
/**
* Convenience method to check if the command is CMD_CONTINUE.
*
* @return true if the command is CMD_CONTINUE, false otherwise
*/
public boolean shouldContinue() {
return cmd == AttackerCommand.CMD_CONTINUE;
}
/**
* Convenience method to check if the command is CMD_ABORT.
*
* @return true if the command is CMD_ABORT, false otherwise
*/
public boolean shouldAbort() {
return cmd == AttackerCommand.CMD_ABORT;
}
@Override
public String toString() {
return "AttackerResponse{" + "cmd=" + cmd + ", result='" + result + '\'' + '}';
}
}
package tech.pegasys.teku.attacker2;
package tech.pegasys.teku.attacker;
import com.googlecode.jsonrpc4j.JsonRpcHttpClient;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment