From fc4808c51354485f31045f11840796b06a9bd7b8 Mon Sep 17 00:00:00 2001 From: Ethen Pociask Date: Wed, 14 Aug 2024 21:02:27 -0400 Subject: [PATCH] fix: Compute EigenDA preimage hash using preimage length - go fmt --- cmd/replay/main.go | 2 +- eigenda/eigenda.go | 2 +- eigenda/reader.go | 8 +++----- eigenda/serialize.go | 1 - eigenda/serialize_test.go | 3 +-- eigenda/types.go | 2 +- 6 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cmd/replay/main.go b/cmd/replay/main.go index c9c9325f1..5e2abce1e 100644 --- a/cmd/replay/main.go +++ b/cmd/replay/main.go @@ -158,7 +158,7 @@ func (dasReader *EigenDAPreimageReader) QueryBlob(ctx context.Context, cert *eig if err != nil { return nil, err } - + preimage, err := wavmio.ResolveTypedPreimage(arbutil.EigenDaPreimageType, *hash) if err != nil { return nil, err diff --git a/eigenda/eigenda.go b/eigenda/eigenda.go index 758be23a3..4218617c9 100644 --- a/eigenda/eigenda.go +++ b/eigenda/eigenda.go @@ -25,7 +25,7 @@ func init() { const ( sequencerMsgOffset = 41 - MaxBatchSize = 2_000_000 // 2MB + MaxBatchSize = 2_000_000 // 2MB ) func IsEigenDAMessageHeaderByte(header byte) bool { diff --git a/eigenda/reader.go b/eigenda/reader.go index e0950e1ac..826e9f8fc 100644 --- a/eigenda/reader.go +++ b/eigenda/reader.go @@ -19,7 +19,6 @@ type readerForEigenDA struct { readerEigenDA EigenDAReader } - func (d *readerForEigenDA) IsValidHeaderByte(headerByte byte) bool { return IsEigenDAMessageHeaderByte(headerByte) } @@ -59,7 +58,6 @@ func RecoverPayloadFromEigenDABatch(ctx context.Context, return nil, err } - if preimageRecoder != nil { // iFFT the preimage data preimage, err := GenericEncodeBlob(data) @@ -104,7 +102,7 @@ func ParseSequencerMsg(calldata []byte) (*EigenDABlobInfo, error) { } func uint32ToBytes(n uint32) []byte { - bytes := make([]byte, 4) - binary.BigEndian.PutUint32(bytes, n) - return bytes + bytes := make([]byte, 4) + binary.BigEndian.PutUint32(bytes, n) + return bytes } diff --git a/eigenda/serialize.go b/eigenda/serialize.go index a9ef45988..2b110079f 100644 --- a/eigenda/serialize.go +++ b/eigenda/serialize.go @@ -16,7 +16,6 @@ import ( - https://github.com/Layr-Labs/eigenda/blob/44569ec461c9a1dd1191e7999a72e63bd1e7aba9/api/clients/codecs/ifft_codec.go#L27-L38 */ - func GenericDecodeBlob(data []byte) ([]byte, error) { if len(data) <= 32 { return nil, fmt.Errorf("data is not of length greater than 32 bytes: %d", len(data)) diff --git a/eigenda/serialize_test.go b/eigenda/serialize_test.go index d6464b15d..e54508062 100644 --- a/eigenda/serialize_test.go +++ b/eigenda/serialize_test.go @@ -2,7 +2,6 @@ package eigenda import "testing" - func Test_EncodeDecodeBlob(t *testing.T) { rawBlob := []byte("optimistic nihilism") @@ -19,4 +18,4 @@ func Test_EncodeDecodeBlob(t *testing.T) { if string(decodedBlob) != string(rawBlob) { t.Fatalf("decoded blob does not match raw blob") } -} \ No newline at end of file +} diff --git a/eigenda/types.go b/eigenda/types.go index f0ea0b782..d39f8939c 100644 --- a/eigenda/types.go +++ b/eigenda/types.go @@ -24,7 +24,7 @@ type EigenDABlobInfo struct { } /* - Unlike 4844 there's no need to inject a version byte into the 0th offset of the hash +Unlike 4844 there's no need to inject a version byte into the 0th offset of the hash */ func (e *EigenDABlobInfo) PreimageHash() (*common.Hash, error) { kzgCommit, err := e.SerializeCommitment()