Skip to content

Commit 0d2eec1

Browse files
thinkAfCodGrapeBaBa
authored andcommitted
fix: hard forked to canyon
1 parent 4e1ae7d commit 0d2eec1

File tree

8 files changed

+95
-28
lines changed

8 files changed

+95
-28
lines changed

docker/docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ x-logging: &logging
99

1010
services:
1111
hildr-node:
12-
image: optimism-java/hildr-node:latest
12+
image: ghcr.io/optimism-java/hildr:latest
1313
container_name: hildr-node
1414
build:
15-
dockerfile: ./docker/Dockerfile
15+
dockerfile: ./docker/jvm.dock
1616
context: ../
1717
profiles:
1818
- hildr-node
1919
restart: unless-stopped
2020
stop_grace_period: 3m
21-
entrypoint: /scripts/start-hildr-node.sh
21+
entrypoint: /scripts/start-hildr-node-java.sh
2222
depends_on:
2323
- op-geth
2424
env_file:
@@ -33,7 +33,7 @@ services:
3333
<<: *logging
3434

3535
op-geth:
36-
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:v1.101304.1
36+
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:v1.101304.2
3737
container_name: op-geth
3838
profiles:
3939
- op-geth
@@ -49,7 +49,7 @@ services:
4949
volumes:
5050
- ./:/scripts
5151
- data:/data
52-
- ${OP_GENESIS_JSON_FILEPATH:-.}:/genesis-l2.json
52+
- ${OP_GENESIS_JSON_FILEPATH:-.}:/genesis-l2-attached.json
5353
<<: *logging
5454

5555
op-erigon:

docker/start-op-geth.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ then
5656
if [ ! -d $DATADIR ]
5757
then
5858
mkdir $DATADIR
59-
geth init --datadir=$DATADIR ./genesis-l2.json
59+
geth init --datadir=$DATADIR ./genesis-l2-attached.json
6060
fi
6161
else
6262
echo "Network not recognized. Available options are optimism-goerli and base-goerli"

hildr-node/src/main/java/io/optimism/driver/EngineDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ private OpEthExecutionPayload buildPayload(PayloadAttributes attributes)
338338
OpEthExecutionPayload res;
339339
try (var scope1 = new StructuredTaskScope.ShutdownOnFailure()) {
340340
StructuredTaskScope.Subtask<OpEthExecutionPayload> payloadFuture =
341-
scope1.fork(TracerTaskWrapper.wrap(() -> EngineDriver.this.engine.getPayload(payloadId)));
341+
scope1.fork(TracerTaskWrapper.wrap(() -> EngineDriver.this.engine.getPayloadV2(payloadId)));
342342

343343
scope1.join();
344344
scope1.throwIfFailed();

hildr-node/src/main/java/io/optimism/engine/Engine.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ OpEthForkChoiceUpdate forkchoiceUpdated(ForkchoiceState forkchoiceState, Payload
7777
* Retrieves a payload by ID, prepared by {forkChoiceUpdated} when called with {@code
7878
* payloadAttributes}.
7979
*
80-
* <p>Specification method: engine_getPayloadV1 params: - [PayloadId]: DATA, 8 Bytes - Identifier
80+
* <p>Specification method: engine_getPayloadV2 params: - [PayloadId]: DATA, 8 Bytes - Identifier
8181
* of the payload build process timeout: 1s returns: - [ExecutionPayload] potential errors: - code
8282
* and message set in case an exception happens while getting the payload. Refer to <a
83-
* href="https://github.com/ethereum-optimism/optimism/blob/develop/specs/exec-engine.md#engine_getPayloadv1">Optimism
83+
* href="https://github.com/ethereum-optimism/optimism/blob/develop/specs/exec-engine.md#engine_getpayloadv2">Optimism
8484
* Specs</a>
8585
*
8686
* @param payloadId the payload id
87-
* @return the payload
87+
* @return the payload v2
8888
* @throws IOException the io exception
8989
* @see <a
90-
* href="https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#engine_getpayloadv1">engine_getPayloadV1</a>
90+
* href="https://github.com/ethereum/execution-apis/blob/main/src/engine/shanghai.md#engine_getpayloadv2</a>
9191
*/
92-
OpEthExecutionPayload getPayload(BigInteger payloadId) throws IOException;
92+
OpEthExecutionPayload getPayloadV2(BigInteger payloadId) throws IOException;
9393
}

hildr-node/src/main/java/io/optimism/engine/EngineApi.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,20 @@ public EngineApi fromEnv() {
7373
if (StringUtils.isBlank(baseUrlParm)) {
7474
throw new RuntimeException(
7575
"""
76-
ENGINE_API_URL environment variable not set.
77-
Please set this to the base url of the engine api
78-
""");
76+
ENGINE_API_URL environment variable not set.
77+
Please set this to the base url of the engine api
78+
""");
7979
}
8080
String secretKey = System.getenv("JWT_SECRET");
8181
if (StringUtils.isBlank(secretKey)) {
8282
throw new RuntimeException(
8383
"""
84-
JWT_SECRET environment variable not set.
85-
Please set this to the 256 bit hex-encoded secret key
86-
used to authenticate with the engine api.
87-
This should be the same as set in the `--auth.secret`
88-
flag when executing go-ethereum.
89-
""");
84+
JWT_SECRET environment variable not set.
85+
Please set this to the 256 bit hex-encoded secret key
86+
used to authenticate with the engine api.
87+
This should be the same as set in the `--auth.secret`
88+
flag when executing go-ethereum.
89+
""");
9090
}
9191
String baseUrlFormat = authUrlFromAddr(baseUrlParm, null);
9292
return new EngineApi(baseUrlFormat, secretKey);
@@ -157,7 +157,7 @@ public OpEthPayloadStatus newPayload(ExecutionPayload executionPayload) throws I
157157
}
158158

