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

Adding block height reduced by 1 for UTX transactions validation. #1314

Merged
merged 2 commits into from
Feb 7, 2024
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
17 changes: 13 additions & 4 deletions pkg/miner/micro_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package miner
import (
"errors"

"github.com/mr-tron/base58"
"go.uber.org/zap"

"github.com/wavesplatform/gowaves/pkg/proto"
"github.com/wavesplatform/gowaves/pkg/services"
"github.com/wavesplatform/gowaves/pkg/state"
"github.com/wavesplatform/gowaves/pkg/types"
"go.uber.org/zap"
)

const (
Expand Down Expand Up @@ -42,11 +44,13 @@ func (a *MicroMiner) Micro(minedBlock *proto.Block, rest proto.MiningLimits, key
// block changed, exit
return nil, nil, rest, StateChangedErr
}
zap.S().Debugf("[MICRO MINER] Top block ID '%s'", topBlock.BlockID())

height, err := a.state.Height()
if err != nil {
return nil, nil, rest, err
}
zap.S().Debugf("[MICRO MINER] Height %d", height)

parentTimestamp := topBlock.Timestamp
if height > 1 {
Expand Down Expand Up @@ -82,7 +86,7 @@ func (a *MicroMiner) Micro(minedBlock *proto.Block, rest proto.MiningLimits, key
continue
}

// In miner we pack transactions from UTX into new block.
// In the miner we pack transactions from UTX into new block.
// We should accept failed transactions here.
err = s.ValidateNextTx(t.T, minedBlock.Timestamp, parentTimestamp, minedBlock.Version, true)
if state.IsTxCommitmentError(err) {
Expand Down Expand Up @@ -118,10 +122,15 @@ func (a *MicroMiner) Micro(minedBlock *proto.Block, rest proto.MiningLimits, key
return nil, nil, rest, NoTransactionsErr
}

zap.S().Debugf("micro_miner top block sig %s", a.state.TopBlock().BlockSignature)

transactions := make([]proto.Transaction, len(appliedTransactions))
for i, appliedTx := range appliedTransactions {
if zap.S().Level() <= zap.DebugLevel {
if id, idErr := appliedTx.T.GetID(a.scheme); idErr != nil {
zap.S().Errorf("Failed to get transaction ID: %v", idErr)
} else {
zap.S().Debugf("[MICRO MINER] Appending transaction '%s'", base58.Encode(id))
}
}
transactions[i] = appliedTx.T
}
newTransactions := minedBlock.Transactions.Join(transactions)
Expand Down
2 changes: 1 addition & 1 deletion pkg/state/appender.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ func (a *txAppender) validateNextTx(tx proto.Transaction, currentTimestamp, pare
parentTimestamp: parentTimestamp,
blockID: block.BlockID(),
blockVersion: version,
blockchainHeight: blockInfo.Height,
blockchainHeight: blockInfo.Height - 1,
rideV5Activated: rideV5Activated,
rideV6Activated: rideV6Activated,
blockRewardDistribution: blockRewardDistribution,
Expand Down
Loading