Skip to content

Commit

Permalink
test: Fix lint - G115
Browse files Browse the repository at this point in the history
  • Loading branch information
dudong2 committed Oct 2, 2024
1 parent 3673909 commit efcd77e
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/ante/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (eeed EthEmitEventDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat
ctx.EventManager().EmitEvent(sdk.NewEvent(
evmtypes.EventTypeEthereumTx,
sdk.NewAttribute(evmtypes.AttributeKeyEthereumTxHash, msgEthTx.Hash),
sdk.NewAttribute(evmtypes.AttributeKeyTxIndex, strconv.FormatUint(txIndex+uint64(i), 10)),
sdk.NewAttribute(evmtypes.AttributeKeyTxIndex, strconv.FormatUint(txIndex+uint64(i), 10)), //#nosec G115
))
}

Expand Down
4 changes: 2 additions & 2 deletions indexer/kv_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ func TxHashKey(hash common.Hash) []byte {

// TxIndexKey returns the key for db entry: `(block number, tx index) -> tx hash`
func TxIndexKey(blockNumber int64, txIndex int32) []byte {
bz1 := sdk.Uint64ToBigEndian(uint64(blockNumber))
bz2 := sdk.Uint64ToBigEndian(uint64(txIndex))
bz1 := sdk.Uint64ToBigEndian(uint64(blockNumber)) //#nosec G115
bz2 := sdk.Uint64ToBigEndian(uint64(txIndex)) //#nosec G115
return append(append([]byte{KeyPrefixTxIndex}, bz1...), bz2...)
}

Expand Down
6 changes: 3 additions & 3 deletions rpc/backend/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ func (b *Backend) RPCBlockFromTendermintBlock(
rpcTx, err := rpctypes.NewRPCTransaction(
tx,
common.BytesToHash(block.Hash()),
uint64(block.Height),
uint64(txIndex),
uint64(block.Height), //#nosec G115
uint64(txIndex), //#nosec G115
baseFee,
b.chainID,
)
Expand Down Expand Up @@ -457,7 +457,7 @@ func (b *Backend) RPCBlockFromTendermintBlock(
// block gas limit has exceeded, other txs must have failed with same reason.
break
}
gasUsed += uint64(txsResult.GetGasUsed())
gasUsed += uint64(txsResult.GetGasUsed()) //#nosec G115
}

formattedBlock := rpctypes.FormatBlock(
Expand Down
4 changes: 2 additions & 2 deletions rpc/backend/node_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func (b *Backend) Syncing() (interface{}, error) {
}

return map[string]interface{}{
"startingBlock": hexutil.Uint64(status.SyncInfo.EarliestBlockHeight),
"currentBlock": hexutil.Uint64(status.SyncInfo.LatestBlockHeight),
"startingBlock": hexutil.Uint64(status.SyncInfo.EarliestBlockHeight), //#nosec G115
"currentBlock": hexutil.Uint64(status.SyncInfo.LatestBlockHeight), //#nosec G115
// "highestBlock": nil, // NA
// "pulledStates": nil, // NA
// "knownStates": nil, // NA
Expand Down
12 changes: 6 additions & 6 deletions rpc/backend/tx_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func (b *Backend) GetTransactionByHash(txHash common.Hash) (*rpctypes.RPCTransac
return rpctypes.NewTransactionFromMsg(
msg,
common.BytesToHash(block.BlockID.Hash.Bytes()),
uint64(res.Height),
uint64(res.EthTxIndex),
uint64(res.Height), //#nosec G115
uint64(res.EthTxIndex), //#nosec G115
baseFee,
b.chainID,
)
Expand Down Expand Up @@ -179,7 +179,7 @@ func (b *Backend) GetTransactionReceipt(hash common.Hash) (map[string]interface{
return nil, nil
}
for _, txResult := range blockRes.TxsResults[0:res.TxIndex] {
cumulativeGasUsed += uint64(txResult.GasUsed)
cumulativeGasUsed += uint64(txResult.GasUsed) //#nosec G115
}
cumulativeGasUsed += res.CumulativeGasUsed

Expand Down Expand Up @@ -236,8 +236,8 @@ func (b *Backend) GetTransactionReceipt(hash common.Hash) (map[string]interface{
// Inclusion information: These fields provide information about the inclusion of the
// transaction corresponding to this receipt.
"blockHash": common.BytesToHash(resBlock.Block.Header.Hash()).Hex(),
"blockNumber": hexutil.Uint64(res.Height),
"transactionIndex": hexutil.Uint64(res.EthTxIndex),
"blockNumber": hexutil.Uint64(res.Height), //#nosec G115
"transactionIndex": hexutil.Uint64(res.EthTxIndex), //#nosec G115

// sender and receiver (contract or EOA) addreses
"from": from,
Expand Down Expand Up @@ -417,7 +417,7 @@ func (b *Backend) GetTransactionByBlockAndIndex(block *tmrpctypes.ResultBlock, i
return rpctypes.NewTransactionFromMsg(
msg,
common.BytesToHash(block.Block.Hash()),
uint64(block.Block.Height),
uint64(block.Block.Height), //#nosec G115
uint64(idx),
baseFee,
b.chainID,
Expand Down
2 changes: 1 addition & 1 deletion rpc/backend/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (b *Backend) processBlock(
b.logger.Debug("failed to decode transaction in block", "height", blockHeight, "error", err.Error())
continue
}
txGasUsed := uint64(eachTendermintTxResult.GasUsed)
txGasUsed := uint64(eachTendermintTxResult.GasUsed) //#nosec G115
for _, msg := range tx.GetMsgs() {
ethMsg, ok := msg.(*evmtypes.MsgEthereumTx)
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion rpc/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func ParseTxResult(result *abci.ExecTxResult, tx sdk.Tx) (*ParsedTxs, error) {

// some old versions miss some events, fill it with tx result
if len(p.Txs) == 1 {
p.Txs[0].GasUsed = uint64(result.GasUsed)
p.Txs[0].GasUsed = uint64(result.GasUsed) //#nosec G115
}

// this could only happen if tx exceeds block gas limit
Expand Down
10 changes: 5 additions & 5 deletions rpc/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func EthHeaderFromTendermint(header tmtypes.Header, bloom ethtypes.Bloom, baseFe
Number: big.NewInt(header.Height),
GasLimit: 0,
GasUsed: 0,
Time: uint64(header.Time.UTC().Unix()),
Time: uint64(header.Time.UTC().Unix()), //#nosec G115
Extra: []byte{},
MixDigest: common.Hash{},
Nonce: ethtypes.BlockNonce{},
Expand Down Expand Up @@ -128,7 +128,7 @@ func FormatBlock(
}

result := map[string]interface{}{
"number": hexutil.Uint64(header.Height),
"number": hexutil.Uint64(header.Height), //#nosec G115
"hash": hexutil.Bytes(header.Hash()),
"parentHash": common.BytesToHash(header.LastBlockID.Hash.Bytes()),
"nonce": ethtypes.BlockNonce{}, // PoW specific
Expand All @@ -139,10 +139,10 @@ func FormatBlock(
"mixHash": common.Hash{},
"difficulty": (*hexutil.Big)(big.NewInt(0)),
"extraData": "0x",
"size": hexutil.Uint64(size),
"gasLimit": hexutil.Uint64(gasLimit), // Static gas limit
"size": hexutil.Uint64(size), //#nosec G115
"gasLimit": hexutil.Uint64(gasLimit), //#nosec G115 // Static gas limit
"gasUsed": (*hexutil.Big)(gasUsed),
"timestamp": hexutil.Uint64(header.Time.Unix()),
"timestamp": hexutil.Uint64(header.Time.Unix()), //#nosec G115
"transactionsRoot": transactionsRoot,
"receiptsRoot": ethtypes.EmptyRootHash,

Expand Down
6 changes: 3 additions & 3 deletions x/evm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type
// Query block gas limit
params := ctx.ConsensusParams()
if params.Block != nil && params.Block.MaxGas > 0 {
hi = uint64(params.Block.MaxGas)
hi = uint64(params.Block.MaxGas) //#nosec G115
} else {
hi = req.GasCap
}
Expand Down Expand Up @@ -435,7 +435,7 @@ func (k Keeper) TraceTx(c context.Context, req *types.QueryTraceTxRequest) (*typ
continue
}
txConfig.TxHash = ethTx.Hash()
txConfig.TxIndex = uint(i)
txConfig.TxIndex = uint(i) //#nosec G115
rsp, err := k.ApplyMessageWithConfig(ctx, msg, types.NewNoOpTracer(), true, cfg, txConfig)
if err != nil {
continue
Expand Down Expand Up @@ -512,7 +512,7 @@ func (k Keeper) TraceBlock(c context.Context, req *types.QueryTraceBlockRequest)
result := types.TxTraceResult{}
ethTx := tx.AsTransaction()
txConfig.TxHash = ethTx.Hash()
txConfig.TxIndex = uint(i)
txConfig.TxIndex = uint(i) //#nosec G115
traceResult, logIndex, err := k.traceTx(ctx, cfg, txConfig, signer, ethTx, req.TraceConfig, true, nil)
if err != nil {
result.Error = err.Error()
Expand Down
4 changes: 2 additions & 2 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (k Keeper) GetAuthority() sdk.AccAddress {
// GetBlockBloomTransient returns bloom bytes for the current block height
func (k Keeper) GetBlockBloomTransient(ctx sdk.Context) *big.Int {
store := prefix.NewStore(ctx.TransientStore(k.transientKey), types.KeyPrefixTransientBloom)
heightBz := sdk.Uint64ToBigEndian(uint64(ctx.BlockHeight()))
heightBz := sdk.Uint64ToBigEndian(uint64(ctx.BlockHeight())) //#nosec G115
bz := store.Get(heightBz)
if len(bz) == 0 {
return big.NewInt(0)
Expand All @@ -184,7 +184,7 @@ func (k Keeper) GetBlockBloomTransient(ctx sdk.Context) *big.Int {
// every block.
func (k Keeper) SetBlockBloomTransient(ctx sdk.Context, bloom *big.Int) {
store := prefix.NewStore(ctx.TransientStore(k.transientKey), types.KeyPrefixTransientBloom)
heightBz := sdk.Uint64ToBigEndian(uint64(ctx.BlockHeight()))
heightBz := sdk.Uint64ToBigEndian(uint64(ctx.BlockHeight())) //#nosec G115
store.Set(heightBz, bloom.Bytes())
}

Expand Down

0 comments on commit efcd77e

Please sign in to comment.