From 4e114333257c24d85680082a978f20d43a344d54 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Fri, 26 Aug 2022 10:18:01 -0400 Subject: [PATCH 1/5] Payload of HashXHistoryValue should be an array of uint32 representing "txnums". --- db/prefixes/prefixes.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/db/prefixes/prefixes.go b/db/prefixes/prefixes.go index 4161f35..eee6495 100644 --- a/db/prefixes/prefixes.go +++ b/db/prefixes/prefixes.go @@ -513,7 +513,7 @@ type HashXHistoryKey struct { } type HashXHistoryValue struct { - HashXes []uint16 `struct-while:"!_eof" json:"hashxes"` + TxNums []uint32 `struct-while:"!_eof" json:"tx_nums"` } func (k *HashXHistoryKey) String() string { @@ -538,10 +538,10 @@ func (k *HashXHistoryKey) PackKey() []byte { } func (v *HashXHistoryValue) PackValue() []byte { - n := len(v.HashXes) - value := make([]byte, n*2) - for i, x := range v.HashXes { - binary.BigEndian.PutUint16(value[i*2:], x) + n := len(v.TxNums) + value := make([]byte, n*4) + for i, x := range v.TxNums { + binary.BigEndian.PutUint32(value[i*4:], x) } return value @@ -600,13 +600,13 @@ func HashXHistoryKeyUnpack(key []byte) *HashXHistoryKey { } func HashXHistoryValueUnpack(value []byte) *HashXHistoryValue { - n := len(value) / 2 - hashxes := make([]uint16, n) + n := len(value) / 4 + txnums := make([]uint32, n) for i := 0; i < n; i++ { - hashxes[i] = binary.BigEndian.Uint16(value[i*2:]) + txnums[i] = binary.BigEndian.Uint32(value[i*4:]) } return &HashXHistoryValue{ - HashXes: hashxes, + TxNums: txnums, } } -- 2.45.2 From e46ac7c913d684d59950b28d91b737f77fef4814 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Thu, 1 Sep 2022 12:58:41 -0500 Subject: [PATCH 2/5] HashXHistoryValue TxNums are unique in that they are little-endian (at least when written by Python scribe on ARM64 Mac or x86). --- db/prefixes/prefixes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/prefixes/prefixes.go b/db/prefixes/prefixes.go index eee6495..b6d4a7d 100644 --- a/db/prefixes/prefixes.go +++ b/db/prefixes/prefixes.go @@ -541,7 +541,7 @@ func (v *HashXHistoryValue) PackValue() []byte { n := len(v.TxNums) value := make([]byte, n*4) for i, x := range v.TxNums { - binary.BigEndian.PutUint32(value[i*4:], x) + binary.LittleEndian.PutUint32(value[i*4:], x) } return value @@ -603,7 +603,7 @@ func HashXHistoryValueUnpack(value []byte) *HashXHistoryValue { n := len(value) / 4 txnums := make([]uint32, n) for i := 0; i < n; i++ { - txnums[i] = binary.BigEndian.Uint32(value[i*4:]) + txnums[i] = binary.LittleEndian.Uint32(value[i*4:]) } return &HashXHistoryValue{ TxNums: txnums, -- 2.45.2 From aa16207aa5ae8696bdd923cfd6fb969b4ae15f21 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Tue, 6 Sep 2022 12:57:45 -0500 Subject: [PATCH 3/5] Fix struct annotation for HashXHistoryValue. TxNums now little-endian. --- db/prefixes/prefixes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/prefixes/prefixes.go b/db/prefixes/prefixes.go index b6d4a7d..0c9f67b 100644 --- a/db/prefixes/prefixes.go +++ b/db/prefixes/prefixes.go @@ -513,7 +513,7 @@ type HashXHistoryKey struct { } type HashXHistoryValue struct { - TxNums []uint32 `struct-while:"!_eof" json:"tx_nums"` + TxNums []uint32 `struct:"lsb" struct-while:"!_eof" json:"tx_nums"` } func (k *HashXHistoryKey) String() string { -- 2.45.2 From d025ea16160e714496eb269f385ca23a2d3b9298 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Tue, 6 Sep 2022 14:13:13 -0500 Subject: [PATCH 4/5] Add "on: pull_request" to worflow. (#59) --- .github/workflows/build-short.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-short.yml b/.github/workflows/build-short.yml index 022f8db..b11b76e 100644 --- a/.github/workflows/build-short.yml +++ b/.github/workflows/build-short.yml @@ -1,7 +1,7 @@ name: 'Build and Test Hub' -on: - push: +on: ["push", "pull_request"] + jobs: build: runs-on: ubuntu-latest -- 2.45.2 From dc9b4ada2ae03df5c7b62e7991f909575f2cf159 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Wed, 7 Sep 2022 07:13:51 -0500 Subject: [PATCH 5/5] Update go.mod, go.sum for use of constraints (x/exp). --- go.mod | 3 ++- go.sum | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index b64240a..2db271e 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( github.com/prometheus/client_golang v1.11.0 github.com/prometheus/client_model v0.2.0 github.com/sirupsen/logrus v1.8.1 + golang.org/x/exp v0.0.0-20220907003533-145caa8ea1d0 golang.org/x/text v0.3.7 google.golang.org/grpc v1.46.0 google.golang.org/protobuf v1.27.1 @@ -38,7 +39,7 @@ require ( github.com/stretchr/testify v1.7.0 // indirect golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect - golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/go.sum b/go.sum index de3ce9d..d52f4a5 100644 --- a/go.sum +++ b/go.sum @@ -638,6 +638,8 @@ golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm0 golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20200513190911-00229845015e/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/exp v0.0.0-20211123021643-48cbe7f80d7c/go.mod h1:b9TAUYHmRtqA6klRHApnXMnj+OyLce4yF5cZCUbk2ps= +golang.org/x/exp v0.0.0-20220907003533-145caa8ea1d0 h1:17k44ji3KFYG94XS5QEFC8pyuOlMh3IoR+vkmTZmJJs= +golang.org/x/exp v0.0.0-20220907003533-145caa8ea1d0/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -764,6 +766,8 @@ golang.org/x/sys v0.0.0-20210909193231-528a39cd75f3/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab h1:rfJ1bsoJQQIAoAxTxB7bme+vHrNkRw8CqfsYh9w54cw= golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -- 2.45.2