-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add engine_getClientVersionV1 interface + ability to get commit hash (#…
- Loading branch information
1 parent
3824d24
commit be4dfc0
Showing
23 changed files
with
462 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...ient/src/main/java/tech/pegasys/teku/ethereum/executionclient/schema/ClientVersionV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2024 | ||
* | ||
* 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.ethereum.executionclient.schema; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.google.common.base.MoreObjects; | ||
import java.util.Objects; | ||
import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes4Deserializer; | ||
import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes4Serializer; | ||
import tech.pegasys.teku.infrastructure.bytes.Bytes4; | ||
import tech.pegasys.teku.spec.datastructures.execution.ClientVersion; | ||
|
||
public class ClientVersionV1 { | ||
|
||
public final String code; | ||
public final String name; | ||
public final String version; | ||
|
||
@JsonSerialize(using = Bytes4Serializer.class) | ||
@JsonDeserialize(using = Bytes4Deserializer.class) | ||
public final Bytes4 commit; | ||
|
||
public ClientVersionV1( | ||
@JsonProperty("code") String code, | ||
@JsonProperty("name") String name, | ||
@JsonProperty("version") String version, | ||
@JsonProperty("commit") Bytes4 commit) { | ||
checkNotNull(code, "code"); | ||
checkNotNull(name, "name"); | ||
checkNotNull(version, "version"); | ||
checkNotNull(commit, "commit"); | ||
this.code = code; | ||
this.name = name; | ||
this.version = version; | ||
this.commit = commit; | ||
} | ||
|
||
public static ClientVersionV1 fromInternalClientVersion(final ClientVersion clientVersion) { | ||
return new ClientVersionV1( | ||
clientVersion.code(), | ||
clientVersion.name(), | ||
clientVersion.version(), | ||
clientVersion.commit()); | ||
} | ||
|
||
public static ClientVersion asInternalClientVersion(final ClientVersionV1 clientVersionV1) { | ||
return new ClientVersion( | ||
clientVersionV1.code, | ||
clientVersionV1.name, | ||
clientVersionV1.version, | ||
clientVersionV1.commit); | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
final ClientVersionV1 that = (ClientVersionV1) o; | ||
return Objects.equals(code, that.code) | ||
&& Objects.equals(name, that.name) | ||
&& Objects.equals(version, that.version) | ||
&& Objects.equals(commit, that.commit); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(code, name, version, commit); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.add("code", code) | ||
.add("name", name) | ||
.add("version", version) | ||
.add("commit", commit) | ||
.toString(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ain/java/tech/pegasys/teku/ethereum/executionclient/serialization/Bytes4Deserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2022 | ||
* | ||
* 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.ethereum.executionclient.serialization; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import java.io.IOException; | ||
import tech.pegasys.teku.infrastructure.bytes.Bytes4; | ||
|
||
public class Bytes4Deserializer extends JsonDeserializer<Bytes4> { | ||
|
||
@Override | ||
public Bytes4 deserialize(final JsonParser p, final DeserializationContext ctxt) | ||
throws IOException { | ||
return Bytes4.fromHexString(p.getValueAsString()); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
.../main/java/tech/pegasys/teku/ethereum/executionclient/serialization/Bytes4Serializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2022 | ||
* | ||
* 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.ethereum.executionclient.serialization; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import java.io.IOException; | ||
import java.util.Locale; | ||
import tech.pegasys.teku.infrastructure.bytes.Bytes4; | ||
|
||
public class Bytes4Serializer extends JsonSerializer<Bytes4> { | ||
@Override | ||
public void serialize( | ||
final Bytes4 value, final JsonGenerator gen, final SerializerProvider serializers) | ||
throws IOException { | ||
gen.writeString(value.toHexString().toLowerCase(Locale.ROOT)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.