Skip to content

Commit 272a986

Browse files
committed
fix formatting
1 parent 86e6809 commit 272a986

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

cmd/utils/flags.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -879,19 +879,19 @@ var (
879879
}
880880
DASnapshotFileFlag = cli.StringFlag{
881881
Name: "da.snapshot.file",
882-
Usage: "Snapshot file to sync from da",
882+
Usage: "Snapshot file to sync from DA",
883883
}
884884
DABlobScanAPIEndpointFlag = cli.StringFlag{
885885
Name: "da.blob.blobscan",
886-
Usage: "BlobScan blob api endpoint",
886+
Usage: "BlobScan blob API endpoint",
887887
}
888888
DABlockNativeAPIEndpointFlag = cli.StringFlag{
889889
Name: "da.blob.blocknative",
890-
Usage: "BlockNative blob api endpoint",
890+
Usage: "BlockNative blob API endpoint",
891891
}
892892
DABeaconNodeAPIEndpointFlag = cli.StringFlag{
893893
Name: "da.blob.beaconnode",
894-
Usage: "BlobScan blob api endpoint",
894+
Usage: "Beacon node API endpoint",
895895
}
896896
)
897897

rollup/da_syncer/blob_client/beacon_node_client.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package blob_client
33
import (
44
"context"
55
"crypto/sha256"
6-
"encoding/hex"
76
"encoding/json"
87
"fmt"
98
"io"
@@ -37,11 +36,13 @@ func NewBeaconNodeClient(apiEndpoint string, l1Client *rollup_sync_service.L1Cli
3736
return nil, fmt.Errorf("cannot do request, err: %w", err)
3837
}
3938
defer resp.Body.Close()
39+
4040
if resp.StatusCode != http.StatusOK {
4141
body, _ := io.ReadAll(resp.Body)
4242
bodyStr := string(body)
4343
return nil, fmt.Errorf("beacon node request failed, status: %s, body: %s", resp.Status, bodyStr)
4444
}
45+
4546
var genesisResp GenesisResp
4647
err = json.NewDecoder(resp.Body).Decode(&genesisResp)
4748
if err != nil {
@@ -59,11 +60,13 @@ func NewBeaconNodeClient(apiEndpoint string, l1Client *rollup_sync_service.L1Cli
5960
return nil, fmt.Errorf("cannot do request, err: %w", err)
6061
}
6162
defer resp.Body.Close()
63+
6264
if resp.StatusCode != http.StatusOK {
6365
body, _ := io.ReadAll(resp.Body)
6466
bodyStr := string(body)
6567
return nil, fmt.Errorf("beacon node request failed, status: %s, body: %s", resp.Status, bodyStr)
6668
}
69+
6770
var specResp SpecResp
6871
err = json.NewDecoder(resp.Body).Decode(&specResp)
6972
if err != nil {
@@ -100,11 +103,13 @@ func (c *BeaconNodeClient) GetBlobByVersionedHashAndBlockNumber(ctx context.Cont
100103
return nil, fmt.Errorf("cannot do request, err: %w", err)
101104
}
102105
defer resp.Body.Close()
106+
103107
if resp.StatusCode != http.StatusOK {
104108
body, _ := io.ReadAll(resp.Body)
105109
bodyStr := string(body)
106110
return nil, fmt.Errorf("beacon node request failed, status: %s, body: %s", resp.Status, bodyStr)
107111
}
112+
108113
var blobSidecarResp BlobSidecarResp
109114
err = json.NewDecoder(resp.Body).Decode(&blobSidecarResp)
110115
if err != nil {
@@ -114,26 +119,22 @@ func (c *BeaconNodeClient) GetBlobByVersionedHashAndBlockNumber(ctx context.Cont
114119
// find blob with desired versionedHash
115120
for _, blob := range blobSidecarResp.Data {
116121
// calculate blob hash from commitment and check it with desired
117-
commitmentBytes, err := hex.DecodeString(blob.KzgCommitment[2:])
118-
if err != nil {
119-
return nil, fmt.Errorf("failed to decode data to bytes, err: %w", err)
120-
}
121-
if len(commitmentBytes) != lenKzgCommitment {
122-
return nil, fmt.Errorf("len of kzg commitment is not correct, expected: %d, got: %d", lenKzgCommitment, len(commitmentBytes))
122+
commitmentBytes := common.FromHex(blob.KzgCommitment)
123+
if len(commitmentBytes) != lenKZGCommitment {
124+
return nil, fmt.Errorf("len of kzg commitment is not correct, expected: %d, got: %d", lenKZGCommitment, len(commitmentBytes))
123125
}
124126
commitment := kzg4844.Commitment(commitmentBytes)
125127
blobVersionedHash := kzg4844.CalcBlobHashV1(sha256.New(), &commitment)
128+
126129
if blobVersionedHash == versionedHash {
127130
// found desired blob
128-
blobBytes, err := hex.DecodeString(blob.Blob[2:])
129-
if err != nil {
130-
return nil, fmt.Errorf("failed to decode data to bytes, err: %w", err)
131-
}
131+
blobBytes := common.FromHex(blob.Blob)
132132
if len(blobBytes) != lenBlobBytes {
133133
return nil, fmt.Errorf("len of blob data is not correct, expected: %d, got: %d", lenBlobBytes, len(blobBytes))
134134
}
135-
blob := kzg4844.Blob(blobBytes)
136-
return &blob, nil
135+
136+
b := kzg4844.Blob(blobBytes)
137+
return &b, nil
137138
}
138139
}
139140

rollup/da_syncer/blob_client/blob_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
const (
1111
lenBlobBytes int = 131072
12-
lenKzgCommitment int = 48
12+
lenKZGCommitment int = 48
1313
)
1414

1515
type BlobClient interface {

0 commit comments

Comments
 (0)