Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SF-1.8.4 #6634

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5631405
SF-v1.6.0 initial test
raduchis Sep 5, 2023
5ac599c
Merge branch 'rc/v1.6.0' into SF-v1.6.0
raduchis Sep 6, 2023
91774dc
set singlesigner to disabled
raduchis Sep 7, 2023
075e960
do not check peerSignature
raduchis Sep 8, 2023
797b712
Merge branch 'rc/v1.6.0' into SF-v1.6.0
raduchis Sep 8, 2023
19d6b88
added epochsFastForward
raduchis Sep 11, 2023
e6fb9d2
Merge remote-tracking branch 'origin/rc/v1.6.0' into SF-v1.6.0
raduchis Sep 18, 2023
8d41d1c
Merge branch 'rc/v1.6.0' into SF-v1.6.0
raduchis Nov 10, 2023
4cd3a71
Merge branch 'rc/v1.6.0' into SF-v1.6.0
raduchis Nov 21, 2023
f1ac25d
Merge branch 'master' into SF-v1.6.0
raduchis Jan 15, 2024
475ee29
Merge remote-tracking branch 'origin/new-vm-common' into SF-v1.6.0
raduchis Jan 16, 2024
d8d459e
MaxTxNonceDeltaAllowed = 100000
raduchis Jan 17, 2024
67ad2eb
Merge remote-tracking branch 'origin/migrate-data-trie-fix' into SF-v…
raduchis Jan 25, 2024
72201bf
Merge remote-tracking branch 'origin/rc/v1.7.0' into SF-v1.7.0
raduchis Jan 30, 2024
140d553
Merge branch 'rc/v1.7.0' into SF-v1.7.0
raduchis Apr 12, 2024
79621d8
Merge branch 'rc/v1.7.0' into SF-v1.7.0
raduchis Apr 22, 2024
1f8a378
Merge branch 'rc/v1.7.0' into SF-v1.7.0
raduchis Apr 23, 2024
8cc7cf9
Merge branch 'rc/v1.7.0' into SF-v1.7.0
raduchis May 9, 2024
3dfbc41
Merge branch 'master' into SF-v1.7.0
raduchis May 21, 2024
1d40241
Merge branch 'master' into SF-v1.7.0
raduchis May 29, 2024
b2a3668
Merge branch 'master' into SF-1.7.0
raduchis Jul 2, 2024
24ceef3
Merge branch 'master' into SF-1.7.0
raduchis Aug 20, 2024
d205e62
Merge branch 'master' into SF-1.7.0
raduchis Nov 25, 2024
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
2 changes: 1 addition & 1 deletion common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const DisabledShardIDAsObserver = uint32(0xFFFFFFFF) - 7

// MaxTxNonceDeltaAllowed specifies the maximum difference between an account's nonce and a received transaction's nonce
// in order to mark the transaction as valid.
const MaxTxNonceDeltaAllowed = 100
const MaxTxNonceDeltaAllowed = 100000

// MaxBulkTransactionSize specifies the maximum size of one bulk with txs which can be send over the network
// TODO convert this const into a var and read it from config when this code moves to another binary
Expand Down
4 changes: 2 additions & 2 deletions consensus/spos/bls/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ const srStartEndTime = 0.05
const srBlockStartTime = 0.05

// srBlockEndTime specifies the end time, from the total time of the round, of Subround Block
const srBlockEndTime = 0.25
const srBlockEndTime = 0.45

// srSignatureStartTime specifies the start time, from the total time of the round, of Subround Signature
const srSignatureStartTime = 0.25
const srSignatureStartTime = 0.45

// srSignatureEndTime specifies the end time, from the total time of the round, of Subround Signature
const srSignatureEndTime = 0.85
Expand Down
18 changes: 0 additions & 18 deletions consensus/spos/consensusMessageValidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ func (cmv *consensusMessageValidator) checkConsensusMessageValidity(cnsMsg *cons
len(cnsMsg.PubKey))
}

if len(cnsMsg.Signature) != cmv.signatureSize {
return fmt.Errorf("%w : received signature from consensus topic has an invalid size: %d",
ErrInvalidSignatureSize,
len(cnsMsg.Signature))
}

