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

Implement stacktrie to improve RLP/hashing performance #244

Merged
merged 11 commits into from
Feb 13, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion blockchain/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/gogo/protobuf/proto"

bcproto "github.com/kardiachain/go-kardia/proto/kardiachain/blockchain"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
)

Expand Down Expand Up @@ -83,7 +84,7 @@ func ValidateMsg(pb proto.Message) error {
return fmt.Errorf("invalid height")
}
case *bcproto.BlockResponse:
_, err := types.BlockFromProto(msg.Block)
_, err := types.BlockFromProto(msg.Block, trie.NewStackTrie(nil))
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion blockchain/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

"github.com/kardiachain/go-kardia/lib/common"
"github.com/kardiachain/go-kardia/trie"

"github.com/gogo/protobuf/proto"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -82,7 +83,7 @@ func TestBcStatusResponseMessageValidateBasic(t *testing.T) {

// nolint:lll // ignore line length in tests
func TestBlockchainMessageVectors(t *testing.T) {
block := types.NewBlock(&types.Header{Height: 3}, []*types.Transaction{TestTx}, nil, nil)
block := types.NewBlock(&types.Header{Height: 3}, []*types.Transaction{TestTx}, nil, nil, trie.NewStackTrie(nil))
//block.Version.Block = 11 // overwrite updated protocol version

bpb, err := block.ToProto()
Expand Down
3 changes: 2 additions & 1 deletion blockchain/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/kardiachain/go-kardia/kai/state/cstate"
"github.com/kardiachain/go-kardia/lib/p2p"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
)

Expand All @@ -28,7 +29,7 @@ type params struct {

// makePcBlock makes an empty block.
func makePcBlock(height uint64) *types.Block {
return types.NewBlock(&types.Header{Height: height}, nil, nil, nil)
return types.NewBlock(&types.Header{Height: height}, nil, nil, nil, trie.NewStackTrie(nil))
}

// makeState takes test parameters and creates a specific processor state.
Expand Down
3 changes: 2 additions & 1 deletion blockchain/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/kardiachain/go-kardia/lib/p2p"
ksync "github.com/kardiachain/go-kardia/lib/sync"
bcproto "github.com/kardiachain/go-kardia/proto/kardiachain/blockchain"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
)

Expand Down Expand Up @@ -493,7 +494,7 @@ func (r *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {

case *bcproto.BlockResponse:
r.mtx.RLock()
bi, err := types.BlockFromProto(msg.Block)
bi, err := types.BlockFromProto(msg.Block, trie.NewStackTrie(nil))
if err != nil {
r.logger.Error("error transitioning block from protobuf", "err", err)
return
Expand Down
5 changes: 3 additions & 2 deletions blockchain/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/kardiachain/go-kardia/mainchain/tx_pool"
bcproto "github.com/kardiachain/go-kardia/proto/kardiachain/blockchain"
kaiproto "github.com/kardiachain/go-kardia/proto/kardiachain/types"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
kaitime "github.com/kardiachain/go-kardia/types/time"
)
Expand Down Expand Up @@ -466,14 +467,14 @@ func makeBlock(height uint64, state cstate.LatestBlockState, lastCommit *types.C
ValidatorsHash: state.Validators.Hash(),
NextValidatorsHash: state.NextValidators.Hash(),
ProposerAddress: state.Validators.Validators[0].Address,
}, makeTxs(height), lastCommit, nil)
}, makeTxs(height), lastCommit, nil, trie.NewStackTrie(nil))
return block
}

//func makeBlock(height uint64, state cstate.LatestBlockState, lastCommit *types.Commit) *types.Block {
// block := types.NewBlock(&types.Header{
// Height: height,
// }, makeTxs(height), lastCommit, nil)
// }, makeTxs(height), lastCommit, nil, trie.NewStackTrie(nil))
// return block
//}

Expand Down
3 changes: 2 additions & 1 deletion blockchain/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/kardiachain/go-kardia/configs"
"github.com/kardiachain/go-kardia/kai/state/cstate"
"github.com/kardiachain/go-kardia/lib/p2p"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
)