159159
@Override
160-
public OpEthExecutionPayload getPayload(BigInteger payloadId) throws IOException {
160+
public OpEthExecutionPayload getPayloadV2(BigInteger payloadId) throws IOException {
161161
web3jService.addHeader("authorization", String.format("Bearer %1$s", generateJws(key)));
162162
Request<?, OpEthExecutionPayload> r = new Request<>(
163163
ENGINE_GET_PAYLOAD_V2,

hildr-node/src/main/java/io/optimism/engine/ExecutionPayload.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ public record ExecutionPayloadReq(
213213
String extraData,
214214
String baseFeePerGas,
215215
String blockHash,
216+
List<EthBlock.Withdrawal> withdrawals,
216217
List<String> transactions) {}
217218

218219
/**
@@ -235,6 +236,7 @@ public ExecutionPayloadReq toReq() {
235236
extraData,
236237
Numeric.toHexStringWithPrefix(baseFeePerGas),
237238
blockHash,
239+
withdrawals,
238240
transactions);
239241
}
240242

hildr-node/src/main/java/io/optimism/engine/OpEthExecutionPayload.java

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616

1717
package io.optimism.engine;
1818

19-
import io.optimism.engine.ExecutionPayload.ExecutionPayloadRes;
19+
import com.fasterxml.jackson.core.JsonParser;
20+
import com.fasterxml.jackson.core.JsonToken;
21+
import com.fasterxml.jackson.databind.DeserializationContext;
22+
import com.fasterxml.jackson.databind.JsonDeserializer;
23+
import com.fasterxml.jackson.databind.ObjectReader;
24+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
25+
import java.io.IOException;
26+
import java.util.Objects;
27+
import org.web3j.protocol.ObjectMapperFactory;
2028
import org.web3j.protocol.core.Response;
2129

2230
/**
@@ -25,7 +33,7 @@
2533
* @author grapebaba
2634
* @since 0.1.0
2735
*/
28-
public class OpEthExecutionPayload extends Response<ExecutionPayloadRes> {
36+
public class OpEthExecutionPayload extends Response<OpEthExecutionPayload.ExecutionPayloadObj> {
2937

3038
/** Instantiates a new Op eth execution payload. */
3139
public OpEthExecutionPayload() {}
@@ -36,11 +44,68 @@ public OpEthExecutionPayload() {}
3644
* @return the execution payload
3745
*/
3846
public ExecutionPayload getExecutionPayload() {
39-
return getResult().toExecutionPayload();
47+
return getResult().getExecutionPayload().toExecutionPayload();
4048
}
4149

4250
@Override
43-
public void setResult(ExecutionPayloadRes result) {
51+
@JsonDeserialize(using = ResponseDeserializer.class)
52+
public void setResult(ExecutionPayloadObj result) {
4453
super.setResult(result);
4554
}
55+
56+
public static class ExecutionPayloadObj {
57+
58+
private ExecutionPayload.ExecutionPayloadRes executionPayload;
59+
60+
public ExecutionPayloadObj() {}
61+
62+
public ExecutionPayloadObj(ExecutionPayload.ExecutionPayloadRes executionPayload) {
63+
this.executionPayload = executionPayload;
64+
}
65+
66+
public ExecutionPayload.ExecutionPayloadRes getExecutionPayload() {
67+
return executionPayload;
68+
}
69+
70+
public void setExecutionPayload(ExecutionPayload.ExecutionPayloadRes executionPayload) {
71+
this.executionPayload = executionPayload;
72+
}
73+
74+
@Override
75+
public boolean equals(Object o) {
76+
if (this == o) {
77+
return true;
78+
}
79+
if (!(o instanceof ExecutionPayloadObj that)) {
80+
return false;
81+
}
82+
return Objects.equals(executionPayload, that.executionPayload);
83+
}
84+
85+
@Override
86+
public int hashCode() {
87+
return Objects.hash(executionPayload);
88+
}
89+
}
90+
91+
/** Json Deserializer of ExecutionPayloadObj. */
92+
public static class ResponseDeserializer extends JsonDeserializer<ExecutionPayloadObj> {
93+
94+
private final ObjectReader objectReader;
95+
96+
/** Instantiates a new Response deserializer. */
97+
public ResponseDeserializer() {
98+
this.objectReader = ObjectMapperFactory.getObjectReader();
99+
}
100+
101+
@Override
102+
public ExecutionPayloadObj deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
103+
throws IOException {
104+
if (jsonParser.getCurrentToken() != JsonToken.VALUE_NULL) {
105+
return objectReader.readValue(jsonParser, ExecutionPayloadObj.class);
106+
} else {
107+
return null; // null is wrapped by Optional in above getter
108+
}
109+
}
110+
}
46111
}

hildr-node/src/test/java/io/optimism/engine/EngineApiTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ ExecutionPayloadRes initExecutionPayload() {
112112
String initExecutionPayloadJson() throws JsonProcessingException {
113113
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
114114
OpEthExecutionPayload opEthExecutionPayload = new OpEthExecutionPayload();
115-
opEthExecutionPayload.setResult(initExecutionPayload());
115+
opEthExecutionPayload.setResult(new OpEthExecutionPayload.ExecutionPayloadObj(initExecutionPayload()));
116116
return ow.writeValueAsString(opEthExecutionPayload);
117117
}
118118

@@ -158,7 +158,7 @@ void testGetPayload() throws IOException {
158158
assertEquals("http://127.0.0.1:8851", baseUrl);
159159
server.enqueue(new MockResponse().setBody(initExecutionPayloadJson()));
160160
EngineApi engineApi = new EngineApi(baseUrl, SECRET);
161-
OpEthExecutionPayload executionPayload = engineApi.getPayload(new BigInteger("123"));
161+
OpEthExecutionPayload executionPayload = engineApi.getPayloadV2(new BigInteger("123"));
162162
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
163163
assertEquals(initExecutionPayloadJson(), ow.writeValueAsString(executionPayload));
164164
}

0 commit comments

Comments
 (0)