diff --git a/block.go b/block.go index af3bf6b2..52842b0d 100644 --- a/block.go +++ b/block.go @@ -4,8 +4,6 @@ package dbft type Block[H Hash] interface { // Hash returns block hash. Hash() H - - Version() uint32 // PrevHash returns previous block hash. PrevHash() H // MerkleRoot returns a merkle root of the transaction hashes. diff --git a/context.go b/context.go index 15eb2b85..370e8913 100644 --- a/context.go +++ b/context.go @@ -38,7 +38,6 @@ type Context[H Hash] struct { MyIndex int // PrimaryIndex is an index of the primary node in the current epoch. PrimaryIndex uint - Version uint32 // PrevHash is a hash of the previous block. PrevHash H diff --git a/dbft_test.go b/dbft_test.go index 48209e9d..f123b2a8 100644 --- a/dbft_test.go +++ b/dbft_test.go @@ -855,7 +855,7 @@ func newBlockFromContext(ctx *dbft.Context[crypto.Uint256]) dbft.Block[crypto.Ui if ctx.TransactionHashes == nil { return nil } - block := block.NewBlock(ctx.Timestamp, ctx.BlockIndex, ctx.PrevHash, ctx.Version, ctx.Nonce, ctx.TransactionHashes) + block := block.NewBlock(ctx.Timestamp, ctx.BlockIndex, ctx.PrevHash, ctx.Nonce, ctx.TransactionHashes) return block } diff --git a/internal/block/block.go b/internal/block/block.go index ddbf4266..a68b72a2 100644 --- a/internal/block/block.go +++ b/internal/block/block.go @@ -32,11 +32,6 @@ type ( } ) -// Version implements Block interface. -func (b neoBlock) Version() uint32 { - return b.base.Version -} - // PrevHash implements Block interface. func (b *neoBlock) PrevHash() crypto.Uint256 { return b.base.PrevHash @@ -73,16 +68,19 @@ func (b *neoBlock) SetTransactions(txx []dbft.Transaction[crypto.Uint256]) { } // NewBlock returns new block. -func NewBlock(timestamp uint64, index uint32, prevHash crypto.Uint256, version uint32, nonce uint64, txHashes []crypto.Uint256) dbft.Block[crypto.Uint256] { +func NewBlock(timestamp uint64, index uint32, prevHash crypto.Uint256, nonce uint64, txHashes []crypto.Uint256) dbft.Block[crypto.Uint256] { block := new(neoBlock) block.base.Timestamp = uint32(timestamp / 1000000000) block.base.Index = index - // NextConsensus information is not provided by dBFT context, it's an implementation-specific field, - // and thus, should be managed outside the dBFT library. For simulation simplicity, let's assume - // that NextConsensus is filled by every CN separately and is not verified. + + // NextConsensus and Version information is not provided by dBFT context, + // these are implementation-specific fields, and thus, should be managed outside the + // dBFT library. For simulation simplicity, let's assume that these fields are filled + // by every CN separately and is not verified. block.base.NextConsensus = crypto.Uint160{1, 2, 3} + block.base.Version = 0 + block.base.PrevHash = prevHash - block.base.Version = version block.base.ConsensusData = nonce if len(txHashes) != 0 { diff --git a/internal/block/block_test.go b/internal/block/block_test.go index 96f98035..fce0ce92 100644 --- a/internal/block/block_test.go +++ b/internal/block/block_test.go @@ -26,9 +26,6 @@ func TestNeoBlock_Setters(t *testing.T) { b.consensusData = 123 assert.EqualValues(t, 123, b.ConsensusData()) - b.base.Version = 42 - assert.EqualValues(t, 42, b.Version()) - b.base.PrevHash = crypto.Uint256{3, 7} assert.Equal(t, crypto.Uint256{3, 7}, b.PrevHash()) diff --git a/internal/simulation/main.go b/internal/simulation/main.go index 387007f3..75ce3fd1 100644 --- a/internal/simulation/main.go +++ b/internal/simulation/main.go @@ -114,7 +114,7 @@ func newBlockFromContext(ctx *dbft.Context[crypto.Uint256]) dbft.Block[crypto.Ui if ctx.TransactionHashes == nil { return nil } - block := block.NewBlock(ctx.Timestamp, ctx.BlockIndex, ctx.PrevHash, ctx.Version, ctx.Nonce, ctx.TransactionHashes) + block := block.NewBlock(ctx.Timestamp, ctx.BlockIndex, ctx.PrevHash, ctx.Nonce, ctx.TransactionHashes) return block }