Expand Down Expand Up @@ -1327,7 +1328,7 @@ func TestScSelectPeer(t *testing.T) {

// makeScBlock makes an empty block.
func makeScBlock(height uint64) *types.Block {
return types.NewBlock(&types.Header{Height: height}, nil, nil, nil)
return types.NewBlock(&types.Header{Height: height}, nil, nil, nil, trie.NewStackTrie(nil))
}

// used in place of assert.Equal(t, want, actual) to avoid failures due to
Expand Down
3 changes: 2 additions & 1 deletion consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"github.com/kardiachain/go-kardia/lib/p2p"
"github.com/kardiachain/go-kardia/lib/service"
kproto "github.com/kardiachain/go-kardia/proto/kardiachain/types"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
ktime "github.com/kardiachain/go-kardia/types/time"
)
Expand Down Expand Up @@ -941,7 +942,7 @@ func (cs *ConsensusState) addProposalBlockPart(msg *BlockPartMessage, peerID p2p
if err != nil {
return added, err
}
block, err := types.BlockFromProto(pbb)
block, err := types.BlockFromProto(pbb, trie.NewStackTrie(nil))
if err != nil {
return added, err
}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/kardiachain/go-kardia
go 1.14

require (
github.com/VictoriaMetrics/fastcache v1.5.7 // indirect
github.com/VictoriaMetrics/fastcache v1.5.7
github.com/Workiva/go-datastructures v1.0.52
github.com/allegro/bigcache v1.2.1 // indirect
github.com/aristanetworks/goarista v0.0.0-20190712234253-ed1100a1c015
github.com/btcsuite/btcd v0.21.0-beta
github.com/cespare/cp v1.1.1 // indirect
github.com/cespare/cp v1.1.1
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set v1.7.1
github.com/docker/docker v17.12.0-ce-rc1.0.20200531234253-77e06fda0c94+incompatible // indirect
Expand All @@ -22,7 +22,7 @@ require (
github.com/golang/protobuf v1.4.3
github.com/google/cel-go v0.3.2
github.com/google/go-cmp v0.5.2 // indirect
github.com/google/uuid v1.0.0 // indirect
github.com/google/uuid v1.0.0
github.com/gorilla/mux v1.7.3
github.com/gorilla/websocket v1.4.2
github.com/gtank/merlin v0.1.1
Expand All @@ -37,7 +37,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.8.0
github.com/prometheus/tsdb v0.10.0
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/rjeczalik/notify v0.9.2
github.com/rs/cors v1.7.0
github.com/sasha-s/go-deadlock v0.2.0
github.com/shirou/gopsutil v2.20.5+incompatible
Expand Down
11 changes: 1 addition & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,6 @@ golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200311171314-f7b00557c8c4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 h1:phUcVbl53swtrUN8kQEXFhUxPlIlWyBfKmidCu7P95o=
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -527,8 +525,6 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.3.0 h1:VWL6FNY2bEEmsGVKabSlHu5Irp34xmMRoqb/9lF9lxk=
golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
Expand All @@ -542,6 +538,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand All @@ -562,7 +559,6 @@ golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -574,21 +570,16 @@ golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
Expand Down
3 changes: 2 additions & 1 deletion kai/state/cstate/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ package cstate
import (
"fmt"

"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
)

func validateBlock(evidencePool EvidencePool, store Store, state LatestBlockState, block *types.Block) error {
// Validate internal consistency
if err := block.ValidateBasic(); err != nil {
if err := block.ValidateBasic(trie.NewStackTrie(nil)); err != nil {
return err
}

Expand Down
3 changes: 2 additions & 1 deletion kai/storage/kvstore/accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/kardiachain/go-kardia/lib/log"
"github.com/kardiachain/go-kardia/lib/rlp"
kproto "github.com/kardiachain/go-kardia/proto/kardiachain/types"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
)

Expand Down Expand Up @@ -563,7 +564,7 @@ func ReadBlock(db kaidb.Reader, height uint64) *types.Block {
panic(fmt.Sprintf("Error reading block: %v", err))
}

block, err := types.BlockFromProto(pbb)
block, err := types.BlockFromProto(pbb, trie.NewStackTrie(nil))
if err != nil {
panic(fmt.Errorf("error from proto block: %w", err))
}
Expand Down
3 changes: 2 additions & 1 deletion kai/storage/kvstore/accessors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/kardiachain/go-kardia/kai/kaidb/memorydb"
"github.com/kardiachain/go-kardia/lib/common"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
)

Expand Down Expand Up @@ -71,7 +72,7 @@ func TestBlockStorage(t *testing.T) {
TxHash: types.EmptyRootHash,
LastCommitHash: lastCommit.Hash(),
}
block := types.NewBlock(header, nil, lastCommit, nil)
block := types.NewBlock(header, nil, lastCommit, nil, trie.NewStackTrie(nil))
partsSet := block.MakePartSet(types.BlockPartSizeBytes)

// Check that no entries are in a pristine database
Expand Down
10 changes: 6 additions & 4 deletions mainchain/blockchain/block_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/kardiachain/go-kardia/mainchain/staking/misc"
stypes "github.com/kardiachain/go-kardia/mainchain/staking/types"
"github.com/kardiachain/go-kardia/mainchain/tx_pool"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
)

Expand Down Expand Up @@ -175,9 +176,10 @@ func (bo *BlockOperations) CommitBlockTxsIfNotFound(block *types.Block, lastComm

// SaveBlock saves the given block, blockParts, and seenCommit to the underlying storage.
// seenCommit: The +2/3 precommits that were seen which committed at height.
// If all the nodes restart after committing a block,
// we need this to reload the precommits to catch-up nodes to the
// most recent height. Otherwise they'd stall at H-1.
//
// If all the nodes restart after committing a block,
// we need this to reload the precommits to catch-up nodes to the
// most recent height. Otherwise they'd stall at H-1.
func (bo *BlockOperations) SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit) {
if block == nil {
common.PanicSanity("BlockOperations try to save a nil block")
Expand Down Expand Up @@ -248,7 +250,7 @@ func (bo *BlockOperations) newHeader(time time.Time, height uint64, numTxs uint6

// newBlock creates new block from given data.
func (bo *BlockOperations) newBlock(header *types.Header, txs []*types.Transaction, commit *types.Commit, ev []types.Evidence) *types.Block {
block := types.NewBlock(header, txs, commit, ev)
block := types.NewBlock(header, txs, commit, ev, trie.NewStackTrie(nil))
return block
}

Expand Down
13 changes: 7 additions & 6 deletions mainchain/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
kmath "github.com/kardiachain/go-kardia/lib/math"
"github.com/kardiachain/go-kardia/mainchain/staking"
kaiproto "github.com/kardiachain/go-kardia/proto/kardiachain/types"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
)

Expand Down Expand Up @@ -138,10 +139,10 @@ func (e *GenesisMismatchError) Error() string {
// SetupGenesisBlock writes or updates the genesis block in db.
// The block that will be used is:
//
// genesis == nil genesis != nil
// +------------------------------------------
// db has no genesis | main-net default | genesis
// db has genesis | from DB | genesis (if compatible)
// genesis == nil genesis != nil
// +------------------------------------------
// db has no genesis | main-net default | genesis
// db has genesis | from DB | genesis (if compatible)
//
// The returned chain configuration is never nil.
func SetupGenesisBlock(logger log.Logger, db types.StoreDB, genesis *Genesis, staking *staking.StakingSmcUtil) (*configs.ChainConfig, common.Hash, error) {
Expand Down Expand Up @@ -247,7 +248,7 @@ func (g *Genesis) ToBlock(logger log.Logger, db kaidb.Database, staking *staking
head.GasLimit = configs.GenesisGasLimit
}

block := types.NewBlock(head, nil, &types.Commit{}, nil)
block := types.NewBlock(head, nil, &types.Commit{}, nil, trie.NewStackTrie(nil))
if err := setupGenesisStaking(staking, statedb, block.Header(), kvm.Config{}, g.Validators); err != nil {
panic(err)
}
Expand Down Expand Up @@ -331,7 +332,7 @@ func GenesisAllocFromData(data map[string]*big.Int) (GenesisAlloc, error) {
return ga, nil
}

//same as DefaultTestnetGenesisBlock, but with smart contract data
// same as DefaultTestnetGenesisBlock, but with smart contract data
func DefaultTestnetGenesisBlockWithContract(allocData map[string]string) *Genesis {
ga, err := GenesisAllocFromContractData(allocData)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion mainchain/tests/staking_smc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
g "github.com/kardiachain/go-kardia/mainchain/genesis"
"github.com/kardiachain/go-kardia/mainchain/staking"
stypes "github.com/kardiachain/go-kardia/mainchain/staking/types"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
)

Expand Down Expand Up @@ -135,7 +136,7 @@ func setup() (*blockchain.BlockChain, *state.StateDB, *staking.StakingSmcUtil, *
},
},
}
block := types.NewBlock(head, nil, &types.Commit{}, nil)
block := types.NewBlock(head, nil, &types.Commit{}, nil, trie.NewStackTrie(nil))
if err := util.SetRoot(stateDB, block.Header(), nil, kvm.Config{}); err != nil {
return nil, nil, nil, nil, nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion mainchain/tx_pool/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/kardiachain/go-kardia/lib/crypto"
"github.com/kardiachain/go-kardia/lib/event"
krand "github.com/kardiachain/go-kardia/lib/rand"
"github.com/kardiachain/go-kardia/trie"
"github.com/kardiachain/go-kardia/types"
)

Expand All @@ -58,7 +59,7 @@ type testBlockChain struct {
func (bc *testBlockChain) CurrentBlock() *types.Block {
return types.NewBlock(&types.Header{
GasLimit: bc.gasLimit,
}, nil, nil, nil)
}, nil, nil, nil, trie.NewStackTrie(nil))
}

func (bc *testBlockChain) GetBlock(hash common.Hash, number uint64) *types.Block {
Expand Down