From f9b2dfbf648b55373c601bab7303a6efb5735316 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Sat, 21 Oct 2023 09:53:32 +0100 Subject: [PATCH] Linting. --- api/v1/attesterduty.go | 6 +++--- api/v1/beaconcommitteesubscription.go | 2 +- api/v1/chainreorgevent.go | 2 +- api/v1/depositcontract.go | 2 +- api/v1/forkchoice.go | 2 +- api/v1/genesis.go | 2 +- api/v1/payloadattributesevent.go | 8 ++++---- api/v1/validatorregistration.go | 4 ++-- auto/parameters.go | 2 +- http/events.go | 1 + http/fork_test.go | 4 ++-- http/parameters.go | 2 +- http/validators_test.go | 4 ++-- mock/parameters.go | 2 +- multi/parameters.go | 2 +- spec/altair/beaconstate.go | 6 +++--- spec/altair/synccommitteecontribution.go | 2 +- spec/bellatrix/beaconstate.go | 6 +++--- spec/bellatrix/executionaddress.go | 2 +- spec/bellatrix/executionpayload.go | 8 ++++---- spec/bellatrix/executionpayloadheader.go | 8 ++++---- spec/capella/beaconstate_json.go | 6 +++--- spec/capella/executionpayload.go | 8 ++++---- spec/capella/executionpayloadheader.go | 8 ++++---- spec/deneb/beaconstate_json.go | 6 +++--- spec/deneb/executionpayload_json.go | 12 ++++++------ spec/deneb/executionpayloadheader_json.go | 12 ++++++------ spec/phase0/beaconstate.go | 4 ++-- spec/phase0/eth1data.go | 2 +- spec/phase0/indexedattestation.go | 2 +- 30 files changed, 69 insertions(+), 68 deletions(-) diff --git a/api/v1/attesterduty.go b/api/v1/attesterduty.go index c70e3905..6dae5e10 100644 --- a/api/v1/attesterduty.go +++ b/api/v1/attesterduty.go @@ -60,9 +60,9 @@ func (a *AttesterDuty) MarshalJSON() ([]byte, error) { Slot: fmt.Sprintf("%d", a.Slot), ValidatorIndex: fmt.Sprintf("%d", a.ValidatorIndex), CommitteeIndex: fmt.Sprintf("%d", a.CommitteeIndex), - CommitteeLength: fmt.Sprintf("%d", a.CommitteeLength), - CommitteesAtSlot: fmt.Sprintf("%d", a.CommitteesAtSlot), - ValidatorCommitteeIndex: fmt.Sprintf("%d", a.ValidatorCommitteeIndex), + CommitteeLength: strconv.FormatUint(a.CommitteeLength, 10), + CommitteesAtSlot: strconv.FormatUint(a.CommitteesAtSlot, 10), + ValidatorCommitteeIndex: strconv.FormatUint(a.ValidatorCommitteeIndex, 10), }) } diff --git a/api/v1/beaconcommitteesubscription.go b/api/v1/beaconcommitteesubscription.go index 78cbba48..e45d0081 100644 --- a/api/v1/beaconcommitteesubscription.go +++ b/api/v1/beaconcommitteesubscription.go @@ -51,7 +51,7 @@ func (b *BeaconCommitteeSubscription) MarshalJSON() ([]byte, error) { ValidatorIndex: fmt.Sprintf("%d", b.ValidatorIndex), Slot: fmt.Sprintf("%d", b.Slot), CommitteeIndex: fmt.Sprintf("%d", b.CommitteeIndex), - CommitteesAtSlot: fmt.Sprintf("%d", b.CommitteesAtSlot), + CommitteesAtSlot: strconv.FormatUint(b.CommitteesAtSlot, 10), IsAggregator: b.IsAggregator, }) } diff --git a/api/v1/chainreorgevent.go b/api/v1/chainreorgevent.go index dd5a8fd2..b96100f2 100644 --- a/api/v1/chainreorgevent.go +++ b/api/v1/chainreorgevent.go @@ -50,7 +50,7 @@ type chainReorgEventJSON struct { func (e *ChainReorgEvent) MarshalJSON() ([]byte, error) { return json.Marshal(&chainReorgEventJSON{ Slot: fmt.Sprintf("%d", e.Slot), - Depth: fmt.Sprintf("%d", e.Depth), + Depth: strconv.FormatUint(e.Depth, 10), OldHeadBlock: fmt.Sprintf("%#x", e.OldHeadBlock), NewHeadBlock: fmt.Sprintf("%#x", e.NewHeadBlock), OldHeadState: fmt.Sprintf("%#x", e.OldHeadState), diff --git a/api/v1/depositcontract.go b/api/v1/depositcontract.go index 9333cdfc..e9795f63 100644 --- a/api/v1/depositcontract.go +++ b/api/v1/depositcontract.go @@ -38,7 +38,7 @@ type depositContractJSON struct { // MarshalJSON implements json.Marshaler. func (d *DepositContract) MarshalJSON() ([]byte, error) { return json.Marshal(&depositContractJSON{ - ChainID: fmt.Sprintf("%d", d.ChainID), + ChainID: strconv.FormatUint(d.ChainID, 10), Address: fmt.Sprintf("%#x", d.Address), }) } diff --git a/api/v1/forkchoice.go b/api/v1/forkchoice.go index bc23e073..6e05c7bf 100644 --- a/api/v1/forkchoice.go +++ b/api/v1/forkchoice.go @@ -192,7 +192,7 @@ func (f *ForkChoiceNode) MarshalJSON() ([]byte, error) { ParentRoot: fmt.Sprintf("%#x", f.ParentRoot), JustifiedEpoch: fmt.Sprintf("%d", f.JustifiedEpoch), FinalizedEpoch: fmt.Sprintf("%d", f.FinalizedEpoch), - Weight: fmt.Sprintf("%d", f.Weight), + Weight: strconv.FormatUint(f.Weight, 10), Validity: f.Validity.String(), ExecutionBlockHash: fmt.Sprintf("%#x", f.ExecutionBlockHash), ExtraData: f.ExtraData, diff --git a/api/v1/genesis.go b/api/v1/genesis.go index e2345845..0d3e66a5 100644 --- a/api/v1/genesis.go +++ b/api/v1/genesis.go @@ -42,7 +42,7 @@ type genesisJSON struct { // MarshalJSON implements json.Marshaler. func (g *Genesis) MarshalJSON() ([]byte, error) { return json.Marshal(&genesisJSON{ - GenesisTime: fmt.Sprintf("%d", g.GenesisTime.Unix()), + GenesisTime: strconv.FormatInt(g.GenesisTime.Unix(), 10), GenesisValidatorsRoot: fmt.Sprintf("%#x", g.GenesisValidatorsRoot), GenesisForkVersion: fmt.Sprintf("%#x", g.GenesisForkVersion), }) diff --git a/api/v1/payloadattributesevent.go b/api/v1/payloadattributesevent.go index 2ef57d6e..1991e60a 100644 --- a/api/v1/payloadattributesevent.go +++ b/api/v1/payloadattributesevent.go @@ -295,7 +295,7 @@ func (e *PayloadAttributesEvent) MarshalJSON() ([]byte, error) { return nil, errors.New("no payload attributes v1 data") } payloadAttributes, err = json.Marshal(&payloadAttributesV1JSON{ - Timestamp: fmt.Sprintf("%d", e.Data.V1.Timestamp), + Timestamp: strconv.FormatUint(e.Data.V1.Timestamp, 10), PrevRandao: fmt.Sprintf("%#x", e.Data.V1.PrevRandao), SuggestedFeeRecipient: e.Data.V1.SuggestedFeeRecipient.String(), }) @@ -307,7 +307,7 @@ func (e *PayloadAttributesEvent) MarshalJSON() ([]byte, error) { return nil, errors.New("no payload attributes v2 data") } payloadAttributes, err = json.Marshal(&payloadAttributesV2JSON{ - Timestamp: fmt.Sprintf("%d", e.Data.V2.Timestamp), + Timestamp: strconv.FormatUint(e.Data.V2.Timestamp, 10), PrevRandao: fmt.Sprintf("%#x", e.Data.V2.PrevRandao), SuggestedFeeRecipient: e.Data.V2.SuggestedFeeRecipient.String(), Withdrawals: e.Data.V2.Withdrawals, @@ -320,7 +320,7 @@ func (e *PayloadAttributesEvent) MarshalJSON() ([]byte, error) { return nil, errors.New("no payload attributes v3 data") } payloadAttributes, err = json.Marshal(&payloadAttributesV3JSON{ - Timestamp: fmt.Sprintf("%d", e.Data.V3.Timestamp), + Timestamp: strconv.FormatUint(e.Data.V3.Timestamp, 10), PrevRandao: fmt.Sprintf("%#x", e.Data.V3.PrevRandao), SuggestedFeeRecipient: e.Data.V3.SuggestedFeeRecipient.String(), Withdrawals: e.Data.V3.Withdrawals, @@ -336,7 +336,7 @@ func (e *PayloadAttributesEvent) MarshalJSON() ([]byte, error) { data := payloadAttributesDataJSON{ ProposerIndex: fmt.Sprintf("%d", e.Data.ProposerIndex), ProposalSlot: fmt.Sprintf("%d", e.Data.ProposalSlot), - ParentBlockNumber: fmt.Sprintf("%d", e.Data.ParentBlockNumber), + ParentBlockNumber: strconv.FormatUint(e.Data.ParentBlockNumber, 10), ParentBlockRoot: fmt.Sprintf("%#x", e.Data.ParentBlockRoot), ParentBlockHash: fmt.Sprintf("%#x", e.Data.ParentBlockHash), PayloadAttributes: payloadAttributes, diff --git a/api/v1/validatorregistration.go b/api/v1/validatorregistration.go index df161fd3..05ec0d22 100644 --- a/api/v1/validatorregistration.go +++ b/api/v1/validatorregistration.go @@ -56,8 +56,8 @@ type validatorRegistrationYAML struct { func (v *ValidatorRegistration) MarshalJSON() ([]byte, error) { return json.Marshal(&validatorRegistrationJSON{ FeeRecipient: v.FeeRecipient.String(), - GasLimit: fmt.Sprintf("%d", v.GasLimit), - Timestamp: fmt.Sprintf("%d", v.Timestamp.Unix()), + GasLimit: strconv.FormatUint(v.GasLimit, 10), + Timestamp: strconv.FormatInt(v.Timestamp.Unix(), 10), Pubkey: fmt.Sprintf("%#x", v.Pubkey), }) } diff --git a/auto/parameters.go b/auto/parameters.go index d4e09d5e..16455bea 100644 --- a/auto/parameters.go +++ b/auto/parameters.go @@ -28,7 +28,7 @@ type parameters struct { // Parameter is the interface for service parameters. type Parameter interface { - apply(*parameters) + apply(p *parameters) } type parameterFunc func(*parameters) diff --git a/http/events.go b/http/events.go index 6d2f0780..3b8b75b1 100644 --- a/http/events.go +++ b/http/events.go @@ -183,6 +183,7 @@ func (s *Service) handleEvent(ctx context.Context, msg *sse.Event, handler clien err := json.Unmarshal(msg.Data, blobSidecar) if err != nil { log.Error().Err(err).RawJSON("data", msg.Data).Msg("Failed to parse blob sidecar event") + return } event.Data = blobSidecar diff --git a/http/fork_test.go b/http/fork_test.go index ef59d5cf..0bce288d 100644 --- a/http/fork_test.go +++ b/http/fork_test.go @@ -15,8 +15,8 @@ package http_test import ( "context" - "fmt" "os" + "strconv" "testing" client "github.com/attestantio/go-eth2-client" @@ -67,7 +67,7 @@ func TestFork(t *testing.T) { t.Run(test.name, func(t *testing.T) { response, err := service.(client.ForkProvider).Fork(ctx, test.opts) if test.expectedErrorCode != 0 { - require.Contains(t, err.Error(), fmt.Sprintf("%d", test.expectedErrorCode)) + require.Contains(t, err.Error(), strconv.Itoa(test.expectedErrorCode)) } else { require.NoError(t, err) require.NotNil(t, response) diff --git a/http/parameters.go b/http/parameters.go index 734141b0..f01e5178 100644 --- a/http/parameters.go +++ b/http/parameters.go @@ -32,7 +32,7 @@ type parameters struct { // Parameter is the interface for service parameters. type Parameter interface { - apply(*parameters) + apply(p *parameters) } type parameterFunc func(*parameters) diff --git a/http/validators_test.go b/http/validators_test.go index 53b4fa8f..19189388 100644 --- a/http/validators_test.go +++ b/http/validators_test.go @@ -15,8 +15,8 @@ package http_test import ( "context" - "fmt" "os" + "strconv" "testing" client "github.com/attestantio/go-eth2-client" @@ -94,7 +94,7 @@ func TestValidators(t *testing.T) { t.Run(test.name, func(t *testing.T) { response, err := service.(client.ValidatorsProvider).Validators(ctx, test.opts) if test.expectedErrorCode != 0 { - require.Contains(t, err.Error(), fmt.Sprintf("%d", test.expectedErrorCode)) + require.Contains(t, err.Error(), strconv.Itoa(test.expectedErrorCode)) } else { require.NoError(t, err) require.NotNil(t, response) diff --git a/mock/parameters.go b/mock/parameters.go index a33f5b93..b569ce28 100644 --- a/mock/parameters.go +++ b/mock/parameters.go @@ -29,7 +29,7 @@ type parameters struct { // Parameter is the interface for service parameters. type Parameter interface { - apply(*parameters) + apply(p *parameters) } type parameterFunc func(*parameters) diff --git a/multi/parameters.go b/multi/parameters.go index a40f75e9..3bb8e438 100644 --- a/multi/parameters.go +++ b/multi/parameters.go @@ -34,7 +34,7 @@ type parameters struct { // Parameter is the interface for service parameters. type Parameter interface { - apply(*parameters) + apply(p *parameters) } type parameterFunc func(*parameters) diff --git a/spec/altair/beaconstate.go b/spec/altair/beaconstate.go index 28b74742..b464bb2d 100644 --- a/spec/altair/beaconstate.go +++ b/spec/altair/beaconstate.go @@ -147,11 +147,11 @@ func (s *BeaconState) MarshalJSON() ([]byte, error) { } inactivityScores := make([]string, len(s.InactivityScores)) for i := range s.InactivityScores { - inactivityScores[i] = fmt.Sprintf("%d", s.InactivityScores[i]) + inactivityScores[i] = strconv.FormatUint(s.InactivityScores[i], 10) } return json.Marshal(&beaconStateJSON{ - GenesisTime: fmt.Sprintf("%d", s.GenesisTime), + GenesisTime: strconv.FormatUint(s.GenesisTime, 10), GenesisValidatorsRoot: fmt.Sprintf("%#x", s.GenesisValidatorsRoot), Slot: fmt.Sprintf("%d", s.Slot), Fork: s.Fork, @@ -161,7 +161,7 @@ func (s *BeaconState) MarshalJSON() ([]byte, error) { HistoricalRoots: historicalRoots, ETH1Data: s.ETH1Data, ETH1DataVotes: s.ETH1DataVotes, - ETH1DepositIndex: fmt.Sprintf("%d", s.ETH1DepositIndex), + ETH1DepositIndex: strconv.FormatUint(s.ETH1DepositIndex, 10), Validators: s.Validators, Balances: balances, RANDAOMixes: randaoMixes, diff --git a/spec/altair/synccommitteecontribution.go b/spec/altair/synccommitteecontribution.go index d2c56039..6438cd6a 100644 --- a/spec/altair/synccommitteecontribution.go +++ b/spec/altair/synccommitteecontribution.go @@ -60,7 +60,7 @@ func (s *SyncCommitteeContribution) MarshalJSON() ([]byte, error) { return json.Marshal(&syncCommitteeContributionJSON{ Slot: fmt.Sprintf("%d", s.Slot), BeaconBlockRoot: fmt.Sprintf("%#x", s.BeaconBlockRoot), - SubcommitteeIndex: fmt.Sprintf("%d", s.SubcommitteeIndex), + SubcommitteeIndex: strconv.FormatUint(s.SubcommitteeIndex, 10), AggregationBits: fmt.Sprintf("%#x", []byte(s.AggregationBits)), Signature: fmt.Sprintf("%#x", s.Signature), }) diff --git a/spec/bellatrix/beaconstate.go b/spec/bellatrix/beaconstate.go index 8f580b9b..fac82bba 100644 --- a/spec/bellatrix/beaconstate.go +++ b/spec/bellatrix/beaconstate.go @@ -151,11 +151,11 @@ func (s *BeaconState) MarshalJSON() ([]byte, error) { } inactivityScores := make([]string, len(s.InactivityScores)) for i := range s.InactivityScores { - inactivityScores[i] = fmt.Sprintf("%d", s.InactivityScores[i]) + inactivityScores[i] = strconv.FormatUint(s.InactivityScores[i], 10) } return json.Marshal(&beaconStateJSON{ - GenesisTime: fmt.Sprintf("%d", s.GenesisTime), + GenesisTime: strconv.FormatUint(s.GenesisTime, 10), GenesisValidatorsRoot: fmt.Sprintf("%#x", s.GenesisValidatorsRoot), Slot: fmt.Sprintf("%d", s.Slot), Fork: s.Fork, @@ -165,7 +165,7 @@ func (s *BeaconState) MarshalJSON() ([]byte, error) { HistoricalRoots: historicalRoots, ETH1Data: s.ETH1Data, ETH1DataVotes: s.ETH1DataVotes, - ETH1DepositIndex: fmt.Sprintf("%d", s.ETH1DepositIndex), + ETH1DepositIndex: strconv.FormatUint(s.ETH1DepositIndex, 10), Validators: s.Validators, Balances: balances, RANDAOMixes: randaoMixes, diff --git a/spec/bellatrix/executionaddress.go b/spec/bellatrix/executionaddress.go index 3724a94f..ea750feb 100644 --- a/spec/bellatrix/executionaddress.go +++ b/spec/bellatrix/executionaddress.go @@ -27,7 +27,7 @@ type ExecutionAddress [20]byte // String returns an EIP-55 string version of the address. func (a ExecutionAddress) String() string { - bytes := []byte(fmt.Sprintf("%x", a[:])) + bytes := []byte(hex.EncodeToString(a[:])) keccak := sha3.NewLegacyKeccak256() keccak.Write(bytes) diff --git a/spec/bellatrix/executionpayload.go b/spec/bellatrix/executionpayload.go index 1af66500..18f04c85 100644 --- a/spec/bellatrix/executionpayload.go +++ b/spec/bellatrix/executionpayload.go @@ -108,10 +108,10 @@ func (e *ExecutionPayload) MarshalJSON() ([]byte, error) { ReceiptsRoot: fmt.Sprintf("%#x", e.ReceiptsRoot), LogsBloom: fmt.Sprintf("%#x", e.LogsBloom), PrevRandao: fmt.Sprintf("%#x", e.PrevRandao), - BlockNumber: fmt.Sprintf("%d", e.BlockNumber), - GasLimit: fmt.Sprintf("%d", e.GasLimit), - GasUsed: fmt.Sprintf("%d", e.GasUsed), - Timestamp: fmt.Sprintf("%d", e.Timestamp), + BlockNumber: strconv.FormatUint(e.BlockNumber, 10), + GasLimit: strconv.FormatUint(e.GasLimit, 10), + GasUsed: strconv.FormatUint(e.GasUsed, 10), + Timestamp: strconv.FormatUint(e.Timestamp, 10), ExtraData: extraData, BaseFeePerGas: baseFeePerGas.String(), BlockHash: fmt.Sprintf("%#x", e.BlockHash), diff --git a/spec/bellatrix/executionpayloadheader.go b/spec/bellatrix/executionpayloadheader.go index e83e6b46..6f853203 100644 --- a/spec/bellatrix/executionpayloadheader.go +++ b/spec/bellatrix/executionpayloadheader.go @@ -103,10 +103,10 @@ func (e *ExecutionPayloadHeader) MarshalJSON() ([]byte, error) { ReceiptsRoot: fmt.Sprintf("%#x", e.ReceiptsRoot), LogsBloom: fmt.Sprintf("%#x", e.LogsBloom), PrevRandao: fmt.Sprintf("%#x", e.PrevRandao), - BlockNumber: fmt.Sprintf("%d", e.BlockNumber), - GasLimit: fmt.Sprintf("%d", e.GasLimit), - GasUsed: fmt.Sprintf("%d", e.GasUsed), - Timestamp: fmt.Sprintf("%d", e.Timestamp), + BlockNumber: strconv.FormatUint(e.BlockNumber, 10), + GasLimit: strconv.FormatUint(e.GasLimit, 10), + GasUsed: strconv.FormatUint(e.GasUsed, 10), + Timestamp: strconv.FormatUint(e.Timestamp, 10), ExtraData: extraData, BaseFeePerGas: baseFeePerGas.String(), BlockHash: fmt.Sprintf("%#x", e.BlockHash), diff --git a/spec/capella/beaconstate_json.go b/spec/capella/beaconstate_json.go index f4f71350..46fbe554 100644 --- a/spec/capella/beaconstate_json.go +++ b/spec/capella/beaconstate_json.go @@ -93,11 +93,11 @@ func (s *BeaconState) MarshalJSON() ([]byte, error) { } inactivityScores := make([]string, len(s.InactivityScores)) for i := range s.InactivityScores { - inactivityScores[i] = fmt.Sprintf("%d", s.InactivityScores[i]) + inactivityScores[i] = strconv.FormatUint(s.InactivityScores[i], 10) } return json.Marshal(&beaconStateJSON{ - GenesisTime: fmt.Sprintf("%d", s.GenesisTime), + GenesisTime: strconv.FormatUint(s.GenesisTime, 10), GenesisValidatorsRoot: fmt.Sprintf("%#x", s.GenesisValidatorsRoot), Slot: fmt.Sprintf("%d", s.Slot), Fork: s.Fork, @@ -107,7 +107,7 @@ func (s *BeaconState) MarshalJSON() ([]byte, error) { HistoricalRoots: historicalRoots, ETH1Data: s.ETH1Data, ETH1DataVotes: s.ETH1DataVotes, - ETH1DepositIndex: fmt.Sprintf("%d", s.ETH1DepositIndex), + ETH1DepositIndex: strconv.FormatUint(s.ETH1DepositIndex, 10), Validators: s.Validators, Balances: balances, RANDAOMixes: randaoMixes, diff --git a/spec/capella/executionpayload.go b/spec/capella/executionpayload.go index e22c5a95..a2e74815 100644 --- a/spec/capella/executionpayload.go +++ b/spec/capella/executionpayload.go @@ -112,10 +112,10 @@ func (e *ExecutionPayload) MarshalJSON() ([]byte, error) { ReceiptsRoot: fmt.Sprintf("%#x", e.ReceiptsRoot), LogsBloom: fmt.Sprintf("%#x", e.LogsBloom), PrevRandao: fmt.Sprintf("%#x", e.PrevRandao), - BlockNumber: fmt.Sprintf("%d", e.BlockNumber), - GasLimit: fmt.Sprintf("%d", e.GasLimit), - GasUsed: fmt.Sprintf("%d", e.GasUsed), - Timestamp: fmt.Sprintf("%d", e.Timestamp), + BlockNumber: strconv.FormatUint(e.BlockNumber, 10), + GasLimit: strconv.FormatUint(e.GasLimit, 10), + GasUsed: strconv.FormatUint(e.GasUsed, 10), + Timestamp: strconv.FormatUint(e.Timestamp, 10), ExtraData: extraData, BaseFeePerGas: baseFeePerGas.String(), BlockHash: fmt.Sprintf("%#x", e.BlockHash), diff --git a/spec/capella/executionpayloadheader.go b/spec/capella/executionpayloadheader.go index e6fc8f67..c8616b79 100644 --- a/spec/capella/executionpayloadheader.go +++ b/spec/capella/executionpayloadheader.go @@ -107,10 +107,10 @@ func (e *ExecutionPayloadHeader) MarshalJSON() ([]byte, error) { ReceiptsRoot: fmt.Sprintf("%#x", e.ReceiptsRoot), LogsBloom: fmt.Sprintf("%#x", e.LogsBloom), PrevRandao: fmt.Sprintf("%#x", e.PrevRandao), - BlockNumber: fmt.Sprintf("%d", e.BlockNumber), - GasLimit: fmt.Sprintf("%d", e.GasLimit), - GasUsed: fmt.Sprintf("%d", e.GasUsed), - Timestamp: fmt.Sprintf("%d", e.Timestamp), + BlockNumber: strconv.FormatUint(e.BlockNumber, 10), + GasLimit: strconv.FormatUint(e.GasLimit, 10), + GasUsed: strconv.FormatUint(e.GasUsed, 10), + Timestamp: strconv.FormatUint(e.Timestamp, 10), ExtraData: extraData, BaseFeePerGas: baseFeePerGas.String(), BlockHash: fmt.Sprintf("%#x", e.BlockHash), diff --git a/spec/deneb/beaconstate_json.go b/spec/deneb/beaconstate_json.go index d80cef7a..eaf46972 100644 --- a/spec/deneb/beaconstate_json.go +++ b/spec/deneb/beaconstate_json.go @@ -84,11 +84,11 @@ func (b *BeaconState) MarshalJSON() ([]byte, error) { } inactivityScores := make([]string, len(b.InactivityScores)) for i := range b.InactivityScores { - inactivityScores[i] = fmt.Sprintf("%d", b.InactivityScores[i]) + inactivityScores[i] = strconv.FormatUint(b.InactivityScores[i], 10) } return json.Marshal(&beaconStateJSON{ - GenesisTime: fmt.Sprintf("%d", b.GenesisTime), + GenesisTime: strconv.FormatUint(b.GenesisTime, 10), GenesisValidatorsRoot: b.GenesisValidatorsRoot, Slot: b.Slot, Fork: b.Fork, @@ -98,7 +98,7 @@ func (b *BeaconState) MarshalJSON() ([]byte, error) { HistoricalRoots: b.HistoricalRoots, ETH1Data: b.ETH1Data, ETH1DataVotes: b.ETH1DataVotes, - ETH1DepositIndex: fmt.Sprintf("%d", b.ETH1DepositIndex), + ETH1DepositIndex: strconv.FormatUint(b.ETH1DepositIndex, 10), Validators: b.Validators, Balances: balances, RANDAOMixes: randaoMixes, diff --git a/spec/deneb/executionpayload_json.go b/spec/deneb/executionpayload_json.go index c00c5bf1..5b9564d2 100644 --- a/spec/deneb/executionpayload_json.go +++ b/spec/deneb/executionpayload_json.go @@ -68,17 +68,17 @@ func (e *ExecutionPayload) MarshalJSON() ([]byte, error) { ReceiptsRoot: e.ReceiptsRoot, LogsBloom: fmt.Sprintf("%#x", e.LogsBloom), PrevRandao: fmt.Sprintf("%#x", e.PrevRandao), - BlockNumber: fmt.Sprintf("%d", e.BlockNumber), - GasLimit: fmt.Sprintf("%d", e.GasLimit), - GasUsed: fmt.Sprintf("%d", e.GasUsed), - Timestamp: fmt.Sprintf("%d", e.Timestamp), + BlockNumber: strconv.FormatUint(e.BlockNumber, 10), + GasLimit: strconv.FormatUint(e.GasLimit, 10), + GasUsed: strconv.FormatUint(e.GasUsed, 10), + Timestamp: strconv.FormatUint(e.Timestamp, 10), ExtraData: extraData, BaseFeePerGas: e.BaseFeePerGas.Dec(), BlockHash: e.BlockHash, Transactions: transactions, Withdrawals: e.Withdrawals, - BlobGasUsed: fmt.Sprintf("%d", e.BlobGasUsed), - ExcessBlobGas: fmt.Sprintf("%d", e.ExcessBlobGas), + BlobGasUsed: strconv.FormatUint(e.BlobGasUsed, 10), + ExcessBlobGas: strconv.FormatUint(e.ExcessBlobGas, 10), }) } diff --git a/spec/deneb/executionpayloadheader_json.go b/spec/deneb/executionpayloadheader_json.go index 1ff5aa39..b58d00bb 100644 --- a/spec/deneb/executionpayloadheader_json.go +++ b/spec/deneb/executionpayloadheader_json.go @@ -62,17 +62,17 @@ func (e *ExecutionPayloadHeader) MarshalJSON() ([]byte, error) { ReceiptsRoot: e.ReceiptsRoot, LogsBloom: fmt.Sprintf("%#x", e.LogsBloom), PrevRandao: fmt.Sprintf("%#x", e.PrevRandao), - BlockNumber: fmt.Sprintf("%d", e.BlockNumber), - GasLimit: fmt.Sprintf("%d", e.GasLimit), - GasUsed: fmt.Sprintf("%d", e.GasUsed), - Timestamp: fmt.Sprintf("%d", e.Timestamp), + BlockNumber: strconv.FormatUint(e.BlockNumber, 10), + GasLimit: strconv.FormatUint(e.GasLimit, 10), + GasUsed: strconv.FormatUint(e.GasUsed, 10), + Timestamp: strconv.FormatUint(e.Timestamp, 10), ExtraData: extraData, BaseFeePerGas: e.BaseFeePerGas.Dec(), BlockHash: e.BlockHash, TransactionsRoot: e.TransactionsRoot, WithdrawalsRoot: e.WithdrawalsRoot, - BlobGasUsed: fmt.Sprintf("%d", e.BlobGasUsed), - ExcessBlobGas: fmt.Sprintf("%d", e.ExcessBlobGas), + BlobGasUsed: strconv.FormatUint(e.BlobGasUsed, 10), + ExcessBlobGas: strconv.FormatUint(e.ExcessBlobGas, 10), }) } diff --git a/spec/phase0/beaconstate.go b/spec/phase0/beaconstate.go index 975edb68..d711a8c5 100644 --- a/spec/phase0/beaconstate.go +++ b/spec/phase0/beaconstate.go @@ -129,7 +129,7 @@ func (s *BeaconState) MarshalJSON() ([]byte, error) { } return json.Marshal(&beaconStateJSON{ - GenesisTime: fmt.Sprintf("%d", s.GenesisTime), + GenesisTime: strconv.FormatUint(s.GenesisTime, 10), GenesisValidatorsRoot: fmt.Sprintf("%#x", s.GenesisValidatorsRoot), Slot: fmt.Sprintf("%d", s.Slot), Fork: s.Fork, @@ -139,7 +139,7 @@ func (s *BeaconState) MarshalJSON() ([]byte, error) { HistoricalRoots: historicalRoots, ETH1Data: s.ETH1Data, ETH1DataVotes: s.ETH1DataVotes, - ETH1DepositIndex: fmt.Sprintf("%d", s.ETH1DepositIndex), + ETH1DepositIndex: strconv.FormatUint(s.ETH1DepositIndex, 10), Validators: s.Validators, Balances: balances, RANDAOMixes: randaoMixes, diff --git a/spec/phase0/eth1data.go b/spec/phase0/eth1data.go index afaec80a..c1726885 100644 --- a/spec/phase0/eth1data.go +++ b/spec/phase0/eth1data.go @@ -51,7 +51,7 @@ type eth1DataYAML struct { func (e *ETH1Data) MarshalJSON() ([]byte, error) { return json.Marshal(ð1DataJSON{ DepositRoot: fmt.Sprintf("%#x", e.DepositRoot), - DepositCount: fmt.Sprintf("%d", e.DepositCount), + DepositCount: strconv.FormatUint(e.DepositCount, 10), BlockHash: fmt.Sprintf("%#x", e.BlockHash), }) } diff --git a/spec/phase0/indexedattestation.go b/spec/phase0/indexedattestation.go index a3455cb4..a8cb3b2a 100644 --- a/spec/phase0/indexedattestation.go +++ b/spec/phase0/indexedattestation.go @@ -51,7 +51,7 @@ type indexedAttestationYAML struct { func (i *IndexedAttestation) MarshalJSON() ([]byte, error) { attestingIndices := make([]string, len(i.AttestingIndices)) for j := range i.AttestingIndices { - attestingIndices[j] = fmt.Sprintf("%d", i.AttestingIndices[j]) + attestingIndices[j] = strconv.FormatUint(i.AttestingIndices[j], 10) } return json.Marshal(&indexedAttestationJSON{