From 5e7145dec590ab4397bb9fc9a8371fe3a6377211 Mon Sep 17 00:00:00 2001 From: zeroXbrock <2791467+zeroXbrock@users.noreply.github.com> Date: Fri, 24 May 2024 14:55:09 -0700 Subject: [PATCH 1/5] add dagstore lib with http call --- examples/app-ofa-private/ofa-private.sol | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/app-ofa-private/ofa-private.sol b/examples/app-ofa-private/ofa-private.sol index 20808b3..d8b6236 100644 --- a/examples/app-ofa-private/ofa-private.sol +++ b/examples/app-ofa-private/ofa-private.sol @@ -4,6 +4,20 @@ pragma solidity ^0.8.8; import "suave-std/suavelib/Suave.sol"; import "suave-std/Context.sol"; +library DagStore { + function get(bytes32 id) internal returns (bytes memory) { + bytes memory body = string.concat('{"jsonrpc":"2.0","method":"batches_pull","params":["', id, '"],"id":1}'); + Suave.HttpRequest memory request = Suave.HttpRequest({ + url: "http://localhost:8000", + method: "GET", + headers: [], + body: body, + withFlashbotsSignature: false + }); + return Suave.doHTTPRequest(request); + } +} + contract OFAPrivate { // Struct to hold hint-related information for an order. struct HintOrder { From 83b4d7357026e4d8161346c7365cc619f7856791 Mon Sep 17 00:00:00 2001 From: zeroXbrock <2791467+zeroXbrock@users.noreply.github.com> Date: Fri, 24 May 2024 15:00:34 -0700 Subject: [PATCH 2/5] invoke dag in newOrder to test --- examples/app-ofa-private/ofa-private.sol | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/app-ofa-private/ofa-private.sol b/examples/app-ofa-private/ofa-private.sol index d8b6236..b26fa3a 100644 --- a/examples/app-ofa-private/ofa-private.sol +++ b/examples/app-ofa-private/ofa-private.sol @@ -25,7 +25,7 @@ contract OFAPrivate { bytes hint; } - event HintEvent(Suave.DataId id, bytes hint); + event HintEvent(Suave.DataId id, bytes hint, bytes res); event BundleEmitted(string bundleRawResponse); @@ -57,14 +57,17 @@ contract OFAPrivate { return hintOrder; } - function emitHint(HintOrder memory order) public { - emit HintEvent(order.id, order.hint); + function emitHint(HintOrder memory order, bytes memory dagResult) public { + emit HintEvent(order.id, order.hint, dagResult); } // Function to create a new user order function newOrder(uint64 decryptionCondition) external returns (bytes memory) { HintOrder memory hintOrder = saveOrder(decryptionCondition); - return abi.encodeWithSelector(this.emitHint.selector, hintOrder); + + bytes memory testRes = DagStore.get(keccak256("testkey")); + + return abi.encodeWithSelector(this.emitHint.selector, hintOrder, testRes); } // Function to match and backrun another dataRecord. @@ -78,7 +81,7 @@ contract OFAPrivate { dataRecords[1] = hintOrder.id; Suave.confidentialStore(hintOrder.id, "mevshare:v0:mergedDataRecords", abi.encode(dataRecords)); - return abi.encodeWithSelector(this.emitHint.selector, hintOrder); + return abi.encodeWithSelector(this.emitHint.selector, hintOrder, bytes("undefined")); } function emitMatchDataRecordAndHintCallback(string memory bundleRawResponse) external { From 1ae933ff8d104ade60d42b60611b71713d71cf74 Mon Sep 17 00:00:00 2001 From: zeroXbrock <2791467+zeroXbrock@users.noreply.github.com> Date: Fri, 24 May 2024 15:03:57 -0700 Subject: [PATCH 3/5] fix bugs --- examples/app-ofa-private/ofa-private.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/app-ofa-private/ofa-private.sol b/examples/app-ofa-private/ofa-private.sol index b26fa3a..671abcf 100644 --- a/examples/app-ofa-private/ofa-private.sol +++ b/examples/app-ofa-private/ofa-private.sol @@ -6,11 +6,13 @@ import "suave-std/Context.sol"; library DagStore { function get(bytes32 id) internal returns (bytes memory) { - bytes memory body = string.concat('{"jsonrpc":"2.0","method":"batches_pull","params":["', id, '"],"id":1}'); + bytes memory body = abi.encodePacked( + '{"jsonrpc":"2.0","method":"batches.Pull","params":["', string(abi.encodePacked(id)), '"],"id":1}' + ); Suave.HttpRequest memory request = Suave.HttpRequest({ url: "http://localhost:8000", method: "GET", - headers: [], + headers: new string[](0), body: body, withFlashbotsSignature: false }); From eb1652c1e48d1443114ebfb5d4fb06605ac52150 Mon Sep 17 00:00:00 2001 From: zeroXbrock <2791467+zeroXbrock@users.noreply.github.com> Date: Fri, 24 May 2024 15:04:26 -0700 Subject: [PATCH 4/5] remove unnecessary casting --- examples/app-ofa-private/ofa-private.sol | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/app-ofa-private/ofa-private.sol b/examples/app-ofa-private/ofa-private.sol index 671abcf..6c6a1e1 100644 --- a/examples/app-ofa-private/ofa-private.sol +++ b/examples/app-ofa-private/ofa-private.sol @@ -6,9 +6,7 @@ import "suave-std/Context.sol"; library DagStore { function get(bytes32 id) internal returns (bytes memory) { - bytes memory body = abi.encodePacked( - '{"jsonrpc":"2.0","method":"batches.Pull","params":["', string(abi.encodePacked(id)), '"],"id":1}' - ); + bytes memory body = abi.encodePacked('{"jsonrpc":"2.0","method":"batches.Pull","params":["', id, '"],"id":1}'); Suave.HttpRequest memory request = Suave.HttpRequest({ url: "http://localhost:8000", method: "GET", From 68caa34d2cfa9a1a48a5829cf642cf1fa5bfd240 Mon Sep 17 00:00:00 2001 From: zeroXbrock <2791467+zeroXbrock@users.noreply.github.com> Date: Fri, 24 May 2024 15:08:29 -0700 Subject: [PATCH 5/5] add content-type header to dag.get --- examples/app-ofa-private/ofa-private.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/app-ofa-private/ofa-private.sol b/examples/app-ofa-private/ofa-private.sol index 6c6a1e1..96a5e2b 100644 --- a/examples/app-ofa-private/ofa-private.sol +++ b/examples/app-ofa-private/ofa-private.sol @@ -7,10 +7,12 @@ import "suave-std/Context.sol"; library DagStore { function get(bytes32 id) internal returns (bytes memory) { bytes memory body = abi.encodePacked('{"jsonrpc":"2.0","method":"batches.Pull","params":["', id, '"],"id":1}'); + string[] memory headers = new string[](1); + headers[0] = "Content-Type: application/json"; Suave.HttpRequest memory request = Suave.HttpRequest({ url: "http://localhost:8000", method: "GET", - headers: new string[](0), + headers: headers, body: body, withFlashbotsSignature: false });