Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Commit 8814607

Browse files
adds flashbots_getBundleStatsV2 (metachris#20)
* adds flashbots_getBundleStatsV2 * adds flashbots_getBundleStatsV2 test update
1 parent 702086e commit 8814607

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

flashbotsrpc.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,15 @@ func (rpc *FlashbotsRPC) FlashbotsGetBundleStats(privKey *ecdsa.PrivateKey, para
646646
return res, err
647647
}
648648

649+
func (rpc *FlashbotsRPC) FlashbotsGetBundleStatsV2(privKey *ecdsa.PrivateKey, param FlashbotsGetBundleStatsParam) (res FlashbotsGetBundleStatsResponseV2, err error) {
650+
rawMsg, err := rpc.CallWithFlashbotsSignature("flashbots_getBundleStatsV2", privKey, param)
651+
if err != nil {
652+
return res, err
653+
}
654+
err = json.Unmarshal(rawMsg, &res)
655+
return res, err
656+
}
657+
649658
// Simulate a full Ethereum block. numTx is the maximum number of tx to include, used for troubleshooting (default: 0 - all transactions)
650659
func (rpc *FlashbotsRPC) FlashbotsSimulateBlock(privKey *ecdsa.PrivateKey, block *types.Block, maxTx int) (res FlashbotsCallBundleResponse, err error) {
651660
if rpc.Debug {

flashbotsrpc_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package flashbotsrpc
44

55
import (
66
"crypto/ecdsa"
7+
"encoding/json"
78
"errors"
89
"fmt"
910
"io"
@@ -1227,6 +1228,55 @@ func (s *FlashbotsRPCTestSuite) TestFlashbotsGetBundleStats() {
12271228
s.Require().Equal(expected, bundleStats)
12281229
}
12291230

1231+
func (s *FlashbotsRPCTestSuite) TestFlashbotsGetBundleStatsV2() {
1232+
params := FlashbotsGetBundleStatsParam{
1233+
BlockNumber: "0x10C063C",
1234+
BundleHash: "0x9f93055488f7b9db678c14c1c5056c3ea01ef91e35c4f5e4cbeb6d8eb434f32d",
1235+
}
1236+
1237+
s.registerResponseError(errors.New("Error"))
1238+
_, err := s.rpc.FlashbotsGetBundleStatsV2(s.privKey, params)
1239+
s.Require().NotNil(err)
1240+
1241+
response := `{
1242+
"isSimulated": true,
1243+
"isSentToMiners": true,
1244+
"isHighPriority": true,
1245+
"simulatedAt": "2022-10-06T21:36:06.317Z",
1246+
"submittedAt": "2022-10-06T21:36:06.250Z",
1247+
"sentToMinersAt": "2022-10-06T21:36:06.343Z",
1248+
"consideredByBuildersAt": [
1249+
{
1250+
"pubkey": "0x81babeec8c9f2bb9c329fd8a3b176032fe0ab5f3b92a3f44d4575a231c7bd9c31d10b6328ef68ed1e8c02a3dbc8e80f9",
1251+
"timestamp": "2022-10-06T21:36:06.343Z"
1252+
},
1253+
{
1254+
"pubkey": "0x81beef03aafd3dd33ffd7deb337407142c80fea2690e5b3190cfc01bde5753f28982a7857c96172a75a234cb7bcb994f",
1255+
"timestamp": "2022-10-06T21:36:06.394Z"
1256+
}
1257+
],
1258+
"sealedByBuildersAt": [
1259+
{
1260+
"pubkey": "0x81beef03aafd3dd33ffd7deb337407142c80fea2690e5b3190cfc01bde5753f28982a7857c96172a75a234cb7bcb994f",
1261+
"timestamp": "2022-10-06T21:36:07.742Z"
1262+
}
1263+
]
1264+
}`
1265+
1266+
s.registerResponse(response, func(body []byte) {
1267+
s.methodEqual(body, "flashbots_getBundleStatsV2")
1268+
s.paramsEqual(body, `[{"blockNumber": "0x10C063C", "bundleHash": "0x9f93055488f7b9db678c14c1c5056c3ea01ef91e35c4f5e4cbeb6d8eb434f32d"}]`)
1269+
})
1270+
1271+
bundleStats, err := s.rpc.FlashbotsGetBundleStatsV2(s.privKey, params)
1272+
s.Require().Nil(err)
1273+
1274+
bundleStatsExpected := FlashbotsGetBundleStatsResponseV2{}
1275+
err = json.Unmarshal([]byte(response), &bundleStatsExpected)
1276+
s.Require().Nil(err)
1277+
s.Require().Equal(bundleStatsExpected, bundleStats)
1278+
}
1279+
12301280
func TestFlashbotsRPCTestSuite(t *testing.T) {
12311281
suite.Run(t, new(FlashbotsRPCTestSuite))
12321282
}

types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,16 @@ type FlashbotsGetBundleStatsResponse struct {
401401
ConsideredByBuildersAt []*BuilderPubkeyWithTimestamp `json:"consideredByBuildersAt"`
402402
SealedByBuildersAt []*BuilderPubkeyWithTimestamp `json:"sealedByBuildersAt"`
403403
}
404+
405+
type FlashbotsGetBundleStatsResponseV2 struct {
406+
IsSimulated bool `json:"isSimulated"`
407+
IsHighPriority bool `json:"isHighPriority"`
408+
SimulatedAt time.Time `json:"simulatedAt"`
409+
ReceivedAt time.Time `json:"receivedAt"`
410+
ConsideredByBuildersAt []*BuilderPubkeyWithTimestamp `json:"consideredByBuildersAt"`
411+
SealedByBuildersAt []*BuilderPubkeyWithTimestamp `json:"sealedByBuildersAt"`
412+
}
413+
404414
type BuilderPubkeyWithTimestamp struct {
405415
Pubkey string `json:"pubkey"`
406416
Timestamp time.Time `json:"timestamp"`

0 commit comments

Comments
 (0)