diff --git a/core/encryption/hash.go b/core/encryption/hash.go index 0876756..6652967 100644 --- a/core/encryption/hash.go +++ b/core/encryption/hash.go @@ -7,7 +7,7 @@ import ( "golang.org/x/crypto/sha3" ) -//ErrInvalidHash - hash is invalid error +// ErrInvalidHash - hash is invalid error var ErrInvalidHash = common.NewError("invalid_hash", "Invalid hash") const HASH_LENGTH = 32 @@ -24,10 +24,10 @@ func IsHash(str string) bool { return err == nil && len(bytes) == HASH_LENGTH } -//EmptyHash - hash of an empty string +// EmptyHash - hash of an empty string var EmptyHash = Hash("") -//EmptyHashBytes - hash bytes of an empty string +// EmptyHashBytes - hash bytes of an empty string var EmptyHashBytes = RawHash("") /*RawHash - Logic to hash the text and return the hash bytes */ @@ -45,6 +45,6 @@ func RawHash(data interface{}) []byte { } hash := sha3.New256() hash.Write(databuf) - var buf []byte + buf := make([]byte, 0, hash.Size()) return hash.Sum(buf) } diff --git a/core/mocks/change_collector_i.go b/core/mocks/change_collector_i.go deleted file mode 100644 index c3394b6..0000000 --- a/core/mocks/change_collector_i.go +++ /dev/null @@ -1,130 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import ( - util "github.com/0chain/common/core/util" - mock "github.com/stretchr/testify/mock" -) - -// ChangeCollectorI is an autogenerated mock type for the ChangeCollectorI type -type ChangeCollectorI struct { - mock.Mock -} - -// AddChange provides a mock function with given fields: oldNode, newNode -func (_m *ChangeCollectorI) AddChange(oldNode util.Node, newNode util.Node) { - _m.Called(oldNode, newNode) -} - -// Clone provides a mock function with given fields: -func (_m *ChangeCollectorI) Clone() util.ChangeCollectorI { - ret := _m.Called() - - var r0 util.ChangeCollectorI - if rf, ok := ret.Get(0).(func() util.ChangeCollectorI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(util.ChangeCollectorI) - } - } - - return r0 -} - -// DeleteChange provides a mock function with given fields: oldNode -func (_m *ChangeCollectorI) DeleteChange(oldNode util.Node) { - _m.Called(oldNode) -} - -// GetChanges provides a mock function with given fields: -func (_m *ChangeCollectorI) GetChanges() []*util.NodeChange { - ret := _m.Called() - - var r0 []*util.NodeChange - if rf, ok := ret.Get(0).(func() []*util.NodeChange); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*util.NodeChange) - } - } - - return r0 -} - -// GetDeletes provides a mock function with given fields: -func (_m *ChangeCollectorI) GetDeletes() []util.Node { - ret := _m.Called() - - var r0 []util.Node - if rf, ok := ret.Get(0).(func() []util.Node); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]util.Node) - } - } - - return r0 -} - -// GetStartRoot provides a mock function with given fields: -func (_m *ChangeCollectorI) GetStartRoot() util.Key { - ret := _m.Called() - - var r0 util.Key - if rf, ok := ret.Get(0).(func() util.Key); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(util.Key) - } - } - - return r0 -} - -// UpdateChanges provides a mock function with given fields: ndb, origin, includeDeletes -func (_m *ChangeCollectorI) UpdateChanges(ndb util.NodeDB, origin util.Sequence, includeDeletes bool) error { - ret := _m.Called(ndb, origin, includeDeletes) - - var r0 error - if rf, ok := ret.Get(0).(func(util.NodeDB, util.Sequence, bool) error); ok { - r0 = rf(ndb, origin, includeDeletes) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Validate provides a mock function with given fields: -func (_m *ChangeCollectorI) Validate() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTNewChangeCollectorI interface { - mock.TestingT - Cleanup(func()) -} - -// NewChangeCollectorI creates a new instance of ChangeCollectorI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewChangeCollectorI(t mockConstructorTestingTNewChangeCollectorI) *ChangeCollectorI { - mock := &ChangeCollectorI{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/hashable.go b/core/mocks/hashable.go deleted file mode 100644 index 0a6c35b..0000000 --- a/core/mocks/hashable.go +++ /dev/null @@ -1,55 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import mock "github.com/stretchr/testify/mock" - -// Hashable is an autogenerated mock type for the Hashable type -type Hashable struct { - mock.Mock -} - -// GetHash provides a mock function with given fields: -func (_m *Hashable) GetHash() string { - ret := _m.Called() - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// GetHashBytes provides a mock function with given fields: -func (_m *Hashable) GetHashBytes() []byte { - ret := _m.Called() - - var r0 []byte - if rf, ok := ret.Get(0).(func() []byte); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - return r0 -} - -type mockConstructorTestingTNewHashable interface { - mock.TestingT - Cleanup(func()) -} - -// NewHashable creates a new instance of Hashable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewHashable(t mockConstructorTestingTNewHashable) *Hashable { - mock := &Hashable{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/merkle_patricia_trie_i.go b/core/mocks/merkle_patricia_trie_i.go deleted file mode 100644 index 96f212a..0000000 --- a/core/mocks/merkle_patricia_trie_i.go +++ /dev/null @@ -1,446 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - io "io" - - mock "github.com/stretchr/testify/mock" - - util "github.com/0chain/common/core/util" -) - -// MerklePatriciaTrieI is an autogenerated mock type for the MerklePatriciaTrieI type -type MerklePatriciaTrieI struct { - mock.Mock -} - -// Delete provides a mock function with given fields: path -func (_m *MerklePatriciaTrieI) Delete(path util.Path) (util.Key, error) { - ret := _m.Called(path) - - var r0 util.Key - if rf, ok := ret.Get(0).(func(util.Path) util.Key); ok { - r0 = rf(path) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(util.Key) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(util.Path) error); ok { - r1 = rf(path) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// FindMissingNodes provides a mock function with given fields: ctx -func (_m *MerklePatriciaTrieI) FindMissingNodes(ctx context.Context) ([]util.Path, []util.Key, error) { - ret := _m.Called(ctx) - - var r0 []util.Path - if rf, ok := ret.Get(0).(func(context.Context) []util.Path); ok { - r0 = rf(ctx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]util.Path) - } - } - - var r1 []util.Key - if rf, ok := ret.Get(1).(func(context.Context) []util.Key); ok { - r1 = rf(ctx) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).([]util.Key) - } - } - - var r2 error - if rf, ok := ret.Get(2).(func(context.Context) error); ok { - r2 = rf(ctx) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// GetChangeCount provides a mock function with given fields: -func (_m *MerklePatriciaTrieI) GetChangeCount() int { - ret := _m.Called() - - var r0 int - if rf, ok := ret.Get(0).(func() int); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(int) - } - - return r0 -} - -// GetChanges provides a mock function with given fields: -func (_m *MerklePatriciaTrieI) GetChanges() (util.Key, []*util.NodeChange, []util.Node, util.Key) { - ret := _m.Called() - - var r0 util.Key - if rf, ok := ret.Get(0).(func() util.Key); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(util.Key) - } - } - - var r1 []*util.NodeChange - if rf, ok := ret.Get(1).(func() []*util.NodeChange); ok { - r1 = rf() - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).([]*util.NodeChange) - } - } - - var r2 []util.Node - if rf, ok := ret.Get(2).(func() []util.Node); ok { - r2 = rf() - } else { - if ret.Get(2) != nil { - r2 = ret.Get(2).([]util.Node) - } - } - - var r3 util.Key - if rf, ok := ret.Get(3).(func() util.Key); ok { - r3 = rf() - } else { - if ret.Get(3) != nil { - r3 = ret.Get(3).(util.Key) - } - } - - return r0, r1, r2, r3 -} - -// GetDeletes provides a mock function with given fields: -func (_m *MerklePatriciaTrieI) GetDeletes() []util.Node { - ret := _m.Called() - - var r0 []util.Node - if rf, ok := ret.Get(0).(func() []util.Node); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]util.Node) - } - } - - return r0 -} - -// GetNodeDB provides a mock function with given fields: -func (_m *MerklePatriciaTrieI) GetNodeDB() util.NodeDB { - ret := _m.Called() - - var r0 util.NodeDB - if rf, ok := ret.Get(0).(func() util.NodeDB); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(util.NodeDB) - } - } - - return r0 -} - -// GetNodeValue provides a mock function with given fields: path, v -func (_m *MerklePatriciaTrieI) GetNodeValue(path util.Path, v util.MPTSerializable) error { - ret := _m.Called(path, v) - - var r0 error - if rf, ok := ret.Get(0).(func(util.Path, util.MPTSerializable) error); ok { - r0 = rf(path, v) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// GetNodeValueRaw provides a mock function with given fields: path -func (_m *MerklePatriciaTrieI) GetNodeValueRaw(path util.Path) ([]byte, error) { - ret := _m.Called(path) - - var r0 []byte - if rf, ok := ret.Get(0).(func(util.Path) []byte); ok { - r0 = rf(path) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(util.Path) error); ok { - r1 = rf(path) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetPathNodes provides a mock function with given fields: path -func (_m *MerklePatriciaTrieI) GetPathNodes(path util.Path) ([]util.Node, error) { - ret := _m.Called(path) - - var r0 []util.Node - if rf, ok := ret.Get(0).(func(util.Path) []util.Node); ok { - r0 = rf(path) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]util.Node) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(util.Path) error); ok { - r1 = rf(path) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetRoot provides a mock function with given fields: -func (_m *MerklePatriciaTrieI) GetRoot() util.Key { - ret := _m.Called() - - var r0 util.Key - if rf, ok := ret.Get(0).(func() util.Key); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(util.Key) - } - } - - return r0 -} - -// GetVersion provides a mock function with given fields: -func (_m *MerklePatriciaTrieI) GetVersion() util.Sequence { - ret := _m.Called() - - var r0 util.Sequence - if rf, ok := ret.Get(0).(func() util.Sequence); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(util.Sequence) - } - - return r0 -} - -// HasMissingNodes provides a mock function with given fields: ctx -func (_m *MerklePatriciaTrieI) HasMissingNodes(ctx context.Context) (bool, error) { - ret := _m.Called(ctx) - - var r0 bool - if rf, ok := ret.Get(0).(func(context.Context) bool); ok { - r0 = rf(ctx) - } else { - r0 = ret.Get(0).(bool) - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Insert provides a mock function with given fields: path, value -func (_m *MerklePatriciaTrieI) Insert(path util.Path, value util.MPTSerializable) (util.Key, error) { - ret := _m.Called(path, value) - - var r0 util.Key - if rf, ok := ret.Get(0).(func(util.Path, util.MPTSerializable) util.Key); ok { - r0 = rf(path, value) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(util.Key) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(util.Path, util.MPTSerializable) error); ok { - r1 = rf(path, value) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Iterate provides a mock function with given fields: ctx, handler, visitNodeTypes -func (_m *MerklePatriciaTrieI) Iterate(ctx context.Context, handler util.MPTIteratorHandler, visitNodeTypes byte) error { - ret := _m.Called(ctx, handler, visitNodeTypes) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, util.MPTIteratorHandler, byte) error); ok { - r0 = rf(ctx, handler, visitNodeTypes) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// IterateFrom provides a mock function with given fields: ctx, node, handler, visitNodeTypes -func (_m *MerklePatriciaTrieI) IterateFrom(ctx context.Context, node util.Key, handler util.MPTIteratorHandler, visitNodeTypes byte) error { - ret := _m.Called(ctx, node, handler, visitNodeTypes) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, util.Key, util.MPTIteratorHandler, byte) error); ok { - r0 = rf(ctx, node, handler, visitNodeTypes) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MergeChanges provides a mock function with given fields: newRoot, changes, deletes, startRoot -func (_m *MerklePatriciaTrieI) MergeChanges(newRoot util.Key, changes []*util.NodeChange, deletes []util.Node, startRoot util.Key) error { - ret := _m.Called(newRoot, changes, deletes, startRoot) - - var r0 error - if rf, ok := ret.Get(0).(func(util.Key, []*util.NodeChange, []util.Node, util.Key) error); ok { - r0 = rf(newRoot, changes, deletes, startRoot) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MergeDB provides a mock function with given fields: ndb, root -func (_m *MerklePatriciaTrieI) MergeDB(ndb util.NodeDB, root util.Key) error { - ret := _m.Called(ndb, root) - - var r0 error - if rf, ok := ret.Get(0).(func(util.NodeDB, util.Key) error); ok { - r0 = rf(ndb, root) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MergeMPTChanges provides a mock function with given fields: mpt2 -func (_m *MerklePatriciaTrieI) MergeMPTChanges(mpt2 util.MerklePatriciaTrieI) error { - ret := _m.Called(mpt2) - - var r0 error - if rf, ok := ret.Get(0).(func(util.MerklePatriciaTrieI) error); ok { - r0 = rf(mpt2) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// PrettyPrint provides a mock function with given fields: w -func (_m *MerklePatriciaTrieI) PrettyPrint(w io.Writer) error { - ret := _m.Called(w) - - var r0 error - if rf, ok := ret.Get(0).(func(io.Writer) error); ok { - r0 = rf(w) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SaveChanges provides a mock function with given fields: ctx, ndb, includeDeletes -func (_m *MerklePatriciaTrieI) SaveChanges(ctx context.Context, ndb util.NodeDB, includeDeletes bool) error { - ret := _m.Called(ctx, ndb, includeDeletes) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, util.NodeDB, bool) error); ok { - r0 = rf(ctx, ndb, includeDeletes) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SetNodeDB provides a mock function with given fields: ndb -func (_m *MerklePatriciaTrieI) SetNodeDB(ndb util.NodeDB) { - _m.Called(ndb) -} - -// SetVersion provides a mock function with given fields: version -func (_m *MerklePatriciaTrieI) SetVersion(version util.Sequence) { - _m.Called(version) -} - -// UpdateVersion provides a mock function with given fields: ctx, version, missingNodeHander -func (_m *MerklePatriciaTrieI) UpdateVersion(ctx context.Context, version util.Sequence, missingNodeHander util.MPTMissingNodeHandler) error { - ret := _m.Called(ctx, version, missingNodeHander) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, util.Sequence, util.MPTMissingNodeHandler) error); ok { - r0 = rf(ctx, version, missingNodeHander) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Validate provides a mock function with given fields: -func (_m *MerklePatriciaTrieI) Validate() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTNewMerklePatriciaTrieI interface { - mock.TestingT - Cleanup(func()) -} - -// NewMerklePatriciaTrieI creates a new instance of MerklePatriciaTrieI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMerklePatriciaTrieI(t mockConstructorTestingTNewMerklePatriciaTrieI) *MerklePatriciaTrieI { - mock := &MerklePatriciaTrieI{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/merkle_tree_i.go b/core/mocks/merkle_tree_i.go deleted file mode 100644 index 9556c4e..0000000 --- a/core/mocks/merkle_tree_i.go +++ /dev/null @@ -1,123 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import ( - util "github.com/0chain/common/core/util" - mock "github.com/stretchr/testify/mock" -) - -// MerkleTreeI is an autogenerated mock type for the MerkleTreeI type -type MerkleTreeI struct { - mock.Mock -} - -// ComputeTree provides a mock function with given fields: hashes -func (_m *MerkleTreeI) ComputeTree(hashes []util.Hashable) { - _m.Called(hashes) -} - -// GetPath provides a mock function with given fields: hash -func (_m *MerkleTreeI) GetPath(hash util.Hashable) *util.MTPath { - ret := _m.Called(hash) - - var r0 *util.MTPath - if rf, ok := ret.Get(0).(func(util.Hashable) *util.MTPath); ok { - r0 = rf(hash) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*util.MTPath) - } - } - - return r0 -} - -// GetPathByIndex provides a mock function with given fields: idx -func (_m *MerkleTreeI) GetPathByIndex(idx int) *util.MTPath { - ret := _m.Called(idx) - - var r0 *util.MTPath - if rf, ok := ret.Get(0).(func(int) *util.MTPath); ok { - r0 = rf(idx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*util.MTPath) - } - } - - return r0 -} - -// GetRoot provides a mock function with given fields: -func (_m *MerkleTreeI) GetRoot() string { - ret := _m.Called() - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// GetTree provides a mock function with given fields: -func (_m *MerkleTreeI) GetTree() []string { - ret := _m.Called() - - var r0 []string - if rf, ok := ret.Get(0).(func() []string); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]string) - } - } - - return r0 -} - -// SetTree provides a mock function with given fields: leavesCount, tree -func (_m *MerkleTreeI) SetTree(leavesCount int, tree []string) error { - ret := _m.Called(leavesCount, tree) - - var r0 error - if rf, ok := ret.Get(0).(func(int, []string) error); ok { - r0 = rf(leavesCount, tree) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// VerifyPath provides a mock function with given fields: hash, path -func (_m *MerkleTreeI) VerifyPath(hash util.Hashable, path *util.MTPath) bool { - ret := _m.Called(hash, path) - - var r0 bool - if rf, ok := ret.Get(0).(func(util.Hashable, *util.MTPath) bool); ok { - r0 = rf(hash, path) - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -type mockConstructorTestingTNewMerkleTreeI interface { - mock.TestingT - Cleanup(func()) -} - -// NewMerkleTreeI creates a new instance of MerkleTreeI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMerkleTreeI(t mockConstructorTestingTNewMerkleTreeI) *MerkleTreeI { - mock := &MerkleTreeI{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/mpt_iterator_handler.go b/core/mocks/mpt_iterator_handler.go deleted file mode 100644 index 315fd1a..0000000 --- a/core/mocks/mpt_iterator_handler.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - - util "github.com/0chain/common/core/util" - mock "github.com/stretchr/testify/mock" -) - -// MPTIteratorHandler is an autogenerated mock type for the MPTIteratorHandler type -type MPTIteratorHandler struct { - mock.Mock -} - -// Execute provides a mock function with given fields: ctx, path, key, node -func (_m *MPTIteratorHandler) Execute(ctx context.Context, path util.Path, key util.Key, node util.Node) error { - ret := _m.Called(ctx, path, key, node) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, util.Path, util.Key, util.Node) error); ok { - r0 = rf(ctx, path, key, node) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTNewMPTIteratorHandler interface { - mock.TestingT - Cleanup(func()) -} - -// NewMPTIteratorHandler creates a new instance of MPTIteratorHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMPTIteratorHandler(t mockConstructorTestingTNewMPTIteratorHandler) *MPTIteratorHandler { - mock := &MPTIteratorHandler{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/mpt_missing_node_handler.go b/core/mocks/mpt_missing_node_handler.go deleted file mode 100644 index efdf0c7..0000000 --- a/core/mocks/mpt_missing_node_handler.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - - util "github.com/0chain/common/core/util" - mock "github.com/stretchr/testify/mock" -) - -// MPTMissingNodeHandler is an autogenerated mock type for the MPTMissingNodeHandler type -type MPTMissingNodeHandler struct { - mock.Mock -} - -// Execute provides a mock function with given fields: ctx, path, key -func (_m *MPTMissingNodeHandler) Execute(ctx context.Context, path util.Path, key util.Key) error { - ret := _m.Called(ctx, path, key) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, util.Path, util.Key) error); ok { - r0 = rf(ctx, path, key) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTNewMPTMissingNodeHandler interface { - mock.TestingT - Cleanup(func()) -} - -// NewMPTMissingNodeHandler creates a new instance of MPTMissingNodeHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMPTMissingNodeHandler(t mockConstructorTestingTNewMPTMissingNodeHandler) *MPTMissingNodeHandler { - mock := &MPTMissingNodeHandler{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/mpt_serializable.go b/core/mocks/mpt_serializable.go deleted file mode 100644 index 8336c02..0000000 --- a/core/mocks/mpt_serializable.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import mock "github.com/stretchr/testify/mock" - -// MPTSerializable is an autogenerated mock type for the MPTSerializable type -type MPTSerializable struct { - mock.Mock -} - -// MarshalMsg provides a mock function with given fields: _a0 -func (_m *MPTSerializable) MarshalMsg(_a0 []byte) ([]byte, error) { - ret := _m.Called(_a0) - - var r0 []byte - if rf, ok := ret.Get(0).(func([]byte) []byte); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]byte) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// UnmarshalMsg provides a mock function with given fields: _a0 -func (_m *MPTSerializable) UnmarshalMsg(_a0 []byte) ([]byte, error) { - ret := _m.Called(_a0) - - var r0 []byte - if rf, ok := ret.Get(0).(func([]byte) []byte); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]byte) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTNewMPTSerializable interface { - mock.TestingT - Cleanup(func()) -} - -// NewMPTSerializable creates a new instance of MPTSerializable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMPTSerializable(t mockConstructorTestingTNewMPTSerializable) *MPTSerializable { - mock := &MPTSerializable{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/mpt_serializable_size.go b/core/mocks/mpt_serializable_size.go deleted file mode 100644 index 4580e51..0000000 --- a/core/mocks/mpt_serializable_size.go +++ /dev/null @@ -1,85 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import mock "github.com/stretchr/testify/mock" - -// MPTSerializableSize is an autogenerated mock type for the MPTSerializableSize type -type MPTSerializableSize struct { - mock.Mock -} - -// MarshalMsg provides a mock function with given fields: _a0 -func (_m *MPTSerializableSize) MarshalMsg(_a0 []byte) ([]byte, error) { - ret := _m.Called(_a0) - - var r0 []byte - if rf, ok := ret.Get(0).(func([]byte) []byte); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]byte) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Msgsize provides a mock function with given fields: -func (_m *MPTSerializableSize) Msgsize() int { - ret := _m.Called() - - var r0 int - if rf, ok := ret.Get(0).(func() int); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(int) - } - - return r0 -} - -// UnmarshalMsg provides a mock function with given fields: _a0 -func (_m *MPTSerializableSize) UnmarshalMsg(_a0 []byte) ([]byte, error) { - ret := _m.Called(_a0) - - var r0 []byte - if rf, ok := ret.Get(0).(func([]byte) []byte); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]byte) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTNewMPTSerializableSize interface { - mock.TestingT - Cleanup(func()) -} - -// NewMPTSerializableSize creates a new instance of MPTSerializableSize. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewMPTSerializableSize(t mockConstructorTestingTNewMPTSerializableSize) *MPTSerializableSize { - mock := &MPTSerializableSize{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/node.go b/core/mocks/node.go index 9482675..f726b26 100644 --- a/core/mocks/node.go +++ b/core/mocks/node.go @@ -1,207 +1 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - package mocks - -import ( - io "io" - - util "github.com/0chain/common/core/util" - mock "github.com/stretchr/testify/mock" -) - -// Node is an autogenerated mock type for the Node type -type Node struct { - mock.Mock -} - -// Clone provides a mock function with given fields: -func (_m *Node) Clone() util.Node { - ret := _m.Called() - - var r0 util.Node - if rf, ok := ret.Get(0).(func() util.Node); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(util.Node) - } - } - - return r0 -} - -// Decode provides a mock function with given fields: _a0 -func (_m *Node) Decode(_a0 []byte) error { - ret := _m.Called(_a0) - - var r0 error - if rf, ok := ret.Get(0).(func([]byte) error); ok { - r0 = rf(_a0) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Encode provides a mock function with given fields: -func (_m *Node) Encode() []byte { - ret := _m.Called() - - var r0 []byte - if rf, ok := ret.Get(0).(func() []byte); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - return r0 -} - -// GetHash provides a mock function with given fields: -func (_m *Node) GetHash() string { - ret := _m.Called() - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// GetHashBytes provides a mock function with given fields: -func (_m *Node) GetHashBytes() []byte { - ret := _m.Called() - - var r0 []byte - if rf, ok := ret.Get(0).(func() []byte); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - return r0 -} - -// GetNodeType provides a mock function with given fields: -func (_m *Node) GetNodeType() byte { - ret := _m.Called() - - var r0 byte - if rf, ok := ret.Get(0).(func() byte); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(byte) - } - - return r0 -} - -// GetOrigin provides a mock function with given fields: -func (_m *Node) GetOrigin() util.Sequence { - ret := _m.Called() - - var r0 util.Sequence - if rf, ok := ret.Get(0).(func() util.Sequence); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(util.Sequence) - } - - return r0 -} - -// GetOriginTracker provides a mock function with given fields: -func (_m *Node) GetOriginTracker() util.OriginTrackerI { - ret := _m.Called() - - var r0 util.OriginTrackerI - if rf, ok := ret.Get(0).(func() util.OriginTrackerI); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(util.OriginTrackerI) - } - } - - return r0 -} - -// GetVersion provides a mock function with given fields: -func (_m *Node) GetVersion() util.Sequence { - ret := _m.Called() - - var r0 util.Sequence - if rf, ok := ret.Get(0).(func() util.Sequence); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(util.Sequence) - } - - return r0 -} - -// Read provides a mock function with given fields: r -func (_m *Node) Read(r io.Reader) error { - ret := _m.Called(r) - - var r0 error - if rf, ok := ret.Get(0).(func(io.Reader) error); ok { - r0 = rf(r) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SetOrigin provides a mock function with given fields: origin -func (_m *Node) SetOrigin(origin util.Sequence) { - _m.Called(origin) -} - -// SetOriginTracker provides a mock function with given fields: ot -func (_m *Node) SetOriginTracker(ot util.OriginTrackerI) { - _m.Called(ot) -} - -// SetVersion provides a mock function with given fields: version -func (_m *Node) SetVersion(version util.Sequence) { - _m.Called(version) -} - -// Write provides a mock function with given fields: w -func (_m *Node) Write(w io.Writer) error { - ret := _m.Called(w) - - var r0 error - if rf, ok := ret.Get(0).(func(io.Writer) error); ok { - r0 = rf(w) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTNewNode interface { - mock.TestingT - Cleanup(func()) -} - -// NewNode creates a new instance of Node. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewNode(t mockConstructorTestingTNewNode) *Node { - mock := &Node{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/node_db.go b/core/mocks/node_db.go deleted file mode 100644 index 9aa4333..0000000 --- a/core/mocks/node_db.go +++ /dev/null @@ -1,188 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - - util "github.com/0chain/common/core/util" - mock "github.com/stretchr/testify/mock" -) - -// NodeDB is an autogenerated mock type for the NodeDB type -type NodeDB struct { - mock.Mock -} - -// DeleteNode provides a mock function with given fields: key -func (_m *NodeDB) DeleteNode(key util.Key) error { - ret := _m.Called(key) - - var r0 error - if rf, ok := ret.Get(0).(func(util.Key) error); ok { - r0 = rf(key) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// GetNode provides a mock function with given fields: key -func (_m *NodeDB) GetNode(key util.Key) (util.Node, error) { - ret := _m.Called(key) - - var r0 util.Node - if rf, ok := ret.Get(0).(func(util.Key) util.Node); ok { - r0 = rf(key) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(util.Node) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(util.Key) error); ok { - r1 = rf(key) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Iterate provides a mock function with given fields: ctx, handler -func (_m *NodeDB) Iterate(ctx context.Context, handler util.NodeDBIteratorHandler) error { - ret := _m.Called(ctx, handler) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, util.NodeDBIteratorHandler) error); ok { - r0 = rf(ctx, handler) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MultiDeleteNode provides a mock function with given fields: keys -func (_m *NodeDB) MultiDeleteNode(keys []util.Key) error { - ret := _m.Called(keys) - - var r0 error - if rf, ok := ret.Get(0).(func([]util.Key) error); ok { - r0 = rf(keys) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MultiGetNode provides a mock function with given fields: keys -func (_m *NodeDB) MultiGetNode(keys []util.Key) ([]util.Node, error) { - ret := _m.Called(keys) - - var r0 []util.Node - if rf, ok := ret.Get(0).(func([]util.Key) []util.Node); ok { - r0 = rf(keys) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]util.Node) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]util.Key) error); ok { - r1 = rf(keys) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MultiPutNode provides a mock function with given fields: keys, nodes -func (_m *NodeDB) MultiPutNode(keys []util.Key, nodes []util.Node) error { - ret := _m.Called(keys, nodes) - - var r0 error - if rf, ok := ret.Get(0).(func([]util.Key, []util.Node) error); ok { - r0 = rf(keys, nodes) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// PruneBelowVersion provides a mock function with given fields: ctx, version -func (_m *NodeDB) PruneBelowVersion(ctx context.Context, version int64) error { - ret := _m.Called(ctx, version) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok { - r0 = rf(ctx, version) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// PutNode provides a mock function with given fields: key, node -func (_m *NodeDB) PutNode(key util.Key, node util.Node) error { - ret := _m.Called(key, node) - - var r0 error - if rf, ok := ret.Get(0).(func(util.Key, util.Node) error); ok { - r0 = rf(key, node) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// RecordDeadNodes provides a mock function with given fields: _a0, _a1 -func (_m *NodeDB) RecordDeadNodes(_a0 []util.Node, _a1 int64) error { - ret := _m.Called(_a0, _a1) - - var r0 error - if rf, ok := ret.Get(0).(func([]util.Node, int64) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Size provides a mock function with given fields: ctx -func (_m *NodeDB) Size(ctx context.Context) int64 { - ret := _m.Called(ctx) - - var r0 int64 - if rf, ok := ret.Get(0).(func(context.Context) int64); ok { - r0 = rf(ctx) - } else { - r0 = ret.Get(0).(int64) - } - - return r0 -} - -type mockConstructorTestingTNewNodeDB interface { - mock.TestingT - Cleanup(func()) -} - -// NewNodeDB creates a new instance of NodeDB. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewNodeDB(t mockConstructorTestingTNewNodeDB) *NodeDB { - mock := &NodeDB{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/node_db_iterator_handler.go b/core/mocks/node_db_iterator_handler.go deleted file mode 100644 index 3d1a77e..0000000 --- a/core/mocks/node_db_iterator_handler.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import ( - context "context" - - util "github.com/0chain/common/core/util" - mock "github.com/stretchr/testify/mock" -) - -// NodeDBIteratorHandler is an autogenerated mock type for the NodeDBIteratorHandler type -type NodeDBIteratorHandler struct { - mock.Mock -} - -// Execute provides a mock function with given fields: ctx, key, node -func (_m *NodeDBIteratorHandler) Execute(ctx context.Context, key util.Key, node util.Node) error { - ret := _m.Called(ctx, key, node) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, util.Key, util.Node) error); ok { - r0 = rf(ctx, key, node) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTNewNodeDBIteratorHandler interface { - mock.TestingT - Cleanup(func()) -} - -// NewNodeDBIteratorHandler creates a new instance of NodeDBIteratorHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewNodeDBIteratorHandler(t mockConstructorTestingTNewNodeDBIteratorHandler) *NodeDBIteratorHandler { - mock := &NodeDBIteratorHandler{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/origin_tracker_i.go b/core/mocks/origin_tracker_i.go deleted file mode 100644 index 0312b7b..0000000 --- a/core/mocks/origin_tracker_i.go +++ /dev/null @@ -1,96 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import ( - io "io" - - util "github.com/0chain/common/core/util" - mock "github.com/stretchr/testify/mock" -) - -// OriginTrackerI is an autogenerated mock type for the OriginTrackerI type -type OriginTrackerI struct { - mock.Mock -} - -// GetOrigin provides a mock function with given fields: -func (_m *OriginTrackerI) GetOrigin() util.Sequence { - ret := _m.Called() - - var r0 util.Sequence - if rf, ok := ret.Get(0).(func() util.Sequence); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(util.Sequence) - } - - return r0 -} - -// GetVersion provides a mock function with given fields: -func (_m *OriginTrackerI) GetVersion() util.Sequence { - ret := _m.Called() - - var r0 util.Sequence - if rf, ok := ret.Get(0).(func() util.Sequence); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(util.Sequence) - } - - return r0 -} - -// Read provides a mock function with given fields: r -func (_m *OriginTrackerI) Read(r io.Reader) error { - ret := _m.Called(r) - - var r0 error - if rf, ok := ret.Get(0).(func(io.Reader) error); ok { - r0 = rf(r) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SetOrigin provides a mock function with given fields: origin -func (_m *OriginTrackerI) SetOrigin(origin util.Sequence) { - _m.Called(origin) -} - -// SetVersion provides a mock function with given fields: version -func (_m *OriginTrackerI) SetVersion(version util.Sequence) { - _m.Called(version) -} - -// Write provides a mock function with given fields: w -func (_m *OriginTrackerI) Write(w io.Writer) error { - ret := _m.Called(w) - - var r0 error - if rf, ok := ret.Get(0).(func(io.Writer) error); ok { - r0 = rf(w) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTNewOriginTrackerI interface { - mock.TestingT - Cleanup(func()) -} - -// NewOriginTrackerI creates a new instance of OriginTrackerI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewOriginTrackerI(t mockConstructorTestingTNewOriginTrackerI) *OriginTrackerI { - mock := &OriginTrackerI{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/secure_serializable_value_i.go b/core/mocks/secure_serializable_value_i.go deleted file mode 100644 index db667f0..0000000 --- a/core/mocks/secure_serializable_value_i.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import mock "github.com/stretchr/testify/mock" - -// SecureSerializableValueI is an autogenerated mock type for the SecureSerializableValueI type -type SecureSerializableValueI struct { - mock.Mock -} - -// GetHash provides a mock function with given fields: -func (_m *SecureSerializableValueI) GetHash() string { - ret := _m.Called() - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// GetHashBytes provides a mock function with given fields: -func (_m *SecureSerializableValueI) GetHashBytes() []byte { - ret := _m.Called() - - var r0 []byte - if rf, ok := ret.Get(0).(func() []byte); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - return r0 -} - -// MarshalMsg provides a mock function with given fields: _a0 -func (_m *SecureSerializableValueI) MarshalMsg(_a0 []byte) ([]byte, error) { - ret := _m.Called(_a0) - - var r0 []byte - if rf, ok := ret.Get(0).(func([]byte) []byte); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]byte) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// UnmarshalMsg provides a mock function with given fields: _a0 -func (_m *SecureSerializableValueI) UnmarshalMsg(_a0 []byte) ([]byte, error) { - ret := _m.Called(_a0) - - var r0 []byte - if rf, ok := ret.Get(0).(func([]byte) []byte); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]byte) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTNewSecureSerializableValueI interface { - mock.TestingT - Cleanup(func()) -} - -// NewSecureSerializableValueI creates a new instance of SecureSerializableValueI. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewSecureSerializableValueI(t mockConstructorTestingTNewSecureSerializableValueI) *SecureSerializableValueI { - mock := &SecureSerializableValueI{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/mocks/serializable.go b/core/mocks/serializable.go deleted file mode 100644 index 744f211..0000000 --- a/core/mocks/serializable.go +++ /dev/null @@ -1,55 +0,0 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. - -package mocks - -import mock "github.com/stretchr/testify/mock" - -// Serializable is an autogenerated mock type for the Serializable type -type Serializable struct { - mock.Mock -} - -// Decode provides a mock function with given fields: _a0 -func (_m *Serializable) Decode(_a0 []byte) error { - ret := _m.Called(_a0) - - var r0 error - if rf, ok := ret.Get(0).(func([]byte) error); ok { - r0 = rf(_a0) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Encode provides a mock function with given fields: -func (_m *Serializable) Encode() []byte { - ret := _m.Called() - - var r0 []byte - if rf, ok := ret.Get(0).(func() []byte); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - return r0 -} - -type mockConstructorTestingTNewSerializable interface { - mock.TestingT - Cleanup(func()) -} - -// NewSerializable creates a new instance of Serializable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewSerializable(t mockConstructorTestingTNewSerializable) *Serializable { - mock := &Serializable{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/core/util/storage/database.go b/core/util/storage/database.go new file mode 100644 index 0000000..ff0cbf1 --- /dev/null +++ b/core/util/storage/database.go @@ -0,0 +1,15 @@ +package storage + +type StorageAdapter interface { + Get([]byte) ([]byte, error) + Put([]byte, []byte) error + Delete([]byte) error + Close() + NewBatch() Batcher +} + +type Batcher interface { + Put([]byte, []byte) error + Delete([]byte) error + Commit(bool) error +} diff --git a/core/util/storage/kv/pebble.go b/core/util/storage/kv/pebble.go new file mode 100644 index 0000000..bc559f2 --- /dev/null +++ b/core/util/storage/kv/pebble.go @@ -0,0 +1,81 @@ +//go:build !js && !wasm + +package kv + +import ( + "runtime" + "sync" + + "github.com/0chain/common/core/util/storage" + "github.com/cockroachdb/pebble" +) + +type PebbleAdapter struct { + db *pebble.DB +} + +func NewPebbleAdapter(path string, opts *pebble.Options) (*PebbleAdapter, error) { + if opts == nil { + opts = &pebble.Options{ + Cache: pebble.NewCache(1024 * 1024 * 1024), + MaxConcurrentCompactions: func() int { return runtime.GOMAXPROCS(0) }, + } + } + db, err := pebble.Open(path, opts) + if err != nil { + return nil, err + } + return &PebbleAdapter{db: db}, nil +} + +func (p *PebbleAdapter) Get(key []byte) ([]byte, error) { + dat, closer, err := p.db.Get(key) + if err != nil { + return nil, err + } + ret := make([]byte, len(dat)) + copy(ret, dat) + closer.Close() + return ret, nil +} + +func (p *PebbleAdapter) Close() { + p.db.Close() +} + +func (p *PebbleAdapter) Put(key []byte, value []byte) error { + return p.db.Set(key, value, pebble.NoSync) +} + +func (p *PebbleAdapter) Delete(key []byte) error { + return p.db.Delete(key, pebble.NoSync) +} + +type batch struct { + b *pebble.Batch + sync.Mutex +} + +func (p *PebbleAdapter) NewBatch() storage.Batcher { + b := p.db.NewBatch() + return &batch{b: b} +} + +func (b *batch) Put(key []byte, value []byte) error { + b.Lock() + defer b.Unlock() + return b.b.Set(key, value, pebble.NoSync) +} + +func (b *batch) Commit(sync bool) error { + if sync { + return b.b.Commit(pebble.Sync) + } + return b.b.Commit(pebble.NoSync) +} + +func (b *batch) Delete(key []byte) error { + b.Lock() + defer b.Unlock() + return b.b.Delete(key, pebble.NoSync) +} diff --git a/core/util/wmpt/node.go b/core/util/wmpt/node.go new file mode 100644 index 0000000..5c9bfc9 --- /dev/null +++ b/core/util/wmpt/node.go @@ -0,0 +1,491 @@ +package wmpt + +import ( + "encoding/binary" + "errors" + + "github.com/0chain/common/core/encryption" + "github.com/0chain/common/core/util/storage" + "github.com/fxamacker/cbor/v2" +) + +type Node interface { + Hash() []byte + CalcHash() []byte + Copy() Node + CopyRoot(currLevel, collapseLevel int) Node + Weight() uint64 + Serialize() ([]byte, error) + ToCollect() bool + Dirty() bool +} + +type ( + routingNode struct { + hash []byte + Children [16]Node + weight uint64 + dirty bool + toCollect bool + } + valueNode struct { + hash []byte + value []byte + weight uint64 + dirty bool + } + shortNode struct { + key []byte + hash []byte + value Node + dirty bool + toCollect bool + } + nilNode struct{} + hashNode struct { + hash []byte + weight uint64 + } +) + +var ( + emptyNode = &nilNode{} + emptyNodeBytes []byte +) + +func init() { + pNode := PersistNodeBase{ + NilNode: &PersistNilNode{}, + } + + emptyNodeBytes, _ = cbor.Marshal(&pNode) +} + +const ( + hashWithWeightLength = 40 + branchNodeLength = 16 + branchNodeHashDataLength = 16*32 + 8 //16 children + 8 bytes for weight +) + +func (r *routingNode) Hash() []byte { + return r.hash +} + +func (r *routingNode) Copy() Node { + cpy := &routingNode{hash: r.hash, weight: r.weight} + + for i, n := range r.Children { + if n != nil { + cpy.Children[i] = &hashNode{ + hash: n.Hash(), + weight: n.Weight(), + } + } + } + + return cpy +} + +func (r *routingNode) CopyRoot(currLevel, collapseLevel int) Node { + if currLevel == collapseLevel { + return &hashNode{ + hash: r.hash, + weight: r.weight, + } + } + cpy := &routingNode{hash: r.hash, weight: r.weight} + + for i, n := range r.Children { + if n != nil { + cpy.Children[i] = n.CopyRoot(currLevel+1, collapseLevel) + } + } + return cpy +} + +func (r *routingNode) CalcHash() []byte { + if !r.dirty { + return r.hash + } + m := make([]byte, 0, branchNodeHashDataLength) + m = binary.BigEndian.AppendUint64(m, r.weight) + for _, child := range r.Children { + if child == nil { + child = emptyNode + } + m = append(m, child.CalcHash()...) + } + h := encryption.RawHash(m) + r.hash = h + return h +} + +func (r *routingNode) Weight() uint64 { + return r.weight +} + +func (r *routingNode) ToCollect() bool { + return r.toCollect +} + +func (r *routingNode) Dirty() bool { + return r.dirty +} + +func (r *routingNode) Save(batcher storage.Batcher) error { + if !r.dirty { + return nil + } + data, err := r.Serialize() + if err != nil { + return err + } + return batcher.Put(r.hash, data) +} + +func (r *routingNode) Serialize() ([]byte, error) { + persistBranchNode := PersistNodeBranch{} + r.toCollect = false + if r.dirty { + r.CalcHash() + } + persistBranchNode.Children = make([][]byte, 16) + for i, child := range r.Children { + if child != nil { + var childBytes []byte + if c, ok := child.(*shortNode); ok { + childBytes = make([]byte, 0, hashWithWeightLength+32+len(c.key)) + childBytes = append(childBytes, child.Hash()...) + childBytes = binary.BigEndian.AppendUint64(childBytes, child.Weight()) + childBytes = append(childBytes, c.value.Hash()...) + childBytes = append(childBytes, c.key...) + } else { + childBytes = make([]byte, 0, hashWithWeightLength) + childBytes = append(childBytes, child.Hash()...) + childBytes = binary.BigEndian.AppendUint64(childBytes, child.Weight()) + } + persistBranchNode.Children[i] = childBytes + } + } + + persistBranchNode.Hash = r.hash + + pNode := PersistNodeBase{ + Branch: &persistBranchNode, + } + + return cbor.Marshal(&pNode) +} + +func (v *valueNode) Hash() []byte { + return v.hash +} + +func (v *valueNode) Copy() Node { + valueCopy := make([]byte, len(v.value)) + copy(valueCopy, v.value) + + return &valueNode{value: valueCopy, weight: v.weight, hash: v.hash} +} + +func (v *valueNode) CopyRoot(currLevel, collapseLevel int) Node { + return v.Copy() +} + +func (v *valueNode) CalcHash() []byte { + if !v.dirty { + return v.hash + } + m := make([]byte, 0, hashWithWeightLength) + m = binary.BigEndian.AppendUint64(m, v.weight) + m = append(m, v.value...) + h := encryption.RawHash(m) + v.hash = h + v.dirty = false + return h +} + +func (v *valueNode) Weight() uint64 { + return v.weight +} + +func (v *valueNode) ToCollect() bool { + return true +} + +func (v *valueNode) Dirty() bool { + return v.dirty +} + +func (v *valueNode) Save(batcher storage.Batcher) error { + if !v.dirty { + return nil + } + data, err := v.Serialize() + if err != nil { + return err + } + return batcher.Put(v.hash, data) +} + +func (v *valueNode) Serialize() ([]byte, error) { + if v.dirty { + v.CalcHash() + } + pNode := PersistNodeBase{ + Value: &PersistNodeValue{ + Value: v.value, + Weight: v.weight, + Hash: v.hash, + }, + } + + return cbor.Marshal(&pNode) +} + +func (n *nilNode) Hash() []byte { + return emptyState +} + +func (n *nilNode) Copy() Node { + return n +} + +func (n *nilNode) CopyRoot(currLevel, collapseLevel int) Node { + return n +} + +func (n *nilNode) CalcHash() []byte { + return emptyState +} + +func (n *nilNode) Weight() uint64 { + return 0 +} + +func (n *nilNode) ToCollect() bool { + return true +} + +func (n *nilNode) Dirty() bool { + return false +} + +func (n *nilNode) Serialize() ([]byte, error) { + return emptyNodeBytes, nil +} + +func NewHashNode(hash []byte, weight uint64) Node { + return &hashNode{hash: hash, weight: weight} +} + +func (h *hashNode) Hash() []byte { + return h.hash +} + +func (h *hashNode) Copy() Node { + return &hashNode{hash: h.hash, weight: h.weight} +} + +func (h *hashNode) CopyRoot(currLevel, collapseLevel int) Node { + return h.Copy() +} + +func (h *hashNode) CalcHash() []byte { + return h.hash +} + +func (h *hashNode) Weight() uint64 { + return h.weight +} + +func (h *hashNode) ToCollect() bool { + return true +} + +func (h *hashNode) Dirty() bool { + return false +} + +func (h *hashNode) Serialize() ([]byte, error) { + pNode := PersistNodeBase{ + HashNode: &PersistHashNode{ + Hash: h.hash, + Weight: h.weight, + }, + } + + return cbor.Marshal(&pNode) +} + +func (s *shortNode) Hash() []byte { + return s.hash +} + +func (s *shortNode) CalcHash() []byte { + if !s.dirty { + return s.hash + } + m := make([]byte, 0, len(s.key)+32) + m = append(m, s.key...) + if s.value != nil { + m = append(m, s.value.CalcHash()...) + } + s.hash = encryption.RawHash(m) + s.dirty = false + return s.hash +} + +func (s *shortNode) Weight() uint64 { + return s.value.Weight() +} + +func (s *shortNode) ToCollect() bool { + return s.toCollect +} + +func (s *shortNode) Dirty() bool { + return s.dirty +} + +func (s *shortNode) Copy() Node { + keyCopy := make([]byte, len(s.key)) + copy(keyCopy, s.key) + + valueCopy := &hashNode{ + hash: s.value.Hash(), + weight: s.value.Weight(), + } + + return &shortNode{key: keyCopy, value: valueCopy, hash: s.hash} +} + +func (s *shortNode) CopyRoot(currLevel, collapseLevel int) Node { + if currLevel == collapseLevel { + return s.Copy() + } + keyCopy := make([]byte, len(s.key)) + copy(keyCopy, s.key) + valueCopy := s.value.CopyRoot(currLevel+1, collapseLevel) + return &shortNode{key: keyCopy, value: valueCopy, hash: s.hash} +} + +func (s *shortNode) Serialize() ([]byte, error) { + s.toCollect = false + if s.dirty { + s.CalcHash() + } + valueHashWithWeight := make([]byte, hashWithWeightLength) + copy(valueHashWithWeight, s.value.Hash()) + binary.BigEndian.PutUint64(valueHashWithWeight[32:], s.value.Weight()) + + shortPersistNode := PersistNodeShort{ + Key: s.key, + Hash: s.hash, + Value: valueHashWithWeight, + } + pNode := PersistNodeBase{ + Short: &shortPersistNode, + } + + return cbor.Marshal(&pNode) +} + +func (s *shortNode) Save(batcher storage.Batcher) error { + if !s.dirty { + return nil + } + data, err := s.Serialize() + if err != nil { + return err + } + return batcher.Put(s.hash, data) +} + +func DeserializeNode(data []byte) (Node, error) { + pNode := PersistNodeBase{} + err := cbor.Unmarshal(data, &pNode) + if err != nil { + return nil, err + } + if pNode.Branch != nil { + branchNode := routingNode{} + branchNode.hash = pNode.Branch.Hash + for i, child := range pNode.Branch.Children { + if len(child) >= hashWithWeightLength { + childHash := child[:32] + childWeight := binary.BigEndian.Uint64(child[32:]) + branchNode.weight += childWeight + childNodeValue := &hashNode{hash: childHash, weight: childWeight} + if len(child) == hashWithWeightLength { + branchNode.Children[i] = childNodeValue + } else { + childNodeValue.hash = child[hashWithWeightLength : hashWithWeightLength+32] + childKey := child[hashWithWeightLength+32:] + branchNode.Children[i] = &shortNode{ + key: childKey, + hash: childHash, + value: childNodeValue, + } + } + } + } + return &branchNode, nil + } + if pNode.Value != nil { + valueNode := valueNode{} + valueNode.value = pNode.Value.Value + valueNode.weight = pNode.Value.Weight + valueNode.hash = pNode.Value.Hash + return &valueNode, nil + } + if pNode.NilNode != nil { + return &nilNode{}, nil + } + if pNode.HashNode != nil { + hashNode := hashNode{} + hashNode.hash = pNode.HashNode.Hash + hashNode.weight = pNode.HashNode.Weight + return &hashNode, nil + } + if pNode.Short != nil { + shortNode := shortNode{} + shortNode.key = pNode.Short.Key + if len(pNode.Short.Value) != hashWithWeightLength { + return nil, errors.New("invalid hash with weight") + } + shortNode.hash = pNode.Short.Hash + hashNode := hashNode{ + hash: pNode.Short.Value[:32], + weight: binary.BigEndian.Uint64(pNode.Short.Value[32:]), + } + shortNode.value = &hashNode + return &shortNode, nil + } + + return nil, errors.New("invalid node") +} + +func keybytesToHex(str []byte) []byte { + l := len(str) * 2 + var nibbles = make([]byte, l) + for i, b := range str { + nibbles[i*2] = b / 16 + nibbles[i*2+1] = b % 16 + } + return nibbles +} + +// hexToKeybytes turns hex nibbles into key bytes. +// This can only be used for keys of even length. +func hexToKeybytes(hex []byte) []byte { + key := make([]byte, len(hex)/2) + decodeNibbles(hex, key) + return key +} + +func decodeNibbles(nibbles []byte, bytes []byte) { + for bi, ni := 0, 0; ni < len(nibbles); bi, ni = bi+1, ni+2 { + bytes[bi] = nibbles[ni]<<4 | nibbles[ni+1] + } +} diff --git a/core/util/wmpt/path.go b/core/util/wmpt/path.go new file mode 100644 index 0000000..22bbc2f --- /dev/null +++ b/core/util/wmpt/path.go @@ -0,0 +1,223 @@ +package wmpt + +import ( + "bytes" + "context" + "errors" + "sync" + + "github.com/fxamacker/cbor/v2" + "golang.org/x/sync/errgroup" +) + +var ErrKVNotFound = errors.New("pebble: not found") + +func (t *WeightedMerkleTrie) GetPath(keys [][]byte) ([]byte, error) { + persistTrie := &PersistTrie{} + + if t.root != nil { + if node, ok := t.root.(*hashNode); ok { + data, err := t.db.Get(node.Hash()) + if err != nil { + return nil, err + } + loadedNode, err := DeserializeNode(data) + if err != nil { + + } + t.root = loadedNode + } + } + + if len(keys) > 10 { + eg, _ := errgroup.WithContext(context.TODO()) + eg.SetLimit(5) + if node, ok := t.root.(*routingNode); ok { + node.toCollect = true + var branchMu = [16]sync.Mutex{} + for i := 0; i < len(keys); i++ { + ind := i + eg.Go(func() error { + k := keybytesToHex(keys[ind]) + branchMu[k[0]].Lock() + defer branchMu[k[0]].Unlock() + child, err := t.markToCollect(node.Children[k[0]], k, 1) + if err != nil { + if errors.Is(err, ErrKVNotFound) { + err = ErrNotFound + } + return err + } + node.Children[k[0]] = child + return nil + }) + } + err := eg.Wait() + if err != nil { + return nil, err + } + } + } else { + for _, key := range keys { + k := keybytesToHex(key) + _, err := t.markToCollect(t.root, k, 0) + if err != nil { + if errors.Is(err, ErrKVNotFound) { + err = ErrNotFound + } + return nil, err + } + } + } + err := t.collectNodes(t.root, persistTrie) + if err != nil { + return nil, err + } + data, err := cbor.Marshal(persistTrie) + return data, err +} + +func (t *WeightedMerkleTrie) collectNodes(node Node, persistTrie *PersistTrie) error { + if node == nil { + return nil + } + + if !node.ToCollect() { + if r, ok := node.(*routingNode); ok { + node = &hashNode{ + hash: r.hash, + weight: r.weight, + } + } + } + + data, err := node.Serialize() + if err != nil { + return err + } + persistTrie.Pairs = append(persistTrie.Pairs, &PersistTriePair{ + Value: data, + }) + + switch n := node.(type) { + case *routingNode: + for _, child := range n.Children { + t.collectNodes(child, persistTrie) + } + case *shortNode: + t.collectNodes(n.value, persistTrie) + } + return nil +} + +func (t *WeightedMerkleTrie) markToCollect(node Node, key []byte, pos int) (Node, error) { + if node == nil { + return nil, nil + } + + switch n := node.(type) { + case *routingNode: + child, err := t.markToCollect(n.Children[key[pos]], key, pos+1) + if err != nil { + return nil, err + } + n.Children[key[pos]] = child + n.toCollect = true + return n, nil + case *shortNode: + n.toCollect = true + if len(key)-pos < len(n.key) || !bytes.Equal(n.key, key[pos:pos+len(n.key)]) { + return n, nil + } + child, err := t.markToCollect(n.value, key, pos+len(n.key)) + if err != nil { + return nil, err + } + n.value = child + return n, nil + case *hashNode: + rn, err := t.resolveHashNode(n) + if err != nil { + return nil, err + } + return t.markToCollect(rn, key, pos) + } + return node, nil +} + +func (t *WeightedMerkleTrie) Deserialize(data []byte) error { + persistTrie := &PersistTrie{} + dm, err := cbor.DecOptions{ + MaxArrayElements: 1342177280, + MaxMapPairs: 1342177280, + }.DecMode() + if err != nil { + return err + } + err = dm.Unmarshal(data, persistTrie) + if err != nil { + return err + } + if len(persistTrie.Pairs) == 0 { + return nil + } + ind := 0 + t.root, err = t.deserializeTrie(persistTrie.Pairs, &ind) + if err != nil { + return err + } + hash := t.root.Hash() + switch n := t.root.(type) { + case *routingNode: + n.dirty = true + n.CalcHash() + case *shortNode: + n.dirty = true + n.CalcHash() + } + if !bytes.Equal(hash, t.root.Hash()) { + return errors.New("root hash mismatch") + } + return nil +} + +func (t *WeightedMerkleTrie) deserializeTrie(pairs []*PersistTriePair, ind *int) (Node, error) { + if len(pairs) == 0 { + return nil, nil + } + if *ind >= len(pairs) { + return nil, errors.New("index out of bounds") + } + + node, err := DeserializeNode(pairs[*ind].Value) + if err != nil { + return nil, err + } + *ind++ + + switch n := node.(type) { + case *routingNode: + for i := 0; i < branchNodeLength; i++ { + if n.Children[i] != nil { + child, err := t.deserializeTrie(pairs, ind) + if err != nil { + return nil, err + } + if !bytes.Equal(n.Children[i].Hash(), child.Hash()) { + return nil, errors.New("child hash mismatch") + } + n.Children[i] = child + } + } + case *shortNode: + child, err := t.deserializeTrie(pairs, ind) + if err != nil { + return nil, err + } + if !bytes.Equal(n.value.Hash(), child.Hash()) { + return nil, errors.New("child hash mismatch") + } + n.value = child + } + return node, nil +} diff --git a/core/util/wmpt/path_test.go b/core/util/wmpt/path_test.go new file mode 100644 index 0000000..3539784 --- /dev/null +++ b/core/util/wmpt/path_test.go @@ -0,0 +1,65 @@ +package wmpt + +import ( + "crypto/sha256" + "strconv" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGetPath(t *testing.T) { + keys := make([][]byte, 0, 5) + for i := 0; i < 5; i++ { + hash := sha256.Sum256([]byte(strconv.Itoa(i))) + keys = append(keys, hash[:]) + } + trie := New(nil, nil) + trie.Update(keys[0], []byte("hello"), 10) + trie.Update(keys[1], []byte("hi"), 9) + trie.Update(keys[2], []byte("hello"), 7) + trie.Update(keys[3], []byte("hello"), 7) + trie.Update(keys[4], []byte("hi"), 10) + trie.root.CalcHash() + getKeys := [][]byte{ + keys[2], + keys[3], + } + path, err := trie.GetPath(getKeys) + assert.NoError(t, err) + newTrie := New(nil, nil) + err = newTrie.Deserialize(path) + assert.NoError(t, err) + assert.Equal(t, newTrie.root.Weight(), trie.root.Weight()) + err = newTrie.Update(keys[3], []byte("hi"), 12) + assert.NoError(t, err) + err = trie.Update(keys[3], []byte("hi"), 12) + assert.NoError(t, err) + assert.Equal(t, newTrie.root.Weight(), trie.root.Weight()) + assert.Equal(t, newTrie.root.CalcHash(), trie.root.CalcHash()) + err = newTrie.Update(keys[2], nil, 0) + assert.NoError(t, err) + err = trie.Update(keys[2], nil, 0) + assert.NoError(t, err) + assert.Equal(t, newTrie.root.Weight(), trie.root.Weight()) + assert.Equal(t, newTrie.root.CalcHash(), trie.root.CalcHash()) +} + +func TestPathAndDelete(t *testing.T) { + trie := New(nil, nil) + keys := make([][]byte, 0, 100) + for i := 0; i < 100; i++ { + hash := sha256.Sum256([]byte(strconv.Itoa(i))) + keys = append(keys, hash[:]) + trie.Update(hash[:], []byte{byte(i)}, uint64(i)) + } + trie.root.CalcHash() + path, err := trie.GetPath([][]byte{keys[50]}) + assert.NoError(t, err) + newTrie := New(nil, nil) + err = newTrie.Deserialize(path) + assert.NoError(t, err) + assert.Equal(t, newTrie.root.Weight(), trie.root.Weight()) + err = newTrie.Update(keys[50], nil, 0) + assert.NoError(t, err) +} diff --git a/core/util/wmpt/proof.go b/core/util/wmpt/proof.go new file mode 100644 index 0000000..2ce01bb --- /dev/null +++ b/core/util/wmpt/proof.go @@ -0,0 +1,160 @@ +package wmpt + +import ( + "errors" + + "github.com/fxamacker/cbor/v2" +) + +func (t *WeightedMerkleTrie) GetBlockProof(block uint64) (key, proof []byte, err error) { + if t.root == nil { + return nil, nil, ErrNotFound + } + if block > t.root.Weight() { + return nil, nil, ErrWeightNotInRange + } + persistTrie := &PersistTrie{} + key, err = t.getBlockProof(t.root, block, nil, persistTrie) + if err != nil { + if errors.Is(err, ErrKVNotFound) { + return nil, nil, ErrNotFound + } + return nil, nil, err + } + key = hexToKeybytes(key) + proof, err = cbor.Marshal(persistTrie) + if err != nil { + return nil, nil, err + } + return +} + +func (t *WeightedMerkleTrie) getBlockProof(node Node, block uint64, prefix []byte, persistTrie *PersistTrie) (key []byte, err error) { + if node == nil { + return nil, ErrNotFound + } + + data, err := node.Serialize() + if err != nil { + return nil, err + } + + switch n := node.(type) { + case *routingNode: + for i, child := range &n.Children { + if child == nil { + continue + } + if block <= child.Weight() { + persistTrie.Pairs = append(persistTrie.Pairs, &PersistTriePair{ + Value: data, + }) + return t.getBlockProof(child, block, append(prefix, byte(i)), persistTrie) + } + block -= child.Weight() + } + case *shortNode: + if block > n.Weight() { + return nil, ErrWeightNotInRange + } + persistTrie.Pairs = append(persistTrie.Pairs, &PersistTriePair{ + Value: data, + }) + return t.getBlockProof(n.value, block, append(prefix, n.key...), persistTrie) + case *valueNode: + persistTrie.Pairs = append(persistTrie.Pairs, &PersistTriePair{ + Value: data, + }) + return prefix, nil + case *hashNode: + rn, err := t.resolveHashNode(n) + if err != nil { + return nil, err + } + return t.getBlockProof(rn, block, prefix, persistTrie) + } + + return nil, ErrNotFound +} + +func (t *WeightedMerkleTrie) VerifyBlockProof(block uint64, proof []byte) (hash, value []byte, err error) { + if len(proof) == 0 { + return nil, nil, errors.New("proof is empty") + } + persistTrie := &PersistTrie{} + dm, err := cbor.DecOptions{ + MaxArrayElements: 1342177280, + MaxMapPairs: 1342177280, + }.DecMode() + if err != nil { + return nil, nil, err + } + err = dm.Unmarshal(proof, persistTrie) + if err != nil { + return nil, nil, err + } + if len(persistTrie.Pairs) == 0 { + return nil, nil, errors.New("proof is empty") + } + ind := 0 + t.root, value, err = verifyProof(persistTrie, block, &ind) + if err != nil { + return nil, nil, err + } + hash = t.root.Hash() + return +} + +func verifyProof(persistTrie *PersistTrie, block uint64, ind *int) (Node, []byte, error) { + if *ind >= len(persistTrie.Pairs) { + return nil, nil, errors.New("index out of bounds") + } + + node, err := DeserializeNode(persistTrie.Pairs[*ind].Value) + if err != nil { + return nil, nil, err + } + *ind++ + + switch n := node.(type) { + case *routingNode: + for i := 0; i < len(&n.Children); i++ { + if n.Children[i] == nil { + continue + } + child := n.Children[i] + if block <= child.Weight() { + newNode, val, err := verifyProof(persistTrie, block, ind) + if err != nil { + return nil, nil, err + } + n.Children[i] = newNode + n.dirty = true + n.CalcHash() + return n, val, nil + } + block -= child.Weight() + } + return nil, nil, ErrWeightNotInRange + case *shortNode: + if block > n.Weight() { + return nil, nil, ErrWeightNotInRange + } + newNode, val, err := verifyProof(persistTrie, block, ind) + if err != nil { + return nil, nil, err + } + n.value = newNode + n.dirty = true + n.CalcHash() + return n, val, nil + case *valueNode: + if block > n.Weight() { + return nil, nil, ErrWeightNotInRange + } + n.dirty = true + n.CalcHash() + return n, n.value, nil + } + return nil, nil, errors.New("invalid node") +} diff --git a/core/util/wmpt/proof_test.go b/core/util/wmpt/proof_test.go new file mode 100644 index 0000000..b0f508a --- /dev/null +++ b/core/util/wmpt/proof_test.go @@ -0,0 +1,32 @@ +package wmpt + +import ( + "crypto/sha256" + "strconv" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGetBlockProof(t *testing.T) { + keys := make([][]byte, 0, 5) + for i := 0; i < 5; i++ { + hash := sha256.Sum256([]byte(strconv.Itoa(i))) + keys = append(keys, hash[:]) + } + trie := New(nil, nil) + trie.Update(keys[0], []byte("hello"), 10) + trie.Update(keys[1], []byte("hi"), 9) + trie.Update(keys[2], []byte("hello"), 7) + trie.Update(keys[3], []byte("hello"), 7) + trie.Update(keys[4], []byte("hi"), 10) + trie.root.CalcHash() + key, proof, err := trie.GetBlockProof(10) + assert.NoError(t, err) + assert.Equal(t, key, keys[4]) + newTrie := New(nil, nil) + h, v, err := newTrie.VerifyBlockProof(10, proof) + assert.NoError(t, err) + assert.Equal(t, h, trie.root.Hash()) + assert.Equal(t, v, []byte("hi")) +} diff --git a/core/util/wmpt/trie.go b/core/util/wmpt/trie.go new file mode 100644 index 0000000..6c14250 --- /dev/null +++ b/core/util/wmpt/trie.go @@ -0,0 +1,548 @@ +package wmpt + +import ( + "bytes" + "context" + "errors" + "sync" + + "github.com/0chain/common/core/encryption" + "github.com/0chain/common/core/util/storage" + "golang.org/x/sync/errgroup" +) + +var ( + // emptyState is the known hash of an empty state trie entry. + emptyState = encryption.EmptyHashBytes + ErrNotFound = errors.New("not found") + ErrWeightNotInRange = errors.New("weight not in range") + ErrInvalidKey = errors.New("invalid key") +) + +const ( + keyLength = 32 +) + +type WeightedMerkleTrie struct { + root Node + db storage.StorageAdapter + oldRoot hashNode + deleted [][]byte + tempDeleted [][]byte + created [][]byte + sync.Mutex +} + +// New creates a new weighted merkle trie +func New(root Node, db storage.StorageAdapter) *WeightedMerkleTrie { + if root == nil { + root = emptyNode + } + return &WeightedMerkleTrie{db: db, root: root} +} + +func (t *WeightedMerkleTrie) CopyRoot(collapseLevel int) Node { + t.Lock() + defer t.Unlock() + if t.root == nil { + return emptyNode + } + return t.root.CopyRoot(0, collapseLevel) +} + +func (t *WeightedMerkleTrie) SetRoot(root Node) { + t.Lock() + defer t.Unlock() + t.root = root +} + +func (t *WeightedMerkleTrie) GetRoot() Node { + return t.root +} + +func (t *WeightedMerkleTrie) Update(key, value []byte, weight uint64) error { + if len(key) != keyLength { + return ErrInvalidKey + } + k := keybytesToHex(key) + t.Lock() + defer t.Unlock() + if t.root == nil { + t.root = emptyNode + } + if len(value) != 0 { + _, n, err := t.insert(t.root, nil, k, &valueNode{value: value, weight: weight, dirty: true}) + if err != nil { + return err + } + t.root = n + } else { + _, n, err := t.delete(t.root, nil, k) + if err != nil { + return err + } + t.root = n + if t.root == nil { + t.root = emptyNode + } + } + return nil +} + +func (t *WeightedMerkleTrie) insert(node Node, prefix, key []byte, value Node) (int64, Node, error) { + if len(key) == 0 { + if v, ok := node.(*valueNode); ok { + newVal := value.(*valueNode).value + if bytes.Equal(v.value, newVal) { + return 0, v, nil + } + change := int64(value.Weight()) - int64(v.Weight()) + v.weight = value.Weight() + v.value = newVal + v.dirty = true + return change, v, nil + } + return int64(value.Weight()), value, nil + } + + switch n := node.(type) { + case *routingNode: + n.dirty = true + change, newNode, err := t.insert(n.Children[key[0]], append(prefix, key[0]), key[1:], value) + if err != nil { + return 0, nil, err + } + n.weight = uint64(int64(n.weight) + change) + n.Children[key[0]] = newNode + return change, n, nil + case *shortNode: + n.dirty = true + prefixLen := commonPrefix(n.key, key) + if prefixLen == len(n.key) { + change, newNode, err := t.insert(n.value, append(prefix, key[:prefixLen]...), key[prefixLen:], value) + if err != nil { + return 0, nil, err + } + n.value = newNode + return change, n, nil + } + t.tempDeleted = append(t.tempDeleted, n.Hash()) + branch := &routingNode{dirty: true, weight: n.Weight() + value.Weight()} + var err error + _, branch.Children[n.key[prefixLen]], err = t.insert(nil, append(prefix, n.key[:prefixLen+1]...), n.key[prefixLen+1:], n.value) + if err != nil { + return 0, nil, err + } + _, branch.Children[key[prefixLen]], err = t.insert(nil, append(prefix, key[:prefixLen+1]...), key[prefixLen+1:], value) + if err != nil { + return 0, nil, err + } + if prefixLen == 0 { + return int64(value.Weight()), branch, nil + } + return int64(value.Weight()), &shortNode{key: key[:prefixLen], value: branch, dirty: true}, nil + case *hashNode: + rn, err := t.resolveHashNode(n) + if err != nil { + return 0, nil, err + } + return t.insert(rn, prefix, key, value) + case nil: + return int64(value.Weight()), &shortNode{key: key, value: value, dirty: true}, nil + case *nilNode: + return int64(value.Weight()), &shortNode{key: key, value: value, dirty: true}, nil + default: + return 0, nil, errors.New("unknown node type") + } +} + +func (t *WeightedMerkleTrie) delete(node Node, prefix, key []byte) (uint64, Node, error) { + switch n := node.(type) { + case *shortNode: + prefixLen := commonPrefix(n.key, key) + if prefixLen < len(n.key) { + return 0, n, ErrNotFound + } + if prefixLen == len(key) { + //delete the node + t.tempDeleted = append(t.tempDeleted, n.Hash(), n.value.Hash()) + return n.Weight(), nil, nil + } + //the key is longer than the short node key, call delete on the child + n.dirty = true + change, newNode, err := t.delete(n.value, append(prefix, key[:len(n.key)]...), key[len(n.key):]) + if err != nil { + return 0, nil, err + } + switch child := newNode.(type) { + case *shortNode: + //merge the short node + newKey := make([]byte, len(n.key)+len(child.key)) + copy(newKey, n.key) + copy(newKey[len(n.key):], child.key) + n.key = newKey + n.value = child.value + return change, n, nil + default: + n.value = newNode + return change, n, nil + } + case *routingNode: + change, newNode, err := t.delete(n.Children[key[0]], append(prefix, key[0]), key[1:]) + if err != nil { + return 0, nil, err + } + n.dirty = true + n.Children[key[0]] = newNode + n.weight -= change + //if child is not nil, we can return the branching node as it has at least 2 children + if newNode != nil { + return change, n, nil + } + //Reduction: + // check if n has only one child, if so, merge it with the child + pos := -1 + for i, child := range &n.Children { + if child != nil { + if pos == -1 { + pos = i + } else { + pos = -2 + break + } + } + } + if pos >= 0 { + t.tempDeleted = append(t.tempDeleted, n.Hash()) + cnode, err := t.resolve(n.Children[pos]) + if err != nil { + return 0, nil, err + } + // merge if the child is short node + if cnode, ok := cnode.(*shortNode); ok { + newKey := make([]byte, len(cnode.key)+1) + newKey[0] = byte(pos) + copy(newKey[1:], cnode.key) + t.tempDeleted = append(t.tempDeleted, cnode.Hash()) + newShortNode := &shortNode{ + key: newKey, + value: cnode.value, + dirty: true, + } + return change, newShortNode, nil + } + + return change, &shortNode{key: []byte{byte(pos)}, value: n.Children[pos], dirty: true}, nil + } + return change, n, nil + case *valueNode: + t.tempDeleted = append(t.tempDeleted, n.Hash()) + return n.weight, nil, nil + case nil: + return 0, nil, ErrNotFound + case *nilNode: + return 0, nil, ErrNotFound + case *hashNode: + rn, err := t.resolveHashNode(n) + if err != nil { + return 0, nil, err + } + return t.delete(rn, prefix, key) + default: + return 0, nil, errors.New("unknown node type") + } +} + +// Resolves the node by loading it from the database if it is a hash node, otherwise it returns the node +func (t *WeightedMerkleTrie) resolve(node Node) (Node, error) { + if t.db == nil { + return node, nil + } + if n, ok := node.(*hashNode); ok { + return t.resolveHashNode(n) + } + return node, nil +} + +func (t *WeightedMerkleTrie) resolveHashNode(node *hashNode) (Node, error) { + if t.db == nil { + return nil, errors.New("database is not set") + } + data, err := t.db.Get(node.Hash()) + if err != nil { + return nil, err + } + loadedNode, err := DeserializeNode(data) + return loadedNode, err +} + +// Put puts a key-value pair into the trie +func (t *WeightedMerkleTrie) Put(key, value []byte, weight uint64) error { + k := keybytesToHex(key) + _, newNode, err := t.insert(t.root, nil, k, &valueNode{value: value, weight: weight, dirty: true}) + if err != nil { + return err + } + t.root = newNode + return nil +} + +// SaveRoot saves the current root to the old root +func (t *WeightedMerkleTrie) SaveRoot() { + if t.root != nil { + t.oldRoot.hash = t.root.Hash() + t.oldRoot.weight = t.root.Weight() + } + t.created = nil +} + +// Rollback rolls back the trie to the previous root +func (t *WeightedMerkleTrie) Rollback() { + if t.oldRoot.weight > 0 { + t.root = &hashNode{ + hash: t.oldRoot.hash, + weight: t.oldRoot.weight, + } + } else { + t.root = emptyNode + } + if len(t.created) > 0 { + batcher := t.db.NewBatch() + for _, key := range t.created { + batcher.Delete(key) + } + batcher.Commit(false) + t.created = nil + } + t.tempDeleted = nil + t.DeleteNodes() //nolint:errcheck +} + +// DeleteNodes deletes the nodes from the underlying storage and sets nextDelete to the tempDeleted nodes collected in previous mutations +func (t *WeightedMerkleTrie) DeleteNodes() error { + if len(t.deleted) > 0 { + batcher := t.db.NewBatch() + for _, key := range t.deleted { + err := batcher.Delete(key) + if err != nil { + return err + } + } + err := batcher.Commit(false) + if err != nil { + return err + } + } + t.deleted = t.tempDeleted + t.tempDeleted = nil + return nil +} + +// Root returns the root hash of the trie, if the root is dirty, it will recalculate the hash +func (t *WeightedMerkleTrie) Root() []byte { + if t.root == nil { + return emptyState + } + if t.root.Dirty() { + return t.root.CalcHash() + } + return t.root.Hash() +} + +func (t *WeightedMerkleTrie) Weight() uint64 { + if t.root == nil { + return 0 + } + return t.root.Weight() +} + +// Commit collapses the trie to the specified level and returns the batcher and the deleted nodes, it is the caller's responsibility to commit the batch +func (t *WeightedMerkleTrie) Commit(collapseLevel int) (storage.Batcher, error) { + batcher := t.db.NewBatch() + root, ok := t.root.(*routingNode) + deleteChan := make(chan []byte, 10) + createdChan := make(chan []byte, 10) + wg := &sync.WaitGroup{} + defer func() { + close(deleteChan) + close(createdChan) + wg.Wait() + }() + t.collectDeleteAndCreated(deleteChan, createdChan, wg) + if ok { + eg, _ := errgroup.WithContext(context.Background()) + eg.SetLimit(5) + deleteChan <- root.Hash() + for i := 0; i < len(&root.Children); i++ { + if root.Children[i] == nil || !root.Children[i].Dirty() { + continue + } + ind := i + eg.Go(func() error { + var collapsedNode Node + collapsedNode, err := t.commit(root.Children[ind], batcher, collapseLevel, 1, deleteChan, createdChan) + if err != nil { + return err + } + if collapsedNode != nil { + root.Children[ind] = collapsedNode + } + return nil + }) + } + err := eg.Wait() + if err != nil { + return nil, err + } + err = root.Save(batcher) + if err != nil { + return nil, err + } + createdChan <- root.Hash() + t.root = root + return batcher, nil + } + node, err := t.commit(t.root, batcher, collapseLevel, 0, deleteChan, createdChan) + if err != nil { + return nil, err + } + t.root = node + return batcher, nil +} + +func (t *WeightedMerkleTrie) RollbackTrie(node Node) { + if node == nil || node.Weight() == 0 { + node = emptyNode + } else if bytes.Equal(node.Hash(), t.root.Hash()) { + return + } + t.root = node + if len(t.created) > 0 { + batcher := t.db.NewBatch() + for _, hash := range t.created { + _ = batcher.Delete(hash) + } + batcher.Commit(false) //nolint:errcheck + } + t.created = nil + t.deleted = nil +} + +func (t *WeightedMerkleTrie) Delete(key []byte) (uint64, error) { + if t.root == nil { + return 0, ErrNotFound + } + k := keybytesToHex(key) + change, node, err := t.delete(t.root, nil, k) + if err != nil { + return 0, err + } + t.root = node + if t.root == nil { + t.root = emptyNode + } + return change, nil +} + +func (t *WeightedMerkleTrie) commit(node Node, batcher storage.Batcher, collapseLevel, level int, deleteChan, createdChan chan []byte) (Node, error) { + if node == nil { + return nil, nil + } + + if !node.Dirty() { + return node, nil + } + deleteChan <- node.Hash() + var err error + switch n := node.(type) { + case *routingNode: + for i := 0; i < len(n.Children); i++ { + if n.Children[i] == nil || !n.Children[i].Dirty() { + continue + } + var collapsedNode Node + collapsedNode, err = t.commit(n.Children[i], batcher, collapseLevel, level+1, deleteChan, createdChan) + if err != nil { + return nil, err + } + if collapsedNode != nil { + n.Children[i] = collapsedNode + } + } + err = n.Save(batcher) + if err != nil { + return nil, err + } + if level == collapseLevel { + n.Children = [16]Node{} + return &hashNode{ + hash: n.Hash(), + weight: n.Weight(), + }, nil + } + createdChan <- n.Hash() + return n, nil + case *shortNode: + collapsedNode, err := t.commit(n.value, batcher, collapseLevel, level+1, deleteChan, createdChan) + if err != nil { + return nil, err + } + if collapsedNode != nil { + n.value = collapsedNode + } + err = n.Save(batcher) + if err != nil { + return nil, err + } + if level == collapseLevel { + hn := &hashNode{ + hash: n.value.Hash(), + weight: n.Weight(), + } + n.value = hn + } + createdChan <- n.Hash() + return n, nil + case *valueNode: + err = n.Save(batcher) + if err != nil { + return nil, err + } + createdChan <- n.Hash() + return n, nil + } + + return node, nil +} + +func commonPrefix(a, b []byte) int { + var i, length = 0, len(a) + if len(b) < length { + length = len(b) + } + for ; i < length; i++ { + if a[i] != b[i] { + break + } + } + return i +} + +func (t *WeightedMerkleTrie) collectDeleteAndCreated(deleteChan, createdChan chan []byte, wg *sync.WaitGroup) { + t.created = nil + wg.Add(2) + go func() { + for hash := range deleteChan { + if len(hash) > 0 { + t.tempDeleted = append(t.tempDeleted, hash) + } + } + wg.Done() + }() + go func() { + for hash := range createdChan { + t.created = append(t.created, hash) + } + wg.Done() + }() +} diff --git a/core/util/wmpt/trie_test.go b/core/util/wmpt/trie_test.go new file mode 100644 index 0000000..b9c302f --- /dev/null +++ b/core/util/wmpt/trie_test.go @@ -0,0 +1,209 @@ +package wmpt + +import ( + "crypto/sha256" + "os" + "path/filepath" + "strconv" + "testing" + + "github.com/0chain/common/core/util/storage/kv" + "github.com/stretchr/testify/assert" +) + +func TestSerializeHashNode(t *testing.T) { + hash := sha256.Sum256([]byte("hello")) + node := hashNode{hash: hash[:], weight: 100000000000} + data, err := node.Serialize() + assert.NoError(t, err) + assert.Equal(t, 1, len(data)) +} + +func TestInsertOrderSensitive(t *testing.T) { + // pebDir := "/pebble/storage" + // os.RemoveAll(pebDir) + // os.MkdirAll(pebDir, 0777) + // defer os.RemoveAll(pebDir) + // db, err := storage.NewPebbleAdapter(pebDir) + // if err != nil { + // t.Fatal(err) + // } + keys := make([][]byte, 0, 5) + for i := 0; i < 5; i++ { + hash := sha256.Sum256([]byte(strconv.Itoa(i))) + keys = append(keys, hash[:]) + } + trie := New(nil, nil) + trie.Update(keys[0], []byte("hello"), 10) + trie.Update(keys[1], []byte("hi"), 9) + trie.Update(keys[2], []byte("hello"), 7) + trie.Update(keys[3], []byte("hello"), 7) + trie.Update(keys[4], []byte("hi"), 6) + + newTrie := New(nil, nil) + newTrie.Update(keys[4], []byte("hi"), 6) + newTrie.Update(keys[3], []byte("hello"), 7) + newTrie.Update(keys[2], []byte("hello"), 7) + newTrie.Update(keys[1], []byte("hi"), 9) + newTrie.Update(keys[0], []byte("hello"), 10) + assert.Equal(t, trie.root.Weight(), newTrie.root.Weight()) + assert.Equal(t, trie.root.CalcHash(), newTrie.root.CalcHash()) +} + +func TestTrieUpdate(t *testing.T) { + keys := make([][]byte, 0, 5) + for i := 0; i < 5; i++ { + hash := sha256.Sum256([]byte(strconv.Itoa(i))) + keys = append(keys, hash[:]) + } + trie := New(nil, nil) + trie.Update(keys[0], []byte("hello"), 10) + trie.Update(keys[0], []byte("hi"), 9) + trie.root.CalcHash() + assert.Equal(t, trie.root.Weight(), uint64(9)) +} + +func TestEmptyTrie(t *testing.T) { + trie := New(nil, nil) + assert.Equal(t, trie.root.CalcHash(), emptyState) + assert.Equal(t, trie.root.Weight(), uint64(0)) +} + +func TestTrieDelete(t *testing.T) { + keys := make([][]byte, 0, 5) + for i := 0; i < 5; i++ { + hash := sha256.Sum256([]byte(strconv.Itoa(i))) + keys = append(keys, hash[:]) + } + trie := New(nil, nil) + trie.Update(keys[0], []byte("a"), 10) + trie.Update(keys[1], []byte("b"), 9) + trie.Update(keys[2], []byte("c"), 7) + trie.Update(keys[3], []byte("d"), 7) + trie.root.CalcHash() + assert.Equal(t, trie.root.Weight(), uint64(33)) + h1 := trie.root.CalcHash() + trie.Update(keys[3], nil, 0) + assert.Equal(t, trie.root.Weight(), uint64(26)) + trie.Update(keys[3], []byte("d"), 7) + h2 := trie.root.CalcHash() + assert.Equal(t, trie.root.Weight(), uint64(33)) + assert.Equal(t, h1, h2) +} + +func TestTrieCommit(t *testing.T) { + keys := make([][]byte, 0, 5) + for i := 0; i < 5; i++ { + hash := sha256.Sum256([]byte(strconv.Itoa(i))) + keys = append(keys, hash[:]) + } + trie := New(nil, nil) + trie.Update(keys[0], []byte("a"), 10) + trie.Update(keys[1], []byte("b"), 9) + trie.Update(keys[2], []byte("c"), 7) + trie.Update(keys[3], []byte("d"), 7) + trie.root.CalcHash() + wd, err := os.Getwd() + assert.NoError(t, err) + pebDir := filepath.Join(wd, "pebble_storage") + assert.NoError(t, os.RemoveAll(pebDir)) + assert.NoError(t, os.MkdirAll(pebDir, 0777)) + db, err := kv.NewPebbleAdapter(pebDir, nil) + if err != nil { + t.Fatal(err) + } + defer func() { + db.Close() + os.RemoveAll(pebDir) + }() + dbTrie := New(nil, db) + dbTrie.Update(keys[0], []byte("a"), 10) + dbTrie.Update(keys[1], []byte("b"), 9) + dbTrie.Update(keys[2], []byte("c"), 7) + dbTrie.Update(keys[3], []byte("d"), 7) + batcher, err := dbTrie.Commit(0) + assert.NoError(t, err) + err = batcher.Commit(true) + assert.NoError(t, err) + assert.Equal(t, trie.root.Weight(), dbTrie.root.Weight()) + assert.Equal(t, trie.root.Hash(), dbTrie.root.Hash()) + dbTrie.DeleteNodes() + dbTrie.Update(keys[4], []byte("e"), 6) + trie.Update(keys[4], []byte("e"), 6) + batcher, err = dbTrie.Commit(0) + assert.NoError(t, err) + err = batcher.Commit(true) + assert.NoError(t, err) + dbTrie.DeleteNodes() + assert.Equal(t, trie.root.Weight(), dbTrie.root.Weight()) + assert.Equal(t, trie.root.CalcHash(), dbTrie.root.Hash()) +} + +func TestRollbackTrie(t *testing.T) { + keys := make([][]byte, 0, 5) + for i := 0; i < 5; i++ { + hash := sha256.Sum256([]byte(strconv.Itoa(i))) + keys = append(keys, hash[:]) + } + wd, err := os.Getwd() + assert.NoError(t, err) + pebDir := filepath.Join(wd, "pebble_storage") + assert.NoError(t, os.RemoveAll(pebDir)) + assert.NoError(t, os.MkdirAll(pebDir, 0777)) + db, err := kv.NewPebbleAdapter(pebDir, nil) + if err != nil { + t.Fatal(err) + } + defer func() { + db.Close() + os.RemoveAll(pebDir) + }() + dbTrie := New(nil, db) + dbTrie.Update(keys[0], []byte("a"), 10) + dbTrie.Update(keys[1], []byte("b"), 9) + dbTrie.Update(keys[2], []byte("c"), 7) + batcher, err := dbTrie.Commit(0) + assert.NoError(t, err) + err = batcher.Commit(true) + assert.NoError(t, err) + assert.NoError(t, dbTrie.DeleteNodes()) + rootNode := &hashNode{ + weight: dbTrie.root.Weight(), + hash: dbTrie.root.Hash(), + } + _, _, err = dbTrie.GetBlockProof(21) + assert.NoError(t, err) + dbTrie.Update(keys[3], []byte("d"), 7) + batcher, err = dbTrie.Commit(0) + assert.NoError(t, err) + err = batcher.Commit(true) + assert.NoError(t, err) + assert.NoError(t, dbTrie.DeleteNodes()) + newHash := dbTrie.root.Hash() + dbTrie.RollbackTrie(rootNode) + assert.Equal(t, dbTrie.root.Weight(), uint64(26)) + assert.Equal(t, dbTrie.root.CalcHash(), rootNode.hash) + _, err = db.Get(newHash) + assert.Error(t, err) + _, err = db.Get(rootNode.hash) + assert.NoError(t, err) + _, _, err = dbTrie.GetBlockProof(21) + assert.NoError(t, err) +} + +func TestUpdateTrie(t *testing.T) { + keys := make([][]byte, 0, 5) + for i := 0; i < 5; i++ { + hash := sha256.Sum256([]byte(strconv.Itoa(i))) + keys = append(keys, hash[:]) + } + trie := New(nil, nil) + trie.Update(keys[0], []byte("a"), 10) + trie.Update(keys[1], []byte("b"), 10) + h1 := trie.root.CalcHash() + assert.Equal(t, trie.root.Weight(), uint64(20)) + trie.Update(keys[1], []byte("c"), 5) + h2 := trie.root.CalcHash() + assert.Equal(t, trie.root.Weight(), uint64(15)) + assert.NotEqual(t, h1, h2) +} diff --git a/core/util/wmpt/type.go b/core/util/wmpt/type.go new file mode 100644 index 0000000..e4a3b00 --- /dev/null +++ b/core/util/wmpt/type.go @@ -0,0 +1,44 @@ +package wmpt + +type ( + PersistNodeBase struct { + Branch *PersistNodeBranch `cbor:"10,keyasint,omitempty"` + Value *PersistNodeValue `cbor:"11,keyasint,omitempty"` + Short *PersistNodeShort `cbor:"12,keyasint,omitempty"` + NilNode *PersistNilNode `cbor:"13,keyasint,omitempty"` + HashNode *PersistHashNode `cbor:"14,keyasint,omitempty"` + } + + PersistNodeBranch struct { + _ struct{} `cbor:",toarray"` + Hash []byte + Children [][]byte `cbor:"omitempty"` + } + PersistNodeValue struct { + _ struct{} `cbor:",toarray"` + Value []byte + Hash []byte + Weight uint64 + } + PersistNodeShort struct { + _ struct{} `cbor:",toarray"` + Key []byte + Hash []byte + Value []byte + } + PersistNilNode struct { + } + PersistHashNode struct { + _ struct{} `cbor:",toarray"` + Hash []byte + Weight uint64 + } + PersistTrie struct { + _ struct{} `cbor:",toarray"` + Pairs []*PersistTriePair + } + PersistTriePair struct { + _ struct{} `cbor:",toarray"` + Value []byte + } +) diff --git a/go.mod b/go.mod index 77a397a..ce97f79 100644 --- a/go.mod +++ b/go.mod @@ -3,38 +3,69 @@ module github.com/0chain/common go 1.18 require ( + github.com/cockroachdb/pebble v1.1.2 github.com/hashicorp/golang-lru v0.5.4 github.com/linxGnu/grocksdb v1.8.0 github.com/shopspring/decimal v1.3.1 github.com/spf13/cast v1.5.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.12.0 - github.com/stretchr/testify v1.8.3 + github.com/stretchr/testify v1.9.0 github.com/tinylib/msgp v1.1.6 go.uber.org/atomic v1.7.0 go.uber.org/zap v1.21.0 - golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d + golang.org/x/crypto v0.7.0 + golang.org/x/sync v0.7.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 ) +require ( + github.com/DataDog/zstd v1.4.5 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cockroachdb/errors v1.11.3 // indirect + github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/redact v1.1.5 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/getsentry/sentry-go v0.27.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/klauspost/compress v1.16.0 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/prometheus/client_golang v1.12.0 // indirect + github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect + github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/procfs v0.7.3 // indirect + github.com/rogpeppe/go-internal v1.9.0 // indirect + github.com/x448/float16 v0.8.4 // indirect + golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect + google.golang.org/protobuf v1.33.0 // indirect +) + require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/fxamacker/cbor/v2 v2.7.0 github.com/hashicorp/hcl v1.0.0 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect - github.com/pelletier/go-toml/v2 v2.0.1 // indirect + github.com/pelletier/go-toml/v2 v2.0.5 // indirect github.com/philhofer/fwd v1.1.2-0.20210722190033-5c56ac6d0bb9 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spf13/afero v1.8.2 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.3.0 // indirect go.uber.org/multierr v1.6.0 // indirect - golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect - golang.org/x/text v0.3.7 // indirect - gopkg.in/ini.v1 v1.66.4 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/text v0.14.0 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index e4702ae..cf2c526 100644 --- a/go.sum +++ b/go.sum @@ -38,12 +38,27 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/0chain/msgp v1.1.62 h1:D/s/TYygUwQnMlvfHUjh56FEaI0wP2VfPVS0TTGGu9I= github.com/0chain/msgp v1.1.62/go.mod h1:g7jEyb18KPe65d9RRhGw+ThaJr5duyBH8eaFgBUor7Y= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= +github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -51,6 +66,20 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= +github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= +github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= +github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -63,9 +92,24 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -91,6 +135,12 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -102,7 +152,9 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -129,38 +181,92 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/linxGnu/grocksdb v1.8.0 h1:H4L/LhP7GOMf1j17oQAElHgVlbEje2h14A8Tz9cM2BE= github.com/linxGnu/grocksdb v1.8.0/go.mod h1:09CeBborffXhXdNpEcOeZrLKEnRtrZFEpFdPNI9Zjjg= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU= -github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= +github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg= +github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas= github.com/philhofer/fwd v1.1.2-0.20210722190033-5c56ac6d0bb9 h1:6ob53CVz+ja2i7easAStApZJlh7sxyq3Cm7g1Di6iqA= github.com/philhofer/fwd v1.1.2-0.20210722190033-5c56ac6d0bb9/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg= +github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= @@ -172,9 +278,10 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ= github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -182,10 +289,12 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.3.0 h1:mjC+YW8QpAdXibNi+vNWgzmgBH4+5l5dCXv8cNysBLI= github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -205,6 +314,7 @@ go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -212,8 +322,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -224,6 +334,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -250,6 +362,7 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -257,6 +370,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -280,6 +394,7 @@ golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -289,6 +404,7 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -300,10 +416,15 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -312,6 +433,7 @@ golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -324,6 +446,8 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -331,14 +455,18 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/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-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -346,8 +474,9 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -388,6 +517,7 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= @@ -397,6 +527,7 @@ golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= @@ -492,16 +623,26 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4= -gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=