Skip to content

Promote beta branch #264

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

Merged
merged 47 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ff4d9e8
Add set/clear support in blockNode struct
leventeliu Jan 28, 2019
a2b8db4
Fix bug: bad critical section for multiple values
leventeliu Jan 28, 2019
89bb26e
Remove the `New` method of config struct
leventeliu Jan 29, 2019
2703344
Format license
leventeliu Jan 29, 2019
0857e51
Format imports
leventeliu Jan 29, 2019
e70d0eb
Add cached block setting
leventeliu Jan 29, 2019
4f51f57
Fix test case and other minor fixes
leventeliu Jan 29, 2019
e5bddc0
Move limits to correct section
leventeliu Jan 29, 2019
5f09562
Add metric values
leventeliu Jan 29, 2019
36e8284
Format query strings
leventeliu Jan 29, 2019
97863cc
Merge remote-tracking branch 'origin/beta' into feature/block_cache
leventeliu Jan 29, 2019
be6b10d
Add block cache LRU list
leventeliu Feb 12, 2019
adf6bbd
Use including notation for fetchNodeList method
leventeliu Feb 12, 2019
cea0aee
Rearrange some variable declarations
leventeliu Feb 12, 2019
1474ad3
Remove unused ChainBus field
leventeliu Feb 12, 2019
5d225a2
Fix issue: must provide a positive size for LRU cache
leventeliu Feb 12, 2019
e474e62
Merge remote-tracking branch 'origin/beta' into feature/block_cache
leventeliu Feb 12, 2019
34858f0
Export block cache size field in config
leventeliu Feb 12, 2019
ec33085
Make use of txCount field in blockNode
leventeliu Feb 12, 2019
907b301
Merge pull request #249 from CovenantSQL/feature/beta_block_cache
Feb 17, 2019
bee1bd5
Merge remote-tracking branch 'origin/develop' into feature/beta_merge…
Feb 18, 2019
496efa5
Merge pull request #253 from CovenantSQL/feature/beta_merge_develop
leventeliu Feb 18, 2019
44adc79
Stablize genesis block generation
Feb 13, 2019
fb9d2f7
Remove conflict check
Feb 14, 2019
64c179e
Fix replay block test case
Feb 18, 2019
d9ba4fb
Fix sqlchain createRandomBlock util bug
Feb 18, 2019
d85e3e0
Merge pull request #254 from CovenantSQL/feature/beta_genesis_fork
Feb 18, 2019
d7ee083
Refactor observer to pull mode
Jan 31, 2019
baf3434
Fix bug of observer restart recover
Feb 18, 2019
64f76b5
Add comments for count in ObserverFetchBlock rpc
Feb 18, 2019
65f0d4a
Merge pull request #255 from CovenantSQL/feature/beta_pullModeObserver
Feb 18, 2019
f3fce74
Combine all createRandomBlock funcs to one(exclude sqlchain/xxx_test.go)
laodouya Feb 18, 2019
27fb735
Change sqlchain/xxx_test.go createRandomBlock function to reuse types…
laodouya Feb 18, 2019
b0c46a4
Merge pull request #258 from CovenantSQL/feature/combine_test_funcs
leventeliu Feb 18, 2019
ad06228
Add transaction hash as return value in create/drop
leventeliu Feb 19, 2019
7c9e5d7
Minor fix
leventeliu Feb 19, 2019
970277b
Also wait for creation after transaction is confirmed
leventeliu Feb 19, 2019
ec05168
Merge pull request #259 from CovenantSQL/feature/beta_wait_create_tx
leventeliu Feb 19, 2019
f6f6653
Update dht consensus using gossip method
Feb 19, 2019
c25c9b5
Remove useless block producer leader/follower role check
Feb 19, 2019
8956e11
Fix bug in RegisterNodeToBP feature
Feb 19, 2019
2bf6642
Try all block producer to find locally unknown nodes
Feb 20, 2019
40a75ca
Fix bug in rpcutil not checking FindNodeInBP result
Feb 20, 2019
bf90a9e
Merge pull request #261 from CovenantSQL/feature/beta_dht_no_kayak
auxten Feb 20, 2019
a94b9e4
Merge remote-tracking branch 'origin/beta' into feature/promote_beta
leventeliu Feb 25, 2019
2b66081
Remove imports blank lines
Feb 25, 2019
572b893
Merge branch 'develop' into feature/promote_beta
auxten Feb 25, 2019
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
9 changes: 4 additions & 5 deletions api/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import (
"testing"
"time"

"github.com/pkg/errors"

"github.com/CovenantSQL/CovenantSQL/api"
"github.com/CovenantSQL/CovenantSQL/api/models"

"github.com/gorilla/websocket"
"github.com/pkg/errors"
. "github.com/smartystreets/goconvey/convey"
"github.com/sourcegraph/jsonrpc2"
wsstream "github.com/sourcegraph/jsonrpc2/websocket"

"github.com/CovenantSQL/CovenantSQL/api"
"github.com/CovenantSQL/CovenantSQL/api/models"
)

