From 65a0eff136840b118b2e239194512fb8847dc7b6 Mon Sep 17 00:00:00 2001 From: Dat Luong Date: Tue, 24 Dec 2024 14:10:11 +0700 Subject: [PATCH 1/4] add: missing build type fix --- go.mod | 2 +- pkg/mev/bundlesendertype_enumer.go | 20 ++++++++++++++++---- pkg/mev/pkg.go | 3 +++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index d272967..bf6bd0c 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/google/uuid v1.6.0 github.com/holiman/uint256 v1.3.1 github.com/jmoiron/sqlx v1.3.5 + github.com/lib/pq v1.10.9 github.com/shopspring/decimal v1.4.0 github.com/sourcegraph/conc v0.3.0 github.com/stretchr/testify v1.9.0 @@ -66,7 +67,6 @@ require ( github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/huin/goupnp v1.3.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect - github.com/lib/pq v1.10.9 // indirect github.com/machinebox/graphql v0.2.2 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect github.com/metachris/flashbotsrpc v0.6.0 // indirect diff --git a/pkg/mev/bundlesendertype_enumer.go b/pkg/mev/bundlesendertype_enumer.go index d57db1b..f6e465a 100644 --- a/pkg/mev/bundlesendertype_enumer.go +++ b/pkg/mev/bundlesendertype_enumer.go @@ -7,11 +7,11 @@ import ( "strings" ) -const _BundleSenderTypeName = "BundleSenderTypeFlashbotBundleSenderTypeBeaverBundleSenderTypeRsyncBundleSenderTypeTitanBundleSenderTypeBloxrouteBundleSenderTypeAllBundleSenderTypeMevShareBundleSenderTypeBackrunPublicBundleSenderTypeMevBlockerBundleSenderTypeBlinkBundleSenderTypeMerkle" +const _BundleSenderTypeName = "BundleSenderTypeFlashbotBundleSenderTypeBeaverBundleSenderTypeRsyncBundleSenderTypeTitanBundleSenderTypeBloxrouteBundleSenderTypeAllBundleSenderTypeMevShareBundleSenderTypeBackrunPublicBundleSenderTypeMevBlockerBundleSenderTypeBlinkBundleSenderTypeMerkleBundleSenderTypeJetbldrBundleSenderTypePenguinBundleSenderTypeLoki" -var _BundleSenderTypeIndex = [...]uint8{0, 24, 46, 67, 88, 113, 132, 156, 185, 211, 232, 254} +var _BundleSenderTypeIndex = [...]uint16{0, 24, 46, 67, 88, 113, 132, 156, 185, 211, 232, 254, 277, 300, 320} -const _BundleSenderTypeLowerName = "bundlesendertypeflashbotbundlesendertypebeaverbundlesendertypersyncbundlesendertypetitanbundlesendertypebloxroutebundlesendertypeallbundlesendertypemevsharebundlesendertypebackrunpublicbundlesendertypemevblockerbundlesendertypeblinkbundlesendertypemerkle" +const _BundleSenderTypeLowerName = "bundlesendertypeflashbotbundlesendertypebeaverbundlesendertypersyncbundlesendertypetitanbundlesendertypebloxroutebundlesendertypeallbundlesendertypemevsharebundlesendertypebackrunpublicbundlesendertypemevblockerbundlesendertypeblinkbundlesendertypemerklebundlesendertypejetbldrbundlesendertypepenguinbundlesendertypeloki" func (i BundleSenderType) String() string { i -= 1 @@ -36,9 +36,12 @@ func _BundleSenderTypeNoOp() { _ = x[BundleSenderTypeMevBlocker-(9)] _ = x[BundleSenderTypeBlink-(10)] _ = x[BundleSenderTypeMerkle-(11)] + _ = x[BundleSenderTypeJetbldr-(12)] + _ = x[BundleSenderTypePenguin-(13)] + _ = x[BundleSenderTypeLoki-(14)] } -var _BundleSenderTypeValues = []BundleSenderType{BundleSenderTypeFlashbot, BundleSenderTypeBeaver, BundleSenderTypeRsync, BundleSenderTypeTitan, BundleSenderTypeBloxroute, BundleSenderTypeAll, BundleSenderTypeMevShare, BundleSenderTypeBackrunPublic, BundleSenderTypeMevBlocker, BundleSenderTypeBlink, BundleSenderTypeMerkle} +var _BundleSenderTypeValues = []BundleSenderType{BundleSenderTypeFlashbot, BundleSenderTypeBeaver, BundleSenderTypeRsync, BundleSenderTypeTitan, BundleSenderTypeBloxroute, BundleSenderTypeAll, BundleSenderTypeMevShare, BundleSenderTypeBackrunPublic, BundleSenderTypeMevBlocker, BundleSenderTypeBlink, BundleSenderTypeMerkle, BundleSenderTypeJetbldr, BundleSenderTypePenguin, BundleSenderTypeLoki} var _BundleSenderTypeNameToValueMap = map[string]BundleSenderType{ _BundleSenderTypeName[0:24]: BundleSenderTypeFlashbot, @@ -63,6 +66,12 @@ var _BundleSenderTypeNameToValueMap = map[string]BundleSenderType{ _BundleSenderTypeLowerName[211:232]: BundleSenderTypeBlink, _BundleSenderTypeName[232:254]: BundleSenderTypeMerkle, _BundleSenderTypeLowerName[232:254]: BundleSenderTypeMerkle, + _BundleSenderTypeName[254:277]: BundleSenderTypeJetbldr, + _BundleSenderTypeLowerName[254:277]: BundleSenderTypeJetbldr, + _BundleSenderTypeName[277:300]: BundleSenderTypePenguin, + _BundleSenderTypeLowerName[277:300]: BundleSenderTypePenguin, + _BundleSenderTypeName[300:320]: BundleSenderTypeLoki, + _BundleSenderTypeLowerName[300:320]: BundleSenderTypeLoki, } var _BundleSenderTypeNames = []string{ @@ -77,6 +86,9 @@ var _BundleSenderTypeNames = []string{ _BundleSenderTypeName[185:211], _BundleSenderTypeName[211:232], _BundleSenderTypeName[232:254], + _BundleSenderTypeName[254:277], + _BundleSenderTypeName[277:300], + _BundleSenderTypeName[300:320], } // BundleSenderTypeString retrieves an enum value from the enum constants string name. diff --git a/pkg/mev/pkg.go b/pkg/mev/pkg.go index 3938a45..1d80dc4 100644 --- a/pkg/mev/pkg.go +++ b/pkg/mev/pkg.go @@ -34,6 +34,9 @@ const ( BundleSenderTypeMevBlocker BundleSenderTypeBlink BundleSenderTypeMerkle + BundleSenderTypeJetbldr + BundleSenderTypePenguin + BundleSenderTypeLoki ) const ( From 8ce7d09898f885e7ca33dce3c4d3c9196ea97c6b Mon Sep 17 00:00:00 2001 From: Dat Luong Date: Tue, 24 Dec 2024 14:33:54 +0700 Subject: [PATCH 2/4] feat: strimp result --- pkg/mev/bundle_sender.go | 12 ++++++++ pkg/mev/bundle_sender_test.go | 3 +- pkg/mev/pkg.go | 10 +++++++ pkg/mev/pkg_test.go | 53 +++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) diff --git a/pkg/mev/bundle_sender.go b/pkg/mev/bundle_sender.go index 06b8da7..41bb266 100644 --- a/pkg/mev/bundle_sender.go +++ b/pkg/mev/bundle_sender.go @@ -233,6 +233,18 @@ func (s *Client) sendBundle( resp.Error.Code, resp.Error.Messange) } + // for some case, blink builder resp contains "" wrap around the bundle hash like + /* + 2024-12-24T03:58:38Z info operator/broadcaster.go:465 send bundle (multiple) + success {"RequestID": "ctl32rfdqqbc73cb4m80", "id": "builder-blink", + "tx": ["0xd629cbb2b4b741f6e71f8daafdbe1d484c5b53020b9cca9a407e0a7cb65f394c"], + "uuid": null, "block": 21469801, "response": + {"jsonrpc":"2.0","id":1,"result":{"bundleHash":"\"0xf72e9e8afd22af2904857e03575eb6f125cabc0d18fe7fb89ee1f8c6861687ae\""},"error":{}}, + "time": "661.127521ms", "start": "2024-12-24 03:58:37.475914455 +0000 UTC"} + + so we need to strip before save to db + */ + resp.Result.BundleHash = CleanBundleHash(resp.Result.BundleHash) return resp, nil } diff --git a/pkg/mev/bundle_sender_test.go b/pkg/mev/bundle_sender_test.go index 0a9269e..7bd8e00 100644 --- a/pkg/mev/bundle_sender_test.go +++ b/pkg/mev/bundle_sender_test.go @@ -25,7 +25,8 @@ import ( ) func TestSendBundle(t *testing.T) { - t.Skip() + //t.Skip() + // Generate a new private key privateKey, err := ecdsa.GenerateKey(crypto.S256(), rand.Reader) if err != nil { diff --git a/pkg/mev/pkg.go b/pkg/mev/pkg.go index 1d80dc4..9cdf299 100644 --- a/pkg/mev/pkg.go +++ b/pkg/mev/pkg.go @@ -312,3 +312,13 @@ func ToCallArg(msg ethereum.CallMsg) interface{} { } return arg } + +func CleanBundleHash(hash string) string { + // First remove escaped quotes if they exist + hash = strings.ReplaceAll(hash, "\\\"", "") + + // Then remove any remaining regular quotes + hash = strings.Trim(hash, "\"") + + return hash +} diff --git a/pkg/mev/pkg_test.go b/pkg/mev/pkg_test.go index 96492d1..51fc84e 100644 --- a/pkg/mev/pkg_test.go +++ b/pkg/mev/pkg_test.go @@ -22,3 +22,56 @@ func TestUnmarshalSendBundleResponse1(t *testing.T) { t.Logf("%+v\n", resp) } } + +func TestCleanBundleHash(t *testing.T) { + tests := []struct { + name string + input string + expected string + }{ + { + name: "hash with escaped quotes", + input: "\"0xf72e9e8afd22af2904857e03575eb6f125cabc0d18fe7fb89ee1f8c6861687ae\"", + expected: "0xf72e9e8afd22af2904857e03575eb6f125cabc0d18fe7fb89ee1f8c6861687ae", + }, + { + name: "hash with regular quotes", + input: "\"0xabc123\"", + expected: "0xabc123", + }, + { + name: "hash without quotes", + input: "0xdef456", + expected: "0xdef456", + }, + { + name: "empty string", + input: "", + expected: "", + }, + { + name: "only quotes", + input: "\"\"", + expected: "", + }, + { + name: "multiple escaped quotes", + input: "\"\\\"0xabc123\\\"\"", + expected: "0xabc123", + }, + { + name: "mixed quotes", + input: "\\\"0xabc123\"", + expected: "0xabc123", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := mev.CleanBundleHash(tt.input) + if got != tt.expected { + t.Errorf("cleanBundleHash() = %v, want %v", got, tt.expected) + } + }) + } +} From 8387ae1078b516eedb199d2c38c0b9d262aaa3f0 Mon Sep 17 00:00:00 2001 From: Dat Luong Date: Tue, 24 Dec 2024 14:39:29 +0700 Subject: [PATCH 3/4] lint fix --- pkg/mev/bundle_sender.go | 4 +++- pkg/mev/bundle_sender_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/mev/bundle_sender.go b/pkg/mev/bundle_sender.go index 41bb266..c16d3b3 100644 --- a/pkg/mev/bundle_sender.go +++ b/pkg/mev/bundle_sender.go @@ -239,7 +239,9 @@ func (s *Client) sendBundle( success {"RequestID": "ctl32rfdqqbc73cb4m80", "id": "builder-blink", "tx": ["0xd629cbb2b4b741f6e71f8daafdbe1d484c5b53020b9cca9a407e0a7cb65f394c"], "uuid": null, "block": 21469801, "response": - {"jsonrpc":"2.0","id":1,"result":{"bundleHash":"\"0xf72e9e8afd22af2904857e03575eb6f125cabc0d18fe7fb89ee1f8c6861687ae\""},"error":{}}, + {"jsonrpc":"2.0","id":1, + "result":{"bundleHash":"\"0xf72e9e8afd22af2904857e03575eb6f125cabc0d18fe7fb89ee1f8c6861687ae\""}, + "error":{}}, "time": "661.127521ms", "start": "2024-12-24 03:58:37.475914455 +0000 UTC"} so we need to strip before save to db diff --git a/pkg/mev/bundle_sender_test.go b/pkg/mev/bundle_sender_test.go index 7bd8e00..6ba58e2 100644 --- a/pkg/mev/bundle_sender_test.go +++ b/pkg/mev/bundle_sender_test.go @@ -25,7 +25,7 @@ import ( ) func TestSendBundle(t *testing.T) { - //t.Skip() + t.Skip() // Generate a new private key privateKey, err := ecdsa.GenerateKey(crypto.S256(), rand.Reader) From f2b355d42052b1d1954b78b2b466b942e0f20882 Mon Sep 17 00:00:00 2001 From: Dat Luong Date: Tue, 24 Dec 2024 14:52:23 +0700 Subject: [PATCH 4/4] add builder for set uuid --- pkg/mev/bundle_sender.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/mev/bundle_sender.go b/pkg/mev/bundle_sender.go index c16d3b3..e97d9be 100644 --- a/pkg/mev/bundle_sender.go +++ b/pkg/mev/bundle_sender.go @@ -409,7 +409,9 @@ func (p *SendBundleParams) SetBlockNumber(block uint64) *SendBundleParams { } func (p *SendBundleParams) SetUUID(uuid string, senderType BundleSenderType) *SendBundleParams { - if senderType == BundleSenderTypeBeaver { + if senderType == BundleSenderTypeBeaver || + senderType == BundleSenderTypeLoki || + senderType == BundleSenderTypeJetbldr { p.UUID = uuid return p }