From 55a4b7f2c980ed3b9c72d0ff3f4dd72318b9a9bf Mon Sep 17 00:00:00 2001 From: PeaStew <34198053+PeaStew@users.noreply.github.com> Date: Sat, 13 Jan 2024 21:27:52 +0100 Subject: [PATCH 1/3] Update client.go to allow the use of paths with the heimdall url As reported to the polygon team 2 months ago in the Ankr polygon slack, the current code prevents the use of a path with the heimdall url, this was fixed in erigon ledgerwatch/erigon@a3a6170 in response to my request by Mark Holt, and it seems this code was just copied from bor where it is incorrect too. This patch fixes that. --- consensus/bor/heimdall/client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/consensus/bor/heimdall/client.go b/consensus/bor/heimdall/client.go index d69f5ead3c..bfabc0fab3 100644 --- a/consensus/bor/heimdall/client.go +++ b/consensus/bor/heimdall/client.go @@ -421,6 +421,7 @@ func makeURL(urlString, rawPath, rawQuery string) (*url.URL, error) { } u.Path = rawPath + u.Path = path.Join(u.Path, rawPath) u.RawQuery = rawQuery return u, err From b3a5bcd9a64ce7a9d37d3a44fdc52b84fd2c7c79 Mon Sep 17 00:00:00 2001 From: PeaStew <34198053+PeaStew@users.noreply.github.com> Date: Sun, 14 Jan 2024 13:32:47 +0100 Subject: [PATCH 2/3] Add reference to path library --- consensus/bor/heimdall/client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/consensus/bor/heimdall/client.go b/consensus/bor/heimdall/client.go index bfabc0fab3..4c99c88c7c 100644 --- a/consensus/bor/heimdall/client.go +++ b/consensus/bor/heimdall/client.go @@ -8,6 +8,7 @@ import ( "io" "net/http" "net/url" + "path" "sort" "time" From 7f9747aa7b0cb7315520774ee094bf81ff3a7a68 Mon Sep 17 00:00:00 2001 From: PeaStew <34198053+PeaStew@users.noreply.github.com> Date: Sun, 14 Jan 2024 15:45:41 +0100 Subject: [PATCH 3/3] Fix reversed order of values in unit tests and test removal of setting u.path to rawPath (otherwise why do we need rawPath at all) seems like there were work arounds done here in bioth the unit tests AND the makeURL but logic needs to be examined --- consensus/bor/heimdall/client.go | 1 - consensus/bor/heimdall/client_test.go | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/consensus/bor/heimdall/client.go b/consensus/bor/heimdall/client.go index 4c99c88c7c..5c65721574 100644 --- a/consensus/bor/heimdall/client.go +++ b/consensus/bor/heimdall/client.go @@ -421,7 +421,6 @@ func makeURL(urlString, rawPath, rawQuery string) (*url.URL, error) { return nil, err } - u.Path = rawPath u.Path = path.Join(u.Path, rawPath) u.RawQuery = rawQuery diff --git a/consensus/bor/heimdall/client_test.go b/consensus/bor/heimdall/client_test.go index 5023b847a5..737875028c 100644 --- a/consensus/bor/heimdall/client_test.go +++ b/consensus/bor/heimdall/client_test.go @@ -399,7 +399,7 @@ func TestSpanURL(t *testing.T) { const expected = "http://bor0/bor/span/1" if url.String() != expected { - t.Fatalf("expected URL %q, got %q", url.String(), expected) + t.Fatalf("expected URL %q, got %q", expected, url.String()) } } @@ -414,6 +414,6 @@ func TestStateSyncURL(t *testing.T) { const expected = "http://bor0/clerk/event-record/list?from-id=10&to-time=100&limit=50" if url.String() != expected { - t.Fatalf("expected URL %q, got %q", url.String(), expected) + t.Fatalf("expected URL %q, got %q", expected, url.String()) } }