Skip to content

Commit

Permalink
not working demo
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarzzz committed Dec 16, 2023
1 parent 6de1fdf commit 2bccb8f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
20 changes: 18 additions & 2 deletions core/vm/contracts_suave_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,23 +388,39 @@ func (c *suaveRuntime) submitBundleJsonRPC(url string, method string, params []b
req.Header.Add("Accept", "application/json")
req.Header.Add("X-Flashbots-Signature", signature)

start := time.Now()
// Execute request
resp, err := http.DefaultClient.Do(req)
if err != nil {
return formatPeekerError("could not send request to relay: %w", err)
}
defer resp.Body.Close()

var bodyBytes []byte
if resp.StatusCode > 299 {
bodyBytes, err := io.ReadAll(resp.Body)
bodyBytes, err = io.ReadAll(resp.Body)
if err != nil {
return formatPeekerError("request failed with code %d", resp.StatusCode)
}

return formatPeekerError("request failed with code %d: %s", resp.StatusCode, string(bodyBytes))
}

return nil, nil
elapsed := time.Since(start)

results := struct {
StatusCode int `json:"statusCode"`
Destination string `json:"destination"`
RoundTripTime time.Duration `json:"roundTripTime"`
Response string `json:"reponse"`
}{
StatusCode: resp.StatusCode,
Destination: url,
RoundTripTime: elapsed,
Response: string(bodyBytes),
}

return json.Marshal(results)
}

func (c *suaveRuntime) fillMevShareBundle(bidId types.BidId) ([]byte, error) {
Expand Down
17 changes: 14 additions & 3 deletions suave/sol/standard_peekers/bids.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,33 @@ contract BundleBidContract is AnyBidContract {

contract EthBundleSenderContract is BundleBidContract {
string[] public builderUrls;
bytes[] public submissionResults;

event SubmissionEvent(bytes[] submissionResults);


constructor(string[] memory builderUrls_) {
builderUrls = builderUrls_;
}

function emitAndReturnWithResults(Suave.Bid memory bid, bytes[] memory submissionResults) internal virtual returns (bytes memory) {
emit BidEvent(bid.id, bid.decryptionCondition, bid.allowedPeekers);
emit SubmissionEvent(submissionResults);
}

function emitAndReturn(Suave.Bid memory bid, bytes memory bundleData)
internal
virtual
override
returns (bytes memory)
{
bytes memory submissionDetails;

for (uint256 i = 0; i < builderUrls.length; i++) {
Suave.submitBundleJsonRPC(builderUrls[i], "eth_sendBundle", bundleData);
submissionDetails = Suave.submitBundleJsonRPC(builderUrls[i], "eth_sendBundle", bundleData);
submissionResults.push(submissionDetails);
}

return BundleBidContract.emitAndReturn(bid, bundleData);
return bytes.concat(this.emitAndReturnWithResults.selector, abi.encode(bid, submissionResults));
}
}

Expand Down

0 comments on commit 2bccb8f

Please sign in to comment.