const (
Expand Down
31 changes: 22 additions & 9 deletions blockproducer/blocknode.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package blockproducer

import (
"sync/atomic"

"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/types"
)
Expand All @@ -27,12 +29,13 @@ type blockNode struct {
count uint32
height uint32
// Cached fields for quick reference
hash hash.Hash
block *types.BPBlock
hash hash.Hash
txCount int
block atomic.Value
}

func newBlockNode(h uint32, b *types.BPBlock, p *blockNode) *blockNode {
return &blockNode{
func newBlockNode(h uint32, b *types.BPBlock, p *blockNode) (node *blockNode) {
node = &blockNode{
parent: p,

count: func() uint32 {
Expand All @@ -43,17 +46,27 @@ func newBlockNode(h uint32, b *types.BPBlock, p *blockNode) *blockNode {
}(),
height: h,

hash: b.SignedHeader.DataHash,
block: b,
hash: b.SignedHeader.DataHash,
txCount: len(b.Transactions),
}
node.block.Store(b)
return
}

func (n *blockNode) load() *types.BPBlock {
return n.block.Load().(*types.BPBlock)
}

func (n *blockNode) clear() {
n.block.Store((*types.BPBlock)(nil))
}

// fetchNodeList returns the block node list within range (from, n.count] from node head n.
// fetchNodeList returns the block node list within range [from, n.count] from node head n.
func (n *blockNode) fetchNodeList(from uint32) (bl []*blockNode) {
if n.count <= from {
if n.count < from {
return
}
bl = make([]*blockNode, n.count-from)
bl = make([]*blockNode, n.count-from+1)
var iter = n
for i := len(bl) - 1; i >= 0; i-- {
bl[i] = iter
Expand Down
6 changes: 3 additions & 3 deletions blockproducer/blocknode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func TestBlockNode(t *testing.T) {
So(n0.count, ShouldEqual, 0)
So(n1.count, ShouldEqual, n0.count+1)

So(n0.fetchNodeList(0), ShouldBeEmpty)
So(n0.fetchNodeList(1), ShouldBeEmpty)
So(n0.fetchNodeList(2), ShouldBeEmpty)
So(n3.fetchNodeList(0), ShouldResemble, []*blockNode{n1, n2, n3})
So(n4p.fetchNodeList(2), ShouldResemble, []*blockNode{n3p, n4p})
So(n0.fetchNodeList(3), ShouldBeEmpty)
So(n3.fetchNodeList(1), ShouldResemble, []*blockNode{n1, n2, n3})
So(n4p.fetchNodeList(3), ShouldResemble, []*blockNode{n3p, n4p})

So(n0.ancestor(1), ShouldBeNil)
So(n3.ancestor(3), ShouldEqual, n3)
Expand Down
21 changes: 12 additions & 9 deletions blockproducer/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * limitations under the License.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package blockproducer
Expand Down Expand Up @@ -44,7 +45,7 @@ func newBranch(
br *branch, err error,
) {
var (
list = headNode.fetchNodeList(baseNode.count)
list = headNode.fetchNodeList(baseNode.count + 1)
inst = &branch{
head: headNode,
preview: baseState.makeCopy(),
Expand All @@ -58,11 +59,12 @@ func newBranch(
}
// Apply new blocks to view and pool
for _, bn := range list {
if len(bn.block.Transactions) > conf.MaxTransactionsPerBlock {
if bn.txCount > conf.MaxTransactionsPerBlock {
return nil, ErrTooManyTransactionsInBlock
}

for _, v := range bn.block.Transactions {
var block = bn.load()
for _, v := range block.Transactions {
var k = v.Hash()
// Check in tx pool
if _, ok := inst.unpacked[k]; ok {
Expand Down Expand Up @@ -127,17 +129,18 @@ func (b *branch) addTx(tx pi.Transaction) {
}

func (b *branch) applyBlock(n *blockNode) (br *branch, err error) {
if !b.head.hash.IsEqual(n.block.ParentHash()) {
var block = n.load()
if !b.head.hash.IsEqual(block.ParentHash()) {
err = ErrParentNotMatch
return
}
var cpy = b.makeArena()

if len(n.block.Transactions) > conf.MaxTransactionsPerBlock {
if n.txCount > conf.MaxTransactionsPerBlock {
return nil, ErrTooManyTransactionsInBlock
}

for _, v := range n.block.Transactions {
for _, v := range block.Transactions {
var k = v.Hash()
// Check in tx pool
if _, ok := cpy.unpacked[k]; ok {
Expand Down Expand Up @@ -259,13 +262,13 @@ func (b *branch) sprint(from uint32) (buff string) {
if i == 0 {
var p = v.parent
buff += fmt.Sprintf("* #%d:%d %s {%d}",
p.height, p.count, p.hash.Short(4), len(p.block.Transactions))
p.height, p.count, p.hash.Short(4), p.txCount)
}
if d := v.height - v.parent.height; d > 1 {
buff += fmt.Sprintf(" <-- (skip %d blocks)", d-1)
}
buff += fmt.Sprintf(" <-- #%d:%d %s {%d}",
v.height, v.count, v.hash.Short(4), len(v.block.Transactions))
v.height, v.count, v.hash.Short(4), v.txCount)
}
return
}
Loading