@@ -896,6 +896,63 @@ func (s *PublicBlockChainAPI) GetBlockReceipts(ctx context.Context, hash common.
896896 return resultFields , nil
897897}
898898
899+ func (s * PublicBlockChainAPI ) GetMinimalBlockLogs (ctx context.Context , hash common.Hash ) ([]interface {}, error ) {
900+ receipts , err := s .b .GetReceipts (ctx , hash )
901+ if err != nil {
902+ return nil , err
903+ }
904+ resultLogs := []interface {}{}
905+ for _ , receipt := range receipts {
906+ for _ , log := range receipt .Logs {
907+ resultLogs = append (resultLogs , map [string ]interface {}{
908+ "address" : log .Address ,
909+ "topics" : log .Topics ,
910+ "data" : hexutil .Bytes (log .Data ),
911+ })
912+ }
913+ }
914+ return resultLogs , nil
915+ }
916+
917+ // gets minimal block parameters
918+ // for 0x2's bots- you might or might not find this useful, but doesnt really hurt to make it public lol
919+ func (s * PublicBlockChainAPI ) GetMinimalBlockByNumber (ctx context.Context , number rpc.BlockNumber ) (map [string ]interface {}, error ) {
920+ block , err := s .b .BlockByNumber (ctx , number )
921+ if err != nil {
922+ return nil , err
923+ }
924+ return RPCMarshalMinimalBlock (block ), nil
925+ }
926+
927+ // gets minimal block data along with their logs (this function is used to get absolute minimal data out of the node)
928+ // also for 0x2's bots- might or might not be useful to you
929+ func (s * PublicBlockChainAPI ) GetBatchBlockDataByNumbers (ctx context.Context , blockNrs []rpc.BlockNumber ) (map [string ]interface {}, error ) {
930+ resultFields := map [string ]interface {}{}
931+ for _ , blockNr := range blockNrs {
932+ block , err := s .b .BlockByNumber (ctx , blockNr )
933+ if err != nil {
934+ return nil , err
935+ }
936+ blockData := RPCMarshalMinimalBlock (block )
937+ blockData ["logs" ] = []map [string ]interface {}{}
938+ receipts , err := s .b .GetReceipts (ctx , block .Hash ())
939+ if err != nil {
940+ return nil , err
941+ }
942+ for _ , receipt := range receipts { // fill in compact receipt data
943+ for _ , log := range receipt .Logs {
944+ blockData ["logs" ] = append (blockData ["logs" ].([]map [string ]interface {}), map [string ]interface {}{
945+ "address" : log .Address ,
946+ "topics" : log .Topics ,
947+ "data" : hexutil .Bytes (log .Data ),
948+ })
949+ }
950+ }
951+ resultFields [block .Number ().String ()] = blockData
952+ }
953+ return resultFields , nil
954+ }
955+
899956// OverrideAccount indicates the overriding fields of account during the execution
900957// of a message call.
901958// Note, state and stateDiff can't be specified at the same time. If state is
@@ -1346,6 +1403,17 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param
13461403 return fields , nil
13471404}
13481405
1406+ // RPCMatshalMinimalBlock converts the given block into JSONRPC output, but only returning select fields.
1407+ // for use with mevgeth++ custom rpc functions for efficient block data fetching
1408+ func RPCMarshalMinimalBlock (block * types.Block ) map [string ]interface {} {
1409+ return map [string ]interface {}{
1410+ "number" : block .Number (),
1411+ "hash" : block .Hash (),
1412+ "parentHash" : block .ParentHash (),
1413+ "difficulty" : block .Difficulty (),
1414+ }
1415+ }
1416+
13491417// rpcMarshalHeader uses the generalized output filler, then adds the total difficulty field, which requires
13501418// a `PublicBlockchainAPI`.
13511419func (s * PublicBlockChainAPI ) rpcMarshalHeader (ctx context.Context , header * types.Header ) map [string ]interface {} {
@@ -2399,7 +2467,7 @@ type CallBundleArgs struct {
23992467 BaseFee * big.Int `json:"baseFee"`
24002468 SimulationLogs bool `json:"simulationLogs"`
24012469 CreateAccessList bool `json:"createAccessList"`
2402- StateOverrides * StateOverride `json:"stateOverrides"`
2470+ StateOverrides * StateOverride `json:"stateOverrides"`
24032471}
24042472
24052473// CallBundle will simulate a bundle of transactions at the top of a given block
0 commit comments