Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
9 changes: 6 additions & 3 deletions .semgrep/rules/if-incorrect-nil-err-return.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ rules:
- id: if-incorrect-nil-err-return
languages: [ go ]
severity: WARNING
message: |
WARNING: A local variable '$ERR' is checked for nil, but a different variable is returned.
Ensure that the returned variable is the one that was checked or properly wrapped!
message: "WARNING: A local variable '$ERR' is checked for nil, but a different variable is returned.
Ensure that the returned variable is the one that was checked or properly wrapped!"
metadata:
category: correctness
technology:
- semgrep
patterns:
- metavariable-regex:
metavariable: $ERR
Expand Down
9 changes: 6 additions & 3 deletions .semgrep/rules/if-inplace-func-incorrect-nil-err-return.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ rules:
- id: if-inplace-func-incorrect-nil-err-return
languages: [ go ]
severity: WARNING
message: |
WARNING: A local variable '$ERR' is checked for nil, but a different variable is returned.
Ensure that the returned variable is the one that was checked or properly wrapped!
message: "WARNING: A local variable '$ERR' is checked for nil, but a different variable is returned.
Ensure that the returned variable is the one that was checked or properly wrapped!"
metadata:
category: correctness
technology:
- semgrep
patterns:
- metavariable-regex:
metavariable: $ERR
Expand Down
6 changes: 6 additions & 0 deletions .semgrepignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@

# Ignore testdata folders
pkg/state/testdata/

# Ignore integration tests config files
itests/config/template.conf

Comment thread Fixed
Comment on lines +23 to +24

Check warning

Code scanning / Semgrep OSS

Semgrep Finding: generic.ci.audit.changed-semgrepignore.changed-semgrepignore Warning

itests/config/template.conf has been added to the .semgrepignore list of ignored paths. Someone from app-sec may want to audit these changes.
# Ignore generated protobuf files
**/*.pb.go
6 changes: 3 additions & 3 deletions itests/clients/net_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ func (c *NetClient) SendHandshake() {
}

func (c *NetClient) SendMessage(m proto.Message) {
//TODO: It is possible now to detect if the peer closed the connection during the write.
// We can use this to check for expected disconnects, for example,
// when we send a malformed transactions to a node.
_, err := m.WriteTo(c.s)
if err != nil {
//TODO: It is possible now to detect if the peer closed the connection during the write.
// We can use this to check for expected disconnects, for example,
// when we send a malformed transactions to a node.
c.t.Logf("[%s] Failed to send message of type %T to %s node at %q: %v",
time.Now().Format(time.RFC3339Nano), m, c.impl.String(), c.s.RemoteAddr(), err)
}
Expand Down
17 changes: 10 additions & 7 deletions itests/clients/node_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ func (c *NodesClients) SynchronizedWavesBalances(
if err != nil {
t.Logf("Errors while requesting balances: %v", err)
}
const retryInterval = 1 * time.Second
timer := time.NewTimer(retryInterval)
defer timer.Stop()
for {
commonHeight := mostCommonHeight(sbs)
toRetry := make([]proto.WavesAddress, 0, len(addresses))
Expand All @@ -302,22 +305,22 @@ func (c *NodesClients) SynchronizedWavesBalances(
}

t.Logf("Heights differ, retrying for %d addresses", len(toRetry))

timer.Reset(retryInterval)
select {
case <-ctx.Done():
case <-time.After(1 * time.Second): // Wait for a second before retrying
t.Logf("No results because of context error: %v", ctx.Err())
return NewSynchronisedBalances()
case <-timer.C: // Wait for a second (retryInterval) before retrying
}
rr, rrErr := c.requestAvailableBalancesForAddresses(ctx, toRetry)
if rrErr != nil {
t.Logf("Errors while requesting balances: %v", rrErr)
}
// Update the map with retry results.
maps.Copy(sbs, rr)
if errors.Is(ctx.Err(), context.Canceled) { // handle context cancellation
t.Logf("Context cancelled, returning empty result")
return NewSynchronisedBalances()
}
if errors.Is(ctx.Err(), context.DeadlineExceeded) { // handle context deadline exceeded
t.Logf("Deadline exceeded, returning empty result")
if errors.Is(ctx.Err(), context.Canceled) || errors.Is(ctx.Err(), context.DeadlineExceeded) {
t.Logf("No results because of context error: %v", ctx.Err())
return NewSynchronisedBalances()
}
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/blockchaininfo/blockchaininfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/wavesplatform/gowaves/pkg/blockchaininfo"
"github.com/wavesplatform/gowaves/pkg/proto"
)
Expand Down Expand Up @@ -64,12 +65,15 @@ func TestChangesGenerationNewEntries(t *testing.T) {

previousDataEntries := []proto.DataEntry{
&proto.BinaryDataEntry{Key: previousFirstKey,
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Value: []byte("base64:AAAAAAAQYVwAAAAAADDSCpJJsd11jrOMW7AS/AHIMIDQ" +
"XjqmFyhDuGt2RPNvmcCXAVTy/URmfMOj7GNweXnZpzidmxHfPBfcP5A=")}, // height 3199498.
&proto.BinaryDataEntry{Key: previousSecondKey,
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Value: []byte("base64:AAAAAAAQYywAAAAAADDSQBBubtiRmKwtaNFF1TrBhsfBu" +
"61fj3qiSrtyu1/kLLAlAVQp5GtuF7Hxji8CQ9SFOEZLLUv88nvIgg8=")}, // height 3199552.
&proto.BinaryDataEntry{Key: previousThirdKey,
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Value: []byte("base64:AAAAAAAQZEUAAAAAADDSZeUUyashoWjUKurzA/wVU5prm" +
"68CambvjIo1ESLoLuAaAVRaS4vOsPl9cxvg7aeRj7RFZQzdpmvV/+A=")}, // height 3199589.
}
Expand Down Expand Up @@ -133,12 +137,15 @@ func TestChangesGenerationContainsPrevious(t *testing.T) {

previousDataEntries := []proto.DataEntry{
&proto.BinaryDataEntry{Key: previousFirstKey,
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Value: []byte("base64:AAAAAAAQYVwAAAAAADDSCpJJsd11jrOMW7AS/AHIMIDQXj" +
"qmFyhDuGt2RPNvmcCXAVTy/URmfMOj7GNweXnZpzidmxHfPBfcP5A=")}, // height 3199498.
&proto.BinaryDataEntry{Key: previousSecondKey,
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Value: []byte("base64:AAAAAAAQYywAAAAAADDSQBBubtiRmKwtaNFF1TrBhsfBu61" +
"fj3qiSrtyu1/kLLAlAVQp5GtuF7Hxji8CQ9SFOEZLLUv88nvIgg8=")}, // height 3199552.
&proto.BinaryDataEntry{Key: previousThirdKey,
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Value: []byte("base64:AAAAAAAQZEUAAAAAADDSZeUUyashoWjUKurzA/wVU5prm68Ca" +
"mbvjIo1ESLoLuAaAVRaS4vOsPl9cxvg7aeRj7RFZQzdpmvV/+A=")}, // height 3199589.
}
Expand All @@ -150,16 +157,20 @@ func TestChangesGenerationContainsPrevious(t *testing.T) {

currentDataEntries := []proto.DataEntry{
&proto.BinaryDataEntry{Key: previousFirstKey,
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Value: []byte("base64:AAAAAAAQYVwAAAAAADDSCpJJsd11jrOMW7AS/A" +
"HIMIDQXjqmFyhDuGt2RPNvmcCXAVTy/URmfMOj7GNweXnZpzidmxHfPBfcP5A=")}, // height 3199498.
&proto.BinaryDataEntry{Key: previousSecondKey,
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Value: []byte("base64:AAAAAAAQYywAAAAAADDSQBBubtiRmKwtaNFF1T" +
"rBhsfBu61fj3qiSrtyu1/kLLAlAVQp5GtuF7Hxji8CQ9SFOEZLLUv88nvIgg8=")}, // height 3199552.
&proto.BinaryDataEntry{Key: previousThirdKey,
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Value: []byte("base64:AAAAAAAQZEUAAAAAADDSZeUUyashoWjUKurzA/wV" +
"U5prm68CambvjIo1ESLoLuAaAVRaS4vOsPl9cxvg7aeRj7RFZQzdpmvV/+A=")}, // height 3199589.

&proto.BinaryDataEntry{Key: currentFirstKey,
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Value: []byte("base64:AAAAAAAQZKkAAAAAADDSb6xEaq4RsFQruGNeGdoo" +
"PmtLBnlERR15qzc/mcKcQ461AVQp5GtuF7Hxji8CQ9SFOEZLLUv88nvIgg8=")}, // height 3199599.
&proto.BinaryDataEntry{Key: currentSecondKey,
Expand Down
2 changes: 2 additions & 0 deletions pkg/client/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func TestUtils_ScriptCompileCode(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, resp)
assert.Equal(t, &UtilsScriptCompile{
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Script: "base64:AAIFAAAAAAAAACMIAhIAIgFpIgVhc3NldCIHYXNzZXRJZCICdHgiBnZlcmlmeQAAAAAAAAABAAAAAWEBAAAABGNhbGwAAAAABAAAAAFiCQAEQwAAAAcCAAAABUFzc2V0AgAAAAAAAAAAAAAAAAEAAAAAAAAAAAAGBQAAAAR1bml0AAAAAAAAAAAABAAAAAFjCQAEOAAAAAEFAAAAAWIJAARMAAAAAgkBAAAAC0JpbmFyeUVudHJ5AAAAAgIAAAADYmluAQAAAAAJAARMAAAAAgkBAAAADEJvb2xlYW5FbnRyeQAAAAICAAAABGJvb2wGCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACAgAAAANpbnQAAAAAAAAAAAEJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgIAAAADc3RyAgAAAAAJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQIAAAADc3RyCQAETAAAAAIFAAAAAWIJAARMAAAAAgkBAAAAB1JlaXNzdWUAAAADBQAAAAFjAAAAAAAAAAABBwkABEwAAAACCQEAAAAEQnVybgAAAAIFAAAAAWMAAAAAAAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWEAAAAGY2FsbGVyAAAAAAAAAAABBQAAAAFjBQAAAANuaWwAAAABAAAAAWQBAAAAAWUAAAAACQAB9AAAAAMIBQAAAAFkAAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAABZAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAFkAAAAD3NlbmRlclB1YmxpY0tleS+y6UM=",
Complexity: 202,
VerifierComplexity: 202,
Expand Down Expand Up @@ -187,6 +188,7 @@ func TestUtils_ScriptEstimate(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, resp)
assert.Equal(t, &UtilsScriptEstimate{
// nosemgrep: generic.secrets.security.detected-telegram-bot-api-key.detected-telegram-bot-api-key
Script: "base64:AAIFAAAAAAAAAAQIAhIAAAAAAAAAAAEAAAABaQEAAAAEY2FsbAAAAAAEAAAABWFzc2V0CQAEQwAAAAcCAAAABUFzc2V0AgAAAAAAAAAAAAAAAAEAAAAAAAAAAAAGBQAAAAR1bml0AAAAAAAAAAAABAAAAAdhc3NldElkCQAEOAAAAAEFAAAABWFzc2V0CQAETAAAAAIJAQAAAAtCaW5hcnlFbnRyeQAAAAICAAAAA2JpbgEAAAAACQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACAgAAAARib29sBgkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAADaW50AAAAAAAAAAABCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAICAAAAA3N0cgIAAAAACQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAECAAAAA3N0cgkABEwAAAACBQAAAAVhc3NldAkABEwAAAACCQEAAAAHUmVpc3N1ZQAAAAMFAAAAB2Fzc2V0SWQAAAAAAAAAAAEHCQAETAAAAAIJAQAAAARCdXJuAAAAAgUAAAAHYXNzZXRJZAAAAAAAAAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIAAAAAAAAAAAEFAAAAB2Fzc2V0SWQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5ZN0QxA==",
ScriptText: "DApp(DAppMeta(2,Vector(CallableFuncSignature(<ByteString@5137f21 size=0 contents=\"\">,UnknownFieldSet(Map()))),Vector(),Vector(),UnknownFieldSet(Map())),List(),List(CallableFunction(CallableAnnotation(i),FUNC(call,List(),LET_BLOCK(LET(asset,FUNCTION_CALL(Native(1091),List(Asset, , 1, 0, true, REF(unit), 0))),LET_BLOCK(LET(assetId,FUNCTION_CALL(Native(1080),List(REF(asset)))),FUNCTION_CALL(Native(1100),List(FUNCTION_CALL(User(BinaryEntry),List(bin, )), FUNCTION_CALL(Native(1100),List(FUNCTION_CALL(User(BooleanEntry),List(bool, true)), FUNCTION_CALL(Native(1100),List(FUNCTION_CALL(User(IntegerEntry),List(int, 1)), FUNCTION_CALL(Native(1100),List(FUNCTION_CALL(User(StringEntry),List(str, )), FUNCTION_CALL(Native(1100),List(FUNCTION_CALL(User(DeleteEntry),List(str)), FUNCTION_CALL(Native(1100),List(REF(asset), FUNCTION_CALL(Native(1100),List(FUNCTION_CALL(User(Reissue),List(REF(assetId), 1, false)), FUNCTION_CALL(Native(1100),List(FUNCTION_CALL(User(Burn),List(REF(assetId), 1)), FUNCTION_CALL(Native(1100),List(FUNCTION_CALL(User(ScriptTransfer),List(GETTER(REF(i),caller), 1, REF(assetId))), REF(nil)))))))))))))))))))))))),Some(VerifierFunction(VerifierAnnotation(tx),FUNC(verify,List(),FUNCTION_CALL(Native(500),List(GETTER(REF(tx),bodyBytes), FUNCTION_CALL(Native(401),List(GETTER(REF(tx),proofs), 0)), GETTER(REF(tx),senderPublicKey)))))))",
Complexity: 202,
Expand Down
9 changes: 6 additions & 3 deletions pkg/crypto/ecdsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,24 @@ func TestECDSASign(t *testing.T) {
isValidSignature bool
}{
{
message: "foo",
message: "foo",
// nosemgrep: generic.secrets.gitleaks.generic-api-key.generic-api-key
privateKeyHex: "289c2857d4598e37fb9647507e47a309d6133539bf21a8b9cb6df88fd5232032",
publicKeyHex: "047db227d7094ce215c3a0f57e1bcc732551fe351f94249471934567e0f5dc1bf795962b8cccb87a2eb56b29fbe37d614e2f4c3c45b789ae4f1f51f4cb21972ffd",
signatureHex: "d155e94305af7e07dd8c32873e5c03cb95c9e05960ef85be9c07f671da58c73718c19adc397a211aa9e87e519e2038c5a3b658618db335f74f800b8e0cfeef4401",
isValidSignature: true,
},
{
message: "bar",
message: "bar",
// nosemgrep: generic.secrets.gitleaks.generic-api-key.generic-api-key
privateKeyHex: "289c2857d4598e37fb9647507e47a309d6133539bf21a8b9cb6df88fd5232032",
publicKeyHex: "047db227d7094ce215c3a0f57e1bcc732551fe351f94249471934567e0f5dc1bf795962b8cccb87a2eb56b29fbe37d614e2f4c3c45b789ae4f1f51f4cb21972ffd",
signatureHex: "d127ddb88b9be7e79fe046a2055706f8bde67506baeb69989e0eb57be097f93926bb7f1236ed1a66f6445cf48fb547bec72927ae4724af44e78c303d01a002c600",
isValidSignature: true,
},
{
message: "foo",
message: "foo",
// nosemgrep: generic.secrets.gitleaks.generic-api-key.generic-api-key
privateKeyHex: "289c2857d4598e37fb9647507e47a309d6133539bf21a8b9cb6df88fd5232032",
publicKeyHex: "047db227d7094ce215c3a0f57e1bcc732551fe351f94249471934567e0f5dc1bf795962b8cccb87a2eb56b29fbe37d614e2f4c3c45b789ae4f1f51f4cb21972ffd",
signatureHex: "f155e94305af7e07dd8c32873e5c03cb95c9e05960ef85be9c07f671da58c73718c19adc397a211aa9e87e519e2038c5a3b658618db335f74f800b8e0cfeef4401",
Expand Down
5 changes: 4 additions & 1 deletion pkg/networking/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,14 @@ func (s *Session) readMessagePayload(hdr Header, conn io.Reader) error {
// keepaliveLoop is a long-running goroutine that periodically sends a Ping message to keep the connection alive.
func (s *Session) keepaliveLoop() error {
defer s.drain()
timer := time.NewTimer(s.config.keepAliveInterval)
defer timer.Stop()
for {
timer.Reset(s.config.keepAliveInterval)
select {
case <-s.ctx.Done():
return s.ctx.Err()
case <-time.After(s.config.keepAliveInterval):
case <-timer.C:
if s.established.Load() {
// Get actual Ping message from Protocol.
p, pErr := s.config.protocol.Ping()
Expand Down
4 changes: 2 additions & 2 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func (a *Node) serveIncomingPeers(ctx context.Context) error {
for {
conn, acErr := l.Accept()
if acErr != nil {
if ctx.Err() != nil { // context has been canceled
return nil
if errors.Is(err, net.ErrClosed) && errors.Is(ctx.Err(), context.Canceled) {
return nil // Listener closed due to context cancellation this is fine.
}
slog.Error("Failed to accept new peer", logging.Error(acErr))
continue
Expand Down
2 changes: 1 addition & 1 deletion pkg/node/peers/score_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
}
// The peer was not found in the larges group, time to change the peer.
// Select the random peer from the group and return it along with a new score value.
i := rand.IntN(len(g.peers)) // #nosec: it's ok to use math/rand/v2 here
i := rand.IntN(len(g.peers)) //nolint: gosec // it's ok to use math/rand/v2 here.

Check failure

Code scanning / gosec

Use of weak random number generator (math/rand or math/rand/v2 instead of crypto/rand) Error

Use of weak random number generator (math/rand or math/rand/v2 instead of crypto/rand)
heap.Push(s.groups, g)
return g.peers[i], g.score
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/proto/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ func (r *aliasRecipient) String() string {
return r.al.String()
}

func (r *aliasRecipient) MarshalJSON() ([]byte, error) {
func (r aliasRecipient) MarshalJSON() ([]byte, error) {
return r.al.MarshalJSON()
}

Expand Down Expand Up @@ -726,7 +726,7 @@ func (r *wavesAddressRecipient) ToProtobuf() (*g.Recipient, error) {
return &g.Recipient{Recipient: &g.Recipient_PublicKeyHash{PublicKeyHash: r.addr.Body()}}, nil
}

func (r *wavesAddressRecipient) MarshalJSON() ([]byte, error) {
func (r wavesAddressRecipient) MarshalJSON() ([]byte, error) {
return r.addr.MarshalJSON()
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/proto/block_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ type txSnapshotJSON struct {
AccountData NonNullableSlice[DataEntriesSnapshot] `json:"accountData"`
}

func (s *txSnapshotJSON) MarshalJSON() ([]byte, error) {
func (s txSnapshotJSON) MarshalJSON() ([]byte, error) {
if s.ApplicationStatus == unknownTransactionStatus {
return nil, errors.New("empty transaction status")
}
type shadowed txSnapshotJSON
return json.Marshal((*shadowed)(s))
return json.Marshal((shadowed)(s))
}

func (s *txSnapshotJSON) UnmarshalJSON(bytes []byte) error {
Expand Down
3 changes: 2 additions & 1 deletion pkg/proto/eth_crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
btcECDSA "github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/pkg/errors"

"github.com/wavesplatform/gowaves/pkg/crypto"
)

Expand Down Expand Up @@ -128,7 +129,7 @@ func (es *EthereumSignature) UnmarshalBinary(data []byte) error {
return nil
}

func (es *EthereumSignature) MarshalJSON() ([]byte, error) {
func (es EthereumSignature) MarshalJSON() ([]byte, error) {
sig := es.Bytes()
return HexBytes(sig).MarshalJSON()
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/proto/eth_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/mr-tron/base58/base58"
"github.com/pkg/errors"
"github.com/umbracle/fastrlp"

"github.com/wavesplatform/gowaves/pkg/crypto"
)

Expand All @@ -34,7 +35,7 @@ func (esk *EthereumPrivateKey) EthereumPublicKey() *EthereumPublicKey {
type EthereumPublicKey btcec.PublicKey

// MarshalJSON marshal EthereumPublicKey in hex encoding.
func (epk *EthereumPublicKey) MarshalJSON() ([]byte, error) {
func (epk EthereumPublicKey) MarshalJSON() ([]byte, error) {
data := epk.SerializeXYCoordinates()
return HexBytes(data).MarshalJSON()
}
Expand Down
1 change: 1 addition & 0 deletions pkg/proto/ethabi/parsing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"

"github.com/stretchr/testify/require"

"github.com/wavesplatform/gowaves/pkg/crypto"
"github.com/wavesplatform/gowaves/pkg/ride/meta"
)
Expand Down
12 changes: 4 additions & 8 deletions pkg/proto/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,8 @@
return -1
} else if a == b {
return 0
} else {
return 1
}
return 1
}
x := cmp(a[i].major, a[j].major)
y := cmp(a[i].minor, a[j].minor)
Expand All @@ -560,12 +559,10 @@
return true
} else if y == 0 {
return z < 0
} else {
return false
}
} else {
return false
}
return false
}

type TCPAddr net.TCPAddr
Expand Down Expand Up @@ -968,7 +965,7 @@
if err != nil {
return PeerInfo{}, err
}
n := rand.IntN(len(ips)) // #nosec: it's ok to use math/rand/v2 here
n := rand.IntN(len(ips)) //nolint: gosec // it's ok to use math/rand/v2 here.

Check failure

Code scanning / gosec

Use of weak random number generator (math/rand or math/rand/v2 instead of crypto/rand) Error

Use of weak random number generator (math/rand or math/rand/v2 instead of crypto/rand)
ip := ips[n] // Select random IPv4 from the list
return PeerInfo{
Addr: ip,
Expand Down Expand Up @@ -1391,9 +1388,8 @@
}
if block.Version >= ProtobufBlockVersion {
return &PBBlockMessage{bts}, nil
} else {
return &BlockMessage{bts}, nil
}
return &BlockMessage{bts}, nil
}

// BlockMessage represents Block message
Expand Down
6 changes: 3 additions & 3 deletions pkg/proto/transactions_with_proofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2708,12 +2708,12 @@ func (tx *CreateAliasWithProofs) UnmarshalJSONWithScheme(data []byte, scheme Sch
return nil
}

func (tx *CreateAliasWithProofs) MarshalJSON() ([]byte, error) {
func (tx CreateAliasWithProofs) MarshalJSON() ([]byte, error) {
type shadowed CreateAliasWithProofs
tmp := struct {
Alias string `json:"alias"`
*shadowed
}{tx.Alias.Alias, (*shadowed)(tx)}
shadowed
}{tx.Alias.Alias, (shadowed)(tx)}
return json.Marshal(tmp)
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/proto/transactions_with_sig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2247,12 +2247,12 @@ func (tx *CreateAliasWithSig) UnmarshalJSONWithScheme(data []byte, scheme Scheme
return nil
}

func (tx *CreateAliasWithSig) MarshalJSON() ([]byte, error) {
func (tx CreateAliasWithSig) MarshalJSON() ([]byte, error) {
type shadowed CreateAliasWithSig
tmp := struct {
Alias string `json:"alias"`
*shadowed
}{tx.Alias.Alias, (*shadowed)(tx)}
shadowed
}{tx.Alias.Alias, (shadowed)(tx)}
return json.Marshal(tmp)
}

Expand Down
Loading
Loading