aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/db/memory_test.go3
-rw-r--r--core/syncer/consensus.go1
-rw-r--r--core/test/block-revealer.go13
-rw-r--r--core/types/block.go35
-rw-r--r--core/types/block_test.go18
-rw-r--r--core/types/vote.go2
-rw-r--r--core/utils/crypto.go7
-rw-r--r--core/utils/crypto_test.go8
8 files changed, 11 insertions, 76 deletions
diff --git a/core/db/memory_test.go b/core/db/memory_test.go
index b210c8d..b0bfb16 100644
--- a/core/db/memory_test.go
+++ b/core/db/memory_test.go
@@ -46,7 +46,6 @@ func (s *MemBackedDBTestSuite) SetupSuite() {
Position: types.Position{
Height: 0,
},
- Acks: common.NewSortedHashes(common.Hashes{}),
}
s.b01 = &types.Block{
ProposerID: s.v0,
@@ -55,7 +54,6 @@ func (s *MemBackedDBTestSuite) SetupSuite() {
Position: types.Position{
Height: 1,
},
- Acks: common.NewSortedHashes(common.Hashes{s.b00.Hash}),
}
s.b02 = &types.Block{
ProposerID: s.v0,
@@ -64,7 +62,6 @@ func (s *MemBackedDBTestSuite) SetupSuite() {
Position: types.Position{
Height: 2,
},
- Acks: common.NewSortedHashes(common.Hashes{s.b01.Hash}),
}
}
diff --git a/core/syncer/consensus.go b/core/syncer/consensus.go
index 538913f..7399373 100644
--- a/core/syncer/consensus.go
+++ b/core/syncer/consensus.go
@@ -337,7 +337,6 @@ func (con *Consensus) buildEmptyBlock(b *types.Block, parent *types.Block) {
b.Witness.Height = parent.Witness.Height
b.Witness.Data = make([]byte, len(parent.Witness.Data))
copy(b.Witness.Data, parent.Witness.Data)
- b.Acks = common.NewSortedHashes(common.Hashes{parent.Hash})
}
// setupConfigs is called by SyncBlocks with blocks from compaction chain. In
diff --git a/core/test/block-revealer.go b/core/test/block-revealer.go
index 90b3d3e..7516e6c 100644
--- a/core/test/block-revealer.go
+++ b/core/test/block-revealer.go
@@ -31,19 +31,6 @@ var (
ErrNotValidCompactionChain = errors.New("not valid compaction chain")
)
-// isAllAckingBlockRevealed is a helper to check if all acking blocks of
-// one block are revealed.
-func isAllAckingBlockRevealed(
- b *types.Block, revealed map[common.Hash]struct{}) bool {
-
- for _, ack := range b.Acks {
- if _, exists := revealed[ack]; !exists {
- return false
- }
- }
- return true
-}
-
// loadAllBlocks is a helper to load all blocks from db.BlockIterator.
func loadAllBlocks(iter db.BlockIterator) (
blocks map[common.Hash]*types.Block, err error) {
diff --git a/core/types/block.go b/core/types/block.go
index 8c3e510..2b23e96 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -23,7 +23,6 @@ import (
"bytes"
"fmt"
"io"
- "sort"
"time"
"github.com/dexon-foundation/dexon/rlp"
@@ -125,17 +124,16 @@ type Witness struct {
// Block represents a single event broadcasted on the network.
type Block struct {
- ProposerID NodeID `json:"proposer_id"`
- ParentHash common.Hash `json:"parent_hash"`
- Hash common.Hash `json:"hash"`
- Position Position `json:"position"`
- Timestamp time.Time `json:"timestamp"`
- Acks common.SortedHashes `json:"acks"`
- Payload []byte `json:"payload"`
- PayloadHash common.Hash `json:"payload_hash"`
- Witness Witness `json:"witness"`
- Finalization FinalizationResult `json:"finalization"`
- Signature crypto.Signature `json:"signature"`
+ ProposerID NodeID `json:"proposer_id"`
+ ParentHash common.Hash `json:"parent_hash"`
+ Hash common.Hash `json:"hash"`
+ Position Position `json:"position"`
+ Timestamp time.Time `json:"timestamp"`
+ Payload []byte `json:"payload"`
+ PayloadHash common.Hash `json:"payload_hash"`
+ Witness Witness `json:"witness"`
+ Finalization FinalizationResult `json:"finalization"`
+ Signature crypto.Signature `json:"signature"`
CRSSignature crypto.Signature `json:"crs_signature"`
}
@@ -146,7 +144,6 @@ type rlpBlock struct {
Hash common.Hash
Position Position
Timestamp *rlpTimestamp
- Acks common.SortedHashes
Payload []byte
PayloadHash common.Hash
Witness *Witness
@@ -164,7 +161,6 @@ func (b *Block) EncodeRLP(w io.Writer) error {
Hash: b.Hash,
Position: b.Position,
Timestamp: &rlpTimestamp{b.Timestamp},
- Acks: b.Acks,
Payload: b.Payload,
PayloadHash: b.PayloadHash,
Witness: &b.Witness,
@@ -185,7 +181,6 @@ func (b *Block) DecodeRLP(s *rlp.Stream) error {
Hash: dec.Hash,
Position: dec.Position,
Timestamp: dec.Timestamp.Time,
- Acks: dec.Acks,
Payload: dec.Payload,
PayloadHash: dec.PayloadHash,
Witness: *dec.Witness,
@@ -216,8 +211,6 @@ func (b *Block) Clone() (bcopy *Block) {
bcopy.Witness.Data = make([]byte, len(b.Witness.Data))
copy(bcopy.Witness.Data, b.Witness.Data)
bcopy.Timestamp = b.Timestamp
- bcopy.Acks = make(common.SortedHashes, len(b.Acks))
- copy(bcopy.Acks, b.Acks)
bcopy.Payload = make([]byte, len(b.Payload))
copy(bcopy.Payload, b.Payload)
bcopy.PayloadHash = b.PayloadHash
@@ -239,14 +232,6 @@ func (b *Block) IsEmpty() bool {
return b.ProposerID.Hash == common.Hash{}
}
-// IsAcking checks if a block acking another by it's hash.
-func (b *Block) IsAcking(hash common.Hash) bool {
- idx := sort.Search(len(b.Acks), func(i int) bool {
- return bytes.Compare(b.Acks[i][:], hash[:]) >= 0
- })
- return !(idx == len(b.Acks) || b.Acks[idx] != hash)
-}
-
// ByHash is the helper type for sorting slice of blocks by hash.
type ByHash []*Block
diff --git a/core/types/block_test.go b/core/types/block_test.go
index 1dd83a9..03eef35 100644
--- a/core/types/block_test.go
+++ b/core/types/block_test.go
@@ -70,10 +70,6 @@ func (s *BlockTestSuite) createRandomBlock() *Block {
Round: rand.Uint64(),
Height: rand.Uint64(),
},
- Acks: common.NewSortedHashes(common.Hashes{
- common.NewRandomHash(),
- common.NewRandomHash(),
- }),
Timestamp: time.Now().UTC(),
Witness: Witness{
Height: rand.Uint64(),
@@ -180,20 +176,6 @@ func (s *BlockTestSuite) TestGenesisBlock() {
s.False(b2.IsGenesis())
}
-func (s *BlockTestSuite) TestIsAcking() {
- // This test case would check if types.Block.IsAcking works
- ack0 := common.NewRandomHash()
- acks0 := common.Hashes{
- ack0,
- common.NewRandomHash(),
- common.NewRandomHash(),
- }
- b0 := &Block{Acks: common.NewSortedHashes(acks0)}
- s.True(b0.IsAcking(ack0))
- s.False(b0.IsAcking(common.Hash{}))
- s.False(b0.IsAcking(common.NewRandomHash()))
-}
-
func (s *BlockTestSuite) TestClone() {
b1 := *s.createRandomBlock()
b2 := *b1.Clone()
diff --git a/core/types/vote.go b/core/types/vote.go
index 6481eb4..c4a625e 100644
--- a/core/types/vote.go
+++ b/core/types/vote.go
@@ -66,7 +66,7 @@ type Vote struct {
}
func (v *Vote) String() string {
- return fmt.Sprintf("Vote{BP:%s %s Period:%d Type:%d Hash:%s}",
+ return fmt.Sprintf("Vote{VP:%s %s Period:%d Type:%d Hash:%s}",
v.ProposerID.String()[:6],
v.Position, v.Period, v.Type, v.BlockHash.String()[:6])
}
diff --git a/core/utils/crypto.go b/core/utils/crypto.go
index fe67a95..f5343ca 100644
--- a/core/utils/crypto.go
+++ b/core/utils/crypto.go
@@ -37,12 +37,6 @@ func hashWitness(witness *types.Witness) (common.Hash, error) {
// HashBlock generates hash of a types.Block.
func HashBlock(block *types.Block) (common.Hash, error) {
hashPosition := hashPosition(block.Position)
- // Handling Block.Acks.
- binaryAcks := make([][]byte, len(block.Acks))
- for idx, ack := range block.Acks {
- binaryAcks[idx] = ack[:]
- }
- hashAcks := crypto.Keccak256Hash(binaryAcks...)
binaryTimestamp, err := block.Timestamp.UTC().MarshalBinary()
if err != nil {
return common.Hash{}, err
@@ -56,7 +50,6 @@ func HashBlock(block *types.Block) (common.Hash, error) {
block.ProposerID.Hash[:],
block.ParentHash[:],
hashPosition[:],
- hashAcks[:],
binaryTimestamp[:],
block.PayloadHash[:],
binaryWitness[:])
diff --git a/core/utils/crypto_test.go b/core/utils/crypto_test.go
index f1fa9b6..1077277 100644
--- a/core/utils/crypto_test.go
+++ b/core/utils/crypto_test.go
@@ -37,11 +37,9 @@ type CryptoTestSuite struct {
var myNID = types.NodeID{Hash: common.NewRandomHash()}
func (s *CryptoTestSuite) prepareBlock(prevBlock *types.Block) *types.Block {
- acks := common.Hashes{}
now := time.Now().UTC()
if prevBlock == nil {
return &types.Block{
- Acks: common.NewSortedHashes(acks),
Timestamp: now,
Finalization: types.FinalizationResult{
Timestamp: time.Now(),
@@ -52,7 +50,6 @@ func (s *CryptoTestSuite) prepareBlock(prevBlock *types.Block) *types.Block {
s.Require().NotEqual(prevBlock.Hash, common.Hash{})
return &types.Block{
ParentHash: prevBlock.Hash,
- Acks: common.NewSortedHashes(acks),
Timestamp: now,
Position: types.Position{
Height: prevBlock.Position.Height + 1,
@@ -116,11 +113,6 @@ func (s *CryptoTestSuite) TestBlockSignature() {
}
s.NoError(VerifyBlockSignature(block))
}
- // Modify Block.Acks and verify signature again.
- for _, block := range blocks {
- block.Acks = append(block.Acks, common.NewRandomHash())
- s.Error(VerifyBlockSignature(block))
- }
}
func (s *CryptoTestSuite) TestVoteSignature() {