chore: lint: fix lint errors with new linting config

Ref: https://github.com/filecoin-project/lotus/issues/11967
This commit is contained in:
Rod Vagg
2024-05-13 14:52:09 +10:00
parent 6a8110322d
commit 26d3fd2ecc
66 changed files with 128 additions and 153 deletions
+2 -2
View File
@@ -644,8 +644,8 @@ func (a *ChainAPI) ChainExport(ctx context.Context, nroots abi.ChainEpoch, skipo
bw := bufio.NewWriterSize(w, 1<<20)
err := a.Chain.Export(ctx, ts, nroots, skipoldmsgs, bw)
bw.Flush() //nolint:errcheck // it is a write to a pipe
w.CloseWithError(err) //nolint:errcheck // it is a pipe
_ = bw.Flush() // it is a write to a pipe
_ = w.CloseWithError(err) // it is a pipe
}()
go func() {
+18 -19
View File
@@ -92,9 +92,8 @@ func getTipsetByEthBlockNumberOrHash(ctx context.Context, chain *store.ChainStor
return nil, fmt.Errorf("cannot get parent tipset")
}
return parent, nil
} else {
return nil, fmt.Errorf("unknown predefined block %s", *predefined)
}
return nil, fmt.Errorf("unknown predefined block %s", *predefined)
}
if blkParam.BlockNumber != nil {
@@ -298,7 +297,7 @@ func executeTipset(ctx context.Context, ts *types.TipSet, cs *store.ChainStore,
const errorFunctionSelector = "\x08\xc3\x79\xa0" // Error(string)
const panicFunctionSelector = "\x4e\x48\x7b\x71" // Panic(uint256)
// Eth ABI (solidity) panic codes.
var panicErrorCodes map[uint64]string = map[uint64]string{
var panicErrorCodes = map[uint64]string{
0x00: "Panic()",
0x01: "Assert()",
0x11: "ArithmeticOverflow()",
@@ -398,19 +397,19 @@ func lookupEthAddress(addr address.Address, st *state.StateTree) (ethtypes.EthAd
}
// Lookup on the target actor and try to get an f410 address.
if actor, err := st.GetActor(idAddr); errors.Is(err, types.ErrActorNotFound) {
// Not found -> use a masked ID address
} else if err != nil {
// Any other error -> fail.
return ethtypes.EthAddress{}, err
} else if actor.Address == nil {
// No delegated address -> use masked ID address.
} else if ethAddr, err := ethtypes.EthAddressFromFilecoinAddress(*actor.Address); err == nil && !ethAddr.IsMaskedID() {
// Conversable into an eth address, use it.
return ethAddr, nil
}
if actor, err := st.GetActor(idAddr); !errors.Is(err, types.ErrActorNotFound) {
if err != nil {
// Any other error -> fail.
return ethtypes.EthAddress{}, err
}
if actor.Address != nil {
if ethAddr, err := ethtypes.EthAddressFromFilecoinAddress(*actor.Address); err == nil && !ethAddr.IsMaskedID() {
// Conversable into an eth address, use it.
return ethAddr, nil
}
} // else no delegated address -> use masked ID address.
} // else not found -> use a masked ID address
// Otherwise, use the masked address.
return ethtypes.EthAddressFromFilecoinAddress(idAddr)
}
@@ -456,9 +455,9 @@ func ethTxHashFromSignedMessage(smsg *types.SignedMessage) (ethtypes.EthHash, er
return tx.TxHash()
} else if smsg.Signature.Type == crypto.SigTypeSecp256k1 {
return ethtypes.EthHashFromCid(smsg.Cid())
} else { // BLS message
return ethtypes.EthHashFromCid(smsg.Message.Cid())
}
// else BLS message
return ethtypes.EthHashFromCid(smsg.Message.Cid())
}
func newEthTxFromSignedMessage(smsg *types.SignedMessage, st *state.StateTree) (ethtypes.EthTx, error) {
@@ -817,8 +816,8 @@ func encodeAsABIHelper(param1 uint64, param2 uint64, data []byte) []byte {
if len(data)%EVM_WORD_SIZE != 0 {
totalWords++
}
len := totalWords * EVM_WORD_SIZE
buf := make([]byte, len)
l := totalWords * EVM_WORD_SIZE
buf := make([]byte, l)
offset := 0
// Below, we use copy instead of "appending" to preserve all the zero padding.
for _, arg := range staticArgs {
+1 -2
View File
@@ -965,9 +965,8 @@ func (a *StateAPI) StateComputeDataCID(ctx context.Context, maddr address.Addres
return a.stateComputeDataCIDv1(ctx, maddr, sectorType, deals, tsk)
} else if nv < network.Version21 {
return a.stateComputeDataCIDv2(ctx, maddr, sectorType, deals, tsk)
} else {
return a.stateComputeDataCIDv3(ctx, maddr, sectorType, deals, tsk)
}
return a.stateComputeDataCIDv3(ctx, maddr, sectorType, deals, tsk)
}
func (a *StateAPI) stateComputeDataCIDv1(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) {