Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: missing build type fix #109

Merged
merged 4 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions pkg/mev/bundle_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,20 @@ 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
}

Expand Down
1 change: 1 addition & 0 deletions pkg/mev/bundle_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

func TestSendBundle(t *testing.T) {
t.Skip()

// Generate a new private key
privateKey, err := ecdsa.GenerateKey(crypto.S256(), rand.Reader)
if err != nil {
Expand Down
20 changes: 16 additions & 4 deletions pkg/mev/bundlesendertype_enumer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions pkg/mev/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const (
BundleSenderTypeMevBlocker
BundleSenderTypeBlink
BundleSenderTypeMerkle
BundleSenderTypeJetbldr
BundleSenderTypePenguin
BundleSenderTypeLoki
)

const (
Expand Down Expand Up @@ -309,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
}
53 changes: 53 additions & 0 deletions pkg/mev/pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
}