Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
workflow_dispatch:

env:
GO_VER: 1.25.7
GO_VER: 1.26.0
GINKGO_VER: 2.27.3

jobs:
Expand Down Expand Up @@ -54,9 +54,9 @@ jobs:
go-version: ${{ env.GO_VER }}
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
uses: golangci/golangci-lint-action@v9
with:
version: v2.4
version: v2.9.0
skip-cache: true
problem-matchers: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'v*'

env:
GO_VER: 1.25.7
GO_VER: 1.26.0
UBUNTU_VER: 22.04
APP_VER: ${{ github.ref_name }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/vulnerability-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ permissions:
jobs:
scan-scheduled:
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.2.2"
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.3.3"
with:
scan-args: |-
--config ./osv-scanner-config.toml
Expand All @@ -31,7 +31,7 @@ jobs:

scan-pr:
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@v2.2.2"
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@v2.3.3"
with:
scan-args: |-
--config ./osv-scanner-config.toml
Expand Down
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "2"
run:
concurrency: 4
go: "1.25"
go: "1.26"
tests: false
linters:
default: none
Expand Down Expand Up @@ -56,6 +56,7 @@ linters:
- unparam
- usestdlibvars
- whitespace
- modernize
settings:
gosec:
excludes:
Expand Down
10 changes: 6 additions & 4 deletions chrobot/chrobot.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package chrobot
import (
"context"
"fmt"
"strings"
"time"

"github.com/anoideaopen/glog"
Expand Down Expand Up @@ -352,12 +353,13 @@ func batchExecInfoMsg(chName string, bfe *executordto.Batch, batchInfo *collecto
}

func storedCheckpointsMsg(checkPoints *stordto.ChCheckPoint) string {
msg := "saved checkpoints:\n"
var msg strings.Builder
msg.WriteString("saved checkpoints:\n")
for ch, n := range checkPoints.SrcCollectFromBlockNums {
msg += fmt.Sprintf("collect from %d block for channel %s\n", n, ch)
msg.WriteString(fmt.Sprintf("collect from %d block for channel %s\n", n, ch))
}
msg += fmt.Sprintf("exec on peers with minimum blocknum in ledger %d\n", checkPoints.MinExecBlockNum)
return msg
msg.WriteString(fmt.Sprintf("exec on peers with minimum blocknum in ledger %d\n", checkPoints.MinExecBlockNum))
return msg.String()
}

// CreateRobots - creates robots specified by config
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/anoideaopen/robot

go 1.25.7
go 1.26.0

require (
github.com/anoideaopen/common-component v0.0.7
Expand Down
2 changes: 1 addition & 1 deletion hlf/hlfexecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type hlfExecutor struct {
}

func (he *hlfExecutor) Execute(ctx context.Context, request channel.Request) (channel.Response, error) {
var options []channel.RequestOption
options := make([]channel.RequestOption, 0, 2)

executeTimeout := he.chCtx.EndpointConfig().Timeout(fab.Execute)
if he.execOpts.ExecuteTimeout > 0 {
Expand Down
3 changes: 2 additions & 1 deletion hlf/sdkwrapper/service/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ func SignACL(signerInfoArray []SignerInfo, methodName string, address string, re
nonce := GetNonce()
// 1. update to change any transactions
// 2.
result := []string{methodName, address, reason, reasonID, newPkey, nonce}
result := make([]string, 0, len(signerInfoArray)+6)
result = append(result, methodName, address, reason, reasonID, newPkey, nonce)
for _, signerInfo := range signerInfoArray {
result = append(result, ConvertPublicKeyToBase58(signerInfo.PublicKey))
}
Expand Down
12 changes: 5 additions & 7 deletions hlf/sdkwrapper/service/fabric.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (hlf *HLFClient) Invoke(channelID string, chaincodeName string, methodName

client := channelConnection.channelClient

var beforeInvokeData interface{}
var beforeInvokeData any
if hlf.beforeInvokeHandler != nil {
beforeInvokeData, err = hlf.beforeInvokeHandler(channelID, chaincodeName, methodName, methodArgs, noBatch, peers...)
if err != nil {
Expand Down Expand Up @@ -247,8 +247,8 @@ func (hlf *HLFClient) Invoke(channelID string, chaincodeName string, methodName
}

type (
HlfBeforeInvokeHandler func(channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers ...string) (interface{}, error)
HlfAfterInvokeHandler func(beforeInvokeData interface{}, r *channel.Response, invokeErr error, channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers ...string) error
HlfBeforeInvokeHandler func(channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers ...string) (any, error)
HlfAfterInvokeHandler func(beforeInvokeData any, r *channel.Response, invokeErr error, channelID string, chaincodeName string, methodName string, methodArgs []string, noBatch bool, peers ...string) error
)

func (hlf *HLFClient) Request(
Expand All @@ -270,11 +270,9 @@ func (hlf *HLFClient) Request(
return nil, err
}

batchWaiter.Add(1)
go func() {
defer batchWaiter.Done()
batchWaiter.Go(func() {
waitBatchAndPrintContents(notifier)
}()
})
}

printInvokeArgs(methodArgs, chaincodeName, methodName)
Expand Down
4 changes: 2 additions & 2 deletions storage/redis/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (stor *Storage) RemoveAllData(ctx context.Context) error {
return res.Err()
}

func encodeData(data interface{}) ([]byte, error) {
func encodeData(data any) ([]byte, error) {
var bytebuffer bytes.Buffer
e := gob.NewEncoder(&bytebuffer)
if err := e.Encode(data); err != nil {
Expand All @@ -173,7 +173,7 @@ func encodeData(data interface{}) ([]byte, error) {
return bytebuffer.Bytes(), nil
}

func decodeData(data []byte, res interface{}) error {
func decodeData(data []byte, res any) error {
bytebuffer := bytes.NewBuffer(data)
d := gob.NewDecoder(bytebuffer)
if err := d.Decode(res); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/chexec/chexec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var _ = Describe("Robot channel executor tests", func() {
Expect(err).NotTo(HaveOccurred())

var preimages [][]byte
for i := 0; i < 3; i++ {
for range 3 {
txID, err := ntesting.EmitFiat(context.Background(), fiatOwner, user1, 1, ciData.HlfFiatChannel, ciData.HlfFiatChannel)
Expect(err).NotTo(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion test/integration/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/anoideaopen/robot/test/integration

go 1.25.7
go 1.26.0

tool (
github.com/IBM/idemix/tools/idemixgen
Expand Down
2 changes: 1 addition & 1 deletion test/unit/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestBasicBehavior(t *testing.T) {
require.NotNil(t, b)

addBlocks := func(chName string, fbn, bc int) {
for i := 0; i < bc; i++ {
for i := range bc {
if chName == ch1Name {
ok, err := b.AddIfInLimit(chName, &collectordto.BlockData{
BlockNum: uint64(i + fbn),
Expand Down
2 changes: 1 addition & 1 deletion test/unit/chcollector_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func collectNBlocks(b *testing.B, totalCountBlocks int, bufSize uint) {

for i := 0; i < b.N; i++ {
events := make(chan *fab.BlockEvent, totalCountBlocks)
for i := 0; i < totalCountBlocks; i++ {
for range totalCountBlocks {
events <- &fab.BlockEvent{Block: &common.Block{}}
}

Expand Down
14 changes: 7 additions & 7 deletions test/unit/chcollector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestCollectingTheSameBlock(t *testing.T) {
const totalCountBlocks = 2
// add two identical blocks with transactions to the event channel
events := make(chan *fab.BlockEvent, totalCountBlocks)
for i := 0; i < totalCountBlocks; i++ {
for range totalCountBlocks {
events <- &fab.BlockEvent{Block: bltx}
}

Expand Down Expand Up @@ -127,7 +127,7 @@ func TestCollectingTheSameBlockMultiswaps(t *testing.T) {
const totalCountBlocks = 2
// add two identical blocks with transactions to the event channel
events := make(chan *fab.BlockEvent, totalCountBlocks)
for i := 0; i < totalCountBlocks; i++ {
for range totalCountBlocks {
events <- &fab.BlockEvent{Block: bltx}
}

Expand Down Expand Up @@ -178,7 +178,7 @@ func TestCollectingTheSameBlockKeys(t *testing.T) {
const totalCountBlocks = 2
// add two identical blocks with transactions to the event channel
events := make(chan *fab.BlockEvent, totalCountBlocks)
for i := 0; i < totalCountBlocks; i++ {
for range totalCountBlocks {
events <- &fab.BlockEvent{Block: bltx}
}

Expand Down Expand Up @@ -229,7 +229,7 @@ func TestCollectingTheSameBlockMultikeys(t *testing.T) {
const totalCountBlocks = 2
// add two identical blocks with transactions to the event channel
events := make(chan *fab.BlockEvent, totalCountBlocks)
for i := 0; i < totalCountBlocks; i++ {
for range totalCountBlocks {
events <- &fab.BlockEvent{Block: bltx}
}

Expand Down Expand Up @@ -280,7 +280,7 @@ func TestCollectingTheSameBlockSwaps(t *testing.T) {
const totalCountBlocks = 2
// add two identical blocks with transactions to the event channel
events := make(chan *fab.BlockEvent, totalCountBlocks)
for i := 0; i < totalCountBlocks; i++ {
for range totalCountBlocks {
events <- &fab.BlockEvent{Block: bltx}
}

Expand Down Expand Up @@ -323,7 +323,7 @@ func TestSimpleWork(t *testing.T) {

const totalCountBlocks = 100
events := make(chan *fab.BlockEvent, totalCountBlocks)
for i := 0; i < totalCountBlocks; i++ {
for i := range totalCountBlocks {
events <- &fab.BlockEvent{Block: &common.Block{
Header: &common.BlockHeader{
Number: uint64(i),
Expand Down Expand Up @@ -370,7 +370,7 @@ func TestCollectorWorkWithErrors(t *testing.T) {
prsr.callHlp.AddErrMap(prsr.ExtractData, prsrErrors)

events := make(chan *fab.BlockEvent, totalCountBlocks)
for i := 0; i < totalCountBlocks; i++ {
for i := range totalCountBlocks {
events <- &fab.BlockEvent{Block: &common.Block{
Header: &common.BlockHeader{
Number: uint64(i),
Expand Down
6 changes: 3 additions & 3 deletions test/unit/chrobot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func TestWorkWithErrors(t *testing.T) {
//nolint:unparam
func createSrcData(dst, src string, startBlock, countBlocks, countTxOrSwaps, emptyBlockEveryN int) []*collectordto.BlockData {
var res []*collectordto.BlockData
for i := 0; i < countBlocks; i++ {
for i := range countBlocks {
d := &collectordto.BlockData{
BlockNum: uint64(startBlock + i),
Size: 0,
Expand All @@ -283,13 +283,13 @@ func createSrcData(dst, src string, startBlock, countBlocks, countTxOrSwaps, emp
continue
}
if dst == src {
for j := 0; j < countTxOrSwaps; j++ {
for j := range countTxOrSwaps {
tx := make([]byte, 4)
binary.LittleEndian.PutUint32(tx, uint32(i*countTxOrSwaps+j))
d.Txs = append(d.Txs, tx)
}
} else {
for j := 0; j < countTxOrSwaps; j++ {
for range countTxOrSwaps {
d.Swaps = append(d.Swaps, &proto.Swap{
Owner: nil,
Token: "zxcv",
Expand Down
14 changes: 7 additions & 7 deletions test/unit/dto_models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func BenchmarkProtoMarshalVsSize(b *testing.B) {

func generateBatches() []*proto.Batch {
var res []*proto.Batch
for i := 0; i < 1000; i++ {
for range 1000 {
b := &proto.Batch{
TxIDs: generateTxses(),
Swaps: generateSwaps(),
Expand All @@ -67,7 +67,7 @@ func generateBatches() []*proto.Batch {
func generateTxses() [][]byte {
var res [][]byte
count := rnd.Intn(100)
for i := 0; i < count; i++ {
for range count {
res = append(res, generateBytes())
}
return res
Expand All @@ -76,7 +76,7 @@ func generateTxses() [][]byte {
func generateSwaps() []*proto.Swap {
var res []*proto.Swap
count := rnd.Intn(100)
for i := 0; i < count; i++ {
for range count {
s := &proto.Swap{
Id: generateBytes(),
Creator: generateBytes(),
Expand All @@ -96,7 +96,7 @@ func generateSwaps() []*proto.Swap {
func generateMultiSwaps() []*proto.MultiSwap {
var res []*proto.MultiSwap
count := rnd.Intn(100)
for i := 0; i < count; i++ {
for range count {
s := &proto.MultiSwap{
Id: generateBytes(),
Creator: generateBytes(),
Expand All @@ -116,7 +116,7 @@ func generateMultiSwaps() []*proto.MultiSwap {
func generateSwapKeys() []*proto.SwapKey {
var res []*proto.SwapKey
count := rnd.Intn(100)
for i := 0; i < count; i++ {
for range count {
s := &proto.SwapKey{
Id: generateBytes(),
Key: generateString(),
Expand All @@ -129,7 +129,7 @@ func generateSwapKeys() []*proto.SwapKey {
func generateBytes() []byte {
var res []byte
count := rnd.Intn(100)
for i := 0; i < count; i++ {
for range count {
res = append(res, 0)
}
return res
Expand All @@ -142,7 +142,7 @@ func generateString() string {
func generateAssets() []*proto.Asset {
var res []*proto.Asset
count := rnd.Intn(100)
for i := 0; i < count; i++ {
for range count {
s := &proto.Asset{
Group: generateString(),
Amount: generateBytes(),
Expand Down
2 changes: 1 addition & 1 deletion test/unit/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NoTestPutPreimages(t *testing.T) {
amountEmit = 1
)
totalB := oldFiatB
for i := 0; i < countEmits; i++ {
for i := range countEmits {
_, err = ntesting.EmitFiat(ctx, fiatOwner, fiatOwner, amountEmit, ciData.HlfFiatChannel, ciData.HlfFiatChannel)
if err != nil {
l.Infof("emit error: %s", err)
Expand Down
5 changes: 2 additions & 3 deletions test/unit/stub_stor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package unit
import (
"context"
"fmt"
"maps"
"sync"

"github.com/anoideaopen/common-component/testshlp"
Expand Down Expand Up @@ -58,9 +59,7 @@ func cloneChCheckPoints(cp *stordto.ChCheckPoint) *stordto.ChCheckPoint {
MinExecBlockNum: cp.MinExecBlockNum,
}

for k, v := range cp.SrcCollectFromBlockNums {
res.SrcCollectFromBlockNums[k] = v
}
maps.Copy(res.SrcCollectFromBlockNums, cp.SrcCollectFromBlockNums)

return res
}