isNodeInEligibleList := cmv.consensusState.IsNodeInEligibleList(string(cnsMsg.PubKey))
if !isNodeInEligibleList {
return fmt.Errorf("%w : received message from consensus topic has an invalid public key: %s",
Expand Down Expand Up @@ -392,18 +386,6 @@ func (cmv *consensusMessageValidator) checkMessageWithFinalInfoValidity(cnsMsg *
len(cnsMsg.PubKeysBitmap))
}

if len(cnsMsg.AggregateSignature) != cmv.signatureSize {
return fmt.Errorf("%w : received aggregate signature from consensus topic has an invalid size: %d",
ErrInvalidSignatureSize,
len(cnsMsg.AggregateSignature))
}

if len(cnsMsg.LeaderSignature) != cmv.signatureSize {
return fmt.Errorf("%w : received leader signature from consensus topic has an invalid size: %d",
ErrInvalidSignatureSize,
len(cnsMsg.LeaderSignature))
}

return nil
}

Expand Down
36 changes: 6 additions & 30 deletions factory/crypto/cryptoComponents.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
disabledCrypto "github.com/multiversx/mx-chain-crypto-go/signing/disabled"
disabledSig "github.com/multiversx/mx-chain-crypto-go/signing/disabled/singlesig"
"github.com/multiversx/mx-chain-crypto-go/signing/ed25519"
"github.com/multiversx/mx-chain-crypto-go/signing/ed25519/singlesig"
"github.com/multiversx/mx-chain-crypto-go/signing/mcl"
mclSig "github.com/multiversx/mx-chain-crypto-go/signing/mcl/singlesig"
"github.com/multiversx/mx-chain-crypto-go/signing/secp256k1"
Expand Down Expand Up @@ -153,20 +152,21 @@ func (ccf *cryptoComponentsFactory) Create() (*cryptoComponents, error) {
}

txSignKeyGen := signing.NewKeyGenerator(ed25519.NewEd25519())
txSingleSigner := &singlesig.Ed25519Signer{}
processingSingleSigner, err := ccf.createSingleSigner(false)
txSingleSigner := &disabledSig.DisabledSingleSig{}

processingSingleSigner, err := ccf.createSingleSigner(true)
if err != nil {
return nil, err
}

interceptSingleSigner, err := ccf.createSingleSigner(ccf.importModeNoSigCheck)
interceptSingleSigner, err := ccf.createSingleSigner(true)
if err != nil {
return nil, err
}

p2pSingleSigner := &secp256k1SinglerSig.Secp256k1Signer{}

multiSigner, err := ccf.createMultiSignerContainer(blockSignKeyGen, ccf.importModeNoSigCheck)
multiSigner, err := ccf.createMultiSignerContainer(blockSignKeyGen, true)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -492,36 +492,12 @@ func (ccf *cryptoComponentsFactory) processAllHandledKeys(keygen crypto.KeyGener
return handledPrivateKeys, nil
}

