fix: Upgrade status-go to the most recent version of release branch which contains memory fix

Fix #4990
This commit is contained in:
Michal Iskierko
2024-05-13 12:21:03 +02:00
committed by Michał Iskierko
parent 03d490156a
commit 66cf3d21b9
230 changed files with 30930 additions and 14243 deletions

View File

@@ -10,8 +10,9 @@ var ErrBanUserFromCommunityInvalidCommunityID = errors.New("ban-user-from-commun
var ErrBanUserFromCommunityInvalidUser = errors.New("ban-user-from-community: invalid user id")
type BanUserFromCommunity struct {
CommunityID types.HexBytes `json:"communityId"`
User types.HexBytes `json:"user"`
CommunityID types.HexBytes `json:"communityId"`
User types.HexBytes `json:"user"`
DeleteAllMessages bool `json:"deleteAllMessages"`
}
func (b *BanUserFromCommunity) Validate() error {

View File

@@ -0,0 +1,25 @@
package requests
import (
"errors"
)
var ErrCommunityMemberMessagesCommunityID = errors.New("community member messages: invalid id")
var ErrCommunityMemberMessagesMemberPK = errors.New("community member messages: invalid member PK")
type CommunityMemberMessages struct {
CommunityID string `json:"communityId"`
MemberPublicKey string `json:"memberPublicKey"`
}
func (c *CommunityMemberMessages) Validate() error {
if len(c.CommunityID) == 0 {
return ErrCommunityMemberMessagesCommunityID
}
if len(c.MemberPublicKey) == 0 {
return ErrCommunityMemberMessagesMemberPK
}
return nil
}

View File

@@ -2,7 +2,8 @@ package requests
import (
"errors"
"strconv"
"math"
"math/big"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/protobuf"
@@ -43,8 +44,9 @@ func (p *CreateCommunityTokenPermission) Validate() error {
return ErrCreateCommunityTokenPermissionInvalidTokenCriteria
}
floatAmount, _ := strconv.ParseFloat(c.Amount, 32)
if len(c.ContractAddresses) > 0 && floatAmount == 0 {
var amountBig = new(big.Int)
amountBig.SetString(c.AmountInWei, 10)
if len(c.ContractAddresses) > 0 && amountBig.Cmp(big.NewInt(0)) == 0 {
return ErrCreateCommunityTokenPermissionInvalidTokenCriteria
}
}
@@ -52,6 +54,32 @@ func (p *CreateCommunityTokenPermission) Validate() error {
return nil
}
func (p *CreateCommunityTokenPermission) FillDeprecatedAmount() {
computeErc20AmountFunc := func(amountInWeis string, decimals uint64) string {
bigfloat := new(big.Float)
bigfloat.SetString(amountInWeis)
multiplier := big.NewFloat(math.Pow(10, float64(decimals)))
bigfloat.Quo(bigfloat, multiplier)
return bigfloat.String()
}
for _, criteria := range p.TokenCriteria {
if criteria.AmountInWei == "" {
continue
}
// fill Amount to keep backward compatibility
// Amount format (deprecated): "0.123"
// AmountInWei format: "123000..000"
if criteria.Type == protobuf.CommunityTokenType_ERC20 {
criteria.Amount = computeErc20AmountFunc(criteria.AmountInWei, criteria.Decimals)
} else {
criteria.Amount = criteria.AmountInWei
}
}
}
func (p *CreateCommunityTokenPermission) ToCommunityTokenPermission() protobuf.CommunityTokenPermission {
return protobuf.CommunityTokenPermission{
Type: p.Type,

View File

@@ -0,0 +1,54 @@
package requests
import (
"errors"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/protobuf"
)
var ErrDeleteCommunityMemberMessagesInvalidCommunityID = errors.New("delete-community-member-messages: invalid community id")
var ErrDeleteCommunityMemberMessagesInvalidMemberID = errors.New("delete-community-member-messages: invalid member id")
var ErrDeleteCommunityMemberMessagesInvalidData = errors.New("delete-community-member-messages: invalid data")
var ErrDeleteCommunityMemberMessagesInvalidDeleteAll = errors.New("delete-community-member-messages: invalid delete all setup")
var ErrDeleteCommunityMemberMessagesInvalidDeleteMessagesByID = errors.New("delete-community-member-messages: invalid delete messages by ID setups")
var ErrDeleteCommunityMemberMessagesInvalidMsgID = errors.New("delete-community-member-messages: invalid messages Id")
var ErrDeleteCommunityMemberMessagesInvalidMsgChatID = errors.New("delete-community-member-messages: invalid messages chatId")
type DeleteCommunityMemberMessages struct {
CommunityID types.HexBytes `json:"communityId"`
MemberPubKey string `json:"memberPubKey"`
Messages []*protobuf.DeleteCommunityMemberMessage `json:"messages"`
DeleteAll bool `json:"deleteAll"`
}
func (d *DeleteCommunityMemberMessages) Validate() error {
if len(d.CommunityID) == 0 {
return ErrDeleteCommunityMemberMessagesInvalidCommunityID
}
if len(d.MemberPubKey) == 0 {
return ErrDeleteCommunityMemberMessagesInvalidMemberID
}
if d.Messages != nil && len(d.Messages) > 0 && d.DeleteAll {
return ErrDeleteCommunityMemberMessagesInvalidDeleteAll
}
if (d.Messages == nil || (d.Messages != nil && len(d.Messages) == 0)) && !d.DeleteAll {
return ErrDeleteCommunityMemberMessagesInvalidDeleteMessagesByID
}
if d.Messages != nil {
for _, message := range d.Messages {
if len(message.Id) == 0 {
return ErrDeleteCommunityMemberMessagesInvalidMsgID
}
if len(message.ChatId) == 0 {
return ErrDeleteCommunityMemberMessagesInvalidMsgChatID
}
}
}
return nil
}

View File

@@ -0,0 +1,45 @@
package requests
import (
"bytes"
"errors"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/storenodes"
)
var (
ErrSetCommunityStorenodesEmpty = errors.New("set-community-storenodes: empty payload")
ErrSetCommunityStorenodesTooMany = errors.New("set-community-storenodes: too many")
ErrSetCommunityStorenodesMismatch = errors.New("set-community-storenodes: communityId mismatch")
ErrSetCommunityStorenodesMissingCommunity = errors.New("set-community-storenodes: missing community")
ErrSetCommunityStorenodesBadVersion = errors.New("set-community-storenodes: bad version")
)
type SetCommunityStorenodes struct {
CommunityID types.HexBytes `json:"communityId"`
Storenodes []storenodes.Storenode `json:"storenodes"`
}
func (s *SetCommunityStorenodes) Validate() error {
if s == nil || len(s.Storenodes) == 0 {
return ErrSetCommunityStorenodesEmpty
}
if len(s.Storenodes) > 1 {
// TODO for now only allow one
return ErrSetCommunityStorenodesTooMany
}
if len(s.CommunityID) == 0 {
return ErrSetCommunityStorenodesMissingCommunity
}
for _, sn := range s.Storenodes {
if !bytes.Equal(sn.CommunityID, s.CommunityID) {
return ErrSetCommunityStorenodesMismatch
}
if sn.Version == 0 {
return ErrSetCommunityStorenodesBadVersion
}
// TODO validate address and other fields
}
return nil
}

View File

@@ -0,0 +1,9 @@
package requests
type TogglePeerSyncingRequest struct {
Enabled bool `json:"enabled"`
}
func (a *TogglePeerSyncingRequest) Validate() error {
return nil
}