func (ccf *cryptoComponentsFactory) processPrivatePublicKey(keygen crypto.KeyGenerator, encodedSk []byte, pkString string, index int) ([]byte, error) {
func (ccf *cryptoComponentsFactory) processPrivatePublicKey(_ crypto.KeyGenerator, encodedSk []byte, _ string, index int) ([]byte, error) {
skBytes, err := hex.DecodeString(string(encodedSk))
if err != nil {
return nil, fmt.Errorf("%w for encoded secret key, key index %d", err, index)
}

pkBytes, err := ccf.validatorPubKeyConverter.Decode(pkString)
if err != nil {
return nil, fmt.Errorf("%w for encoded public key %s, key index %d", err, pkString, index)
}

sk, err := keygen.PrivateKeyFromByteArray(skBytes)
if err != nil {
return nil, fmt.Errorf("%w secret key, key index %d", err, index)
}

pk := sk.GeneratePublic()
pkGeneratedBytes, err := pk.ToByteArray()
if err != nil {
return nil, fmt.Errorf("%w while generating public key bytes, key index %d", err, index)
}

if !bytes.Equal(pkGeneratedBytes, pkBytes) {
return nil, fmt.Errorf("public keys mismatch, read %s, generated %s, key index %d",
pkString,
ccf.validatorPubKeyConverter.SilentEncode(pkBytes, log),
index,
)
}

return skBytes, nil
}

Expand Down
3 changes: 3 additions & 0 deletions factory/peerSignatureHandler/peerSignatureHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func NewPeerSignatureHandler(
// VerifyPeerSignature verifies the signature associated with the public key. It first checks the cache for the public key,
// and if it is not present, it will recompute the signature.
func (psh *peerSignatureHandler) VerifyPeerSignature(pk []byte, pid core.PeerID, signature []byte) error {
if true {
return nil
}
if len(pk) == 0 {
return crypto.ErrInvalidPublicKey
}
Expand Down
14 changes: 3 additions & 11 deletions keysManagement/managedPeersHolder.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,8 @@ func generateNodeName(providedNodeName string, index int) string {
// It errors if the generated public key is already contained by the struct
// It will auto-generate some fields like the machineID and pid
func (holder *managedPeersHolder) AddManagedPeer(privateKeyBytes []byte) error {
privateKey, err := holder.keyGenerator.PrivateKeyFromByteArray(privateKeyBytes)
if err != nil {
return fmt.Errorf("%w for provided bytes %s", err, hex.EncodeToString(privateKeyBytes))
}

publicKey := privateKey.GeneratePublic()
publicKeyBytes, err := publicKey.ToByteArray()
if err != nil {
return fmt.Errorf("%w for provided bytes %s", err, hex.EncodeToString(privateKeyBytes))
}
sk, _ := holder.keyGenerator.GeneratePair()
publicKeyBytes := privateKeyBytes

p2pPrivateKey, p2pPublicKey := holder.p2pKeyGenerator.GeneratePair()

Expand Down Expand Up @@ -179,7 +171,7 @@ func (holder *managedPeersHolder) AddManagedPeer(privateKeyBytes []byte) error {
pInfo.handler = common.NewRedundancyHandler()
pInfo.pid = pid
pInfo.p2pPrivateKeyBytes = p2pPrivateKeyBytes
pInfo.privateKey = privateKey
pInfo.privateKey = sk
holder.data[string(publicKeyBytes)] = pInfo
holder.pids[pid] = struct{}{}

Expand Down
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ func (n *Node) ValidateTransaction(tx *transaction.Transaction) error {
return err
}

txValidator, intTx, err := n.commonTransactionValidation(tx, n.processComponents.WhiteListerVerifiedTxs(), n.processComponents.WhiteListHandler(), true)
txValidator, intTx, err := n.commonTransactionValidation(tx, n.processComponents.WhiteListerVerifiedTxs(), n.processComponents.WhiteListHandler(), false)
if err != nil {
return err
}
Expand Down
9 changes: 0 additions & 9 deletions process/block/headerValidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ func (h *headerValidator) IsHeaderConstructionValid(currHeader, prevHeader data.
return process.ErrBlockHashDoesNotMatch
}

if !bytes.Equal(currHeader.GetPrevRandSeed(), prevHeader.GetRandSeed()) {
log.Trace("header random seed does not match",
"shard", currHeader.GetShardID(),
"local header random seed", prevHeader.GetRandSeed(),
"received header with prev random seed", currHeader.GetPrevRandSeed(),
)
return process.ErrRandSeedDoesNotMatch
}

return nil
}

Expand Down
77 changes: 77 additions & 0 deletions process/block/metablock.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"encoding/hex"
"fmt"
"math/big"
"strconv"
"strings"
"sync"
"time"

Expand All @@ -22,10 +24,13 @@
"github.com/multiversx/mx-chain-go/process/block/helpers"
"github.com/multiversx/mx-chain-go/process/block/processedMb"
"github.com/multiversx/mx-chain-go/state"
"github.com/multiversx/mx-chain-go/update"
"github.com/multiversx/mx-chain-go/vm"
logger "github.com/multiversx/mx-chain-logger-go"
)

const firstHeaderNonce = uint64(1)
const minRoundModulus = uint64(4)

var _ process.BlockProcessor = (*metaProcessor)(nil)

Expand All @@ -44,6 +49,9 @@
shardBlockFinality uint32
chRcvAllHdrs chan bool
headersCounter *headersCounter
nrEpochsChanges int
roundsModulus uint64
shouldStartBootstrap bool

Check failure on line 54 in process/block/metablock.go

View workflow job for this annotation

GitHub Actions / golangci linter

field `shouldStartBootstrap` is unused (unused)

Check failure on line 54 in process/block/metablock.go

View workflow job for this annotation

GitHub Actions / golangci linter

field `shouldStartBootstrap` is unused (unused)
}

// NewMetaProcessor creates a new metaProcessor object
Expand Down Expand Up @@ -179,6 +187,9 @@

mp.shardsHeadersNonce = &sync.Map{}

mp.nrEpochsChanges = 0
mp.roundsModulus = 20

return &mp, nil
}

Expand Down Expand Up @@ -407,6 +418,8 @@
return err
}

mp.ForceStart(header)

return nil
}

Expand Down Expand Up @@ -771,6 +784,8 @@

mp.requestHandler.SetEpoch(metaHdr.GetEpoch())

mp.ForceStart(metaHdr)

return metaHdr, body, nil
}

Expand Down Expand Up @@ -2545,3 +2560,65 @@

return metaBlock
}

func (mp *metaProcessor) ForceStart(metaHdr *block.MetaBlock) {
forceEpochTrigger := mp.epochStartTrigger.(update.EpochHandler)

txBlockTxs := mp.txCoordinator.GetAllCurrentUsedTxs(block.TxBlock)

for _, tx := range txBlockTxs {
if bytes.Compare(tx.GetRcvAddr(), vm.ValidatorSCAddress) == 0 {

Check failure on line 2570 in process/block/metablock.go

View workflow job for this annotation

GitHub Actions / golangci linter

S1004: should use bytes.Equal(tx.GetRcvAddr(), vm.ValidatorSCAddress) instead (gosimple)

Check failure on line 2570 in process/block/metablock.go

View workflow job for this annotation

GitHub Actions / golangci linter

S1004: should use bytes.Equal(tx.GetRcvAddr(), vm.ValidatorSCAddress) instead (gosimple)
tokens := strings.Split(string(tx.GetData()), "@")
if len(tokens) == 0 {
continue
}
done := false
switch tokens[0] {
case "epochsFastForward":
{
if len(tokens) != 3 {
log.Error("epochsFastForward", "invalid data", string(tx.GetData()))
continue
}
mp.epochsFastForward(metaHdr, tokens)
done = true
}
}

if done {
break
}
}
}

if !check.IfNil(forceEpochTrigger) {
if metaHdr.GetRound()%mp.roundsModulus == 0 && mp.nrEpochsChanges > 0 {
forceEpochTrigger.ForceEpochStart(metaHdr.GetRound())
mp.nrEpochsChanges--
log.Debug("forcing epoch start", "round", metaHdr.GetRound(), "epoch", metaHdr.GetEpoch(), "still remaining epoch changes", mp.nrEpochsChanges, "rounds modulus", mp.roundsModulus)
}
}
}

func (mp *metaProcessor) epochsFastForward(metaHdr *block.MetaBlock, tokens []string) {
epochs, err := strconv.ParseInt(tokens[1], 10, 64)
if err != nil {
log.Error("epochfastforward", "epochs could not be parsed", tokens[1])
}

roundsPerEpoch, err := strconv.ParseInt(tokens[2], 10, 64)
if err != nil {
log.Error("epochfastforward", "rounds could not be parsed", tokens[2])
}
roundsPerEpochUint := uint64(roundsPerEpoch)

if roundsPerEpochUint < minRoundModulus {
log.Warn("epochfastforward rounds per epoch too small", "rounds", roundsPerEpoch, "minRoundModulus", minRoundModulus)
roundsPerEpochUint = minRoundModulus
}

mp.nrEpochsChanges = int(epochs)
mp.roundsModulus = roundsPerEpochUint

log.Warn("epochfastforward - forcing epoch start", "round", metaHdr.GetRound(), "epoch", metaHdr.GetEpoch(), "still remaining epoch changes", mp.nrEpochsChanges, "rounds modulus", mp.roundsModulus)
}
17 changes: 0 additions & 17 deletions process/heartbeat/interceptedPeerAuthentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,6 @@ func (ipa *interceptedPeerAuthentication) CheckValidity() error {
}

// Verify payload signature
err = ipa.signaturesHandler.Verify(ipa.peerAuthentication.Payload, ipa.peerId, ipa.peerAuthentication.PayloadSignature)
if err != nil {
return err
}

// Verify payload
err = ipa.payloadValidator.ValidateTimestamp(ipa.payload.Timestamp)
if err != nil {
return err
}

// Verify message bls signature
err = ipa.peerSignatureHandler.VerifyPeerSignature(ipa.peerAuthentication.Pubkey, ipa.peerId, ipa.peerAuthentication.Signature)
if err != nil {
return err
}

log.Trace("interceptedPeerAuthentication received valid data")

return nil
Expand Down
6 changes: 6 additions & 0 deletions process/transaction/baseProcess.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ func (txProc *baseTxProcessor) verifyGuardian(tx *transaction.Transaction, accou
if check.IfNil(account) {
return nil
}

// no check for guardian signature
if true {
return nil
}

isTransactionGuarded := txProc.txVersionChecker.IsGuardedTransaction(tx)
if !account.IsGuarded() {
if isTransactionGuarded {
Expand Down
Loading