Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime/storage): support nested storage transactions #3670

Merged
merged 24 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c125f69
fix: manage `transactions` correctly (`commits` and `rollbacks`)
EclesioMeloJunior Jan 9, 2024
e16da76
docs(.github/contrib): add commits and PR styleguide to contribmd (#3…
P1sar Jan 5, 2024
d6a632a
chore(deps): bump golang.org/x/term from 0.15.0 to 0.16.0 (#3661)
dependabot[bot] Jan 8, 2024
4aaeb97
chore(deps): bump github.com/prometheus/client_golang from 1.17.0 to …
dependabot[bot] Jan 8, 2024
e6260b4
chore(deps): bump github.com/spf13/viper from 1.18.1 to 1.18.2 (#3664)
dependabot[bot] Jan 9, 2024
3d68312
chore(deps): bump github.com/ethereum/go-ethereum from 1.13.5 to 1.13…
dependabot[bot] Jan 9, 2024
2e81d89
chore: remove uneeded diffs
EclesioMeloJunior Jan 10, 2024
3765e3c
Merge branch 'development' into eclesio/trie-get-panic
EclesioMeloJunior Jan 10, 2024
6932dbd
chore: use `TrieState`
EclesioMeloJunior Jan 10, 2024
a6d3b03
Merge branch 'eclesio/trie-get-panic' of github.com:ChainSafe/gossame…
EclesioMeloJunior Jan 10, 2024
7567bf4
Merge branch 'development' into eclesio/trie-get-panic
EclesioMeloJunior Jan 11, 2024
02ed484
chore: fix lint
EclesioMeloJunior Jan 11, 2024
38c4501
chore: include tests for nested transactions
EclesioMeloJunior Jan 11, 2024
a6a6988
chore: fix `Test_chainSync_onBlockAnnounceHandshake_tipModeNeedToCatc…
EclesioMeloJunior Jan 11, 2024
38bf119
chore: replace `NewTrieState(nil)` to `NewTrieState(tries.EmptyTrie())`
EclesioMeloJunior Jan 11, 2024
b4fcea8
chore: use trie.EmptyTrie() instead of nil
EclesioMeloJunior Jan 11, 2024
7f8bbcb
chore: use `container/list` instead of arrays
EclesioMeloJunior Jan 11, 2024
fd13f68
Delete .DS_Store
EclesioMeloJunior Jan 12, 2024
35bf025
Merge branch 'development' into eclesio/trie-get-panic
EclesioMeloJunior Jan 12, 2024
89d8f45
chore: renaming methods
EclesioMeloJunior Jan 12, 2024
aff3927
chore: fix panic messag
EclesioMeloJunior Jan 12, 2024
aebb4ed
Merge branch 'development' into eclesio/trie-get-panic
EclesioMeloJunior Jan 12, 2024
cbb8f0c
Merge branch 'development' into eclesio/trie-get-panic
EclesioMeloJunior Jan 12, 2024
891b2b2
Merge branch 'development' into eclesio/trie-get-panic
EclesioMeloJunior Jan 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions dot/core/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func generateExtrinsic(t *testing.T) (extrinsic, externalExtrinsic types.Extrins
func Test_Service_StorageRoot(t *testing.T) {
t.Parallel()

ts := rtstorage.NewTrieState(nil)
ts := rtstorage.NewTrieState(trie.NewEmptyTrie())

tests := []struct {
name string
Expand Down Expand Up @@ -378,7 +378,7 @@ func Test_Service_handleBlock(t *testing.T) {

t.Run("storeTrie_error", func(t *testing.T) {
t.Parallel()
trieState := rtstorage.NewTrieState(nil)
trieState := rtstorage.NewTrieState(trie.NewEmptyTrie())

testHeader := types.NewEmptyHeader()
block := types.NewBlock(*testHeader, *types.NewBody([]types.Extrinsic{[]byte{21}}))
Expand All @@ -394,7 +394,7 @@ func Test_Service_handleBlock(t *testing.T) {

t.Run("addBlock_quit_error", func(t *testing.T) {
t.Parallel()
trieState := rtstorage.NewTrieState(nil)
trieState := rtstorage.NewTrieState(trie.NewEmptyTrie())

testHeader := types.NewEmptyHeader()
block := types.NewBlock(*testHeader, *types.NewBody([]types.Extrinsic{[]byte{21}}))
Expand All @@ -415,7 +415,7 @@ func Test_Service_handleBlock(t *testing.T) {

t.Run("addBlock_parent_not_found_error", func(t *testing.T) {
t.Parallel()
trieState := rtstorage.NewTrieState(nil)
trieState := rtstorage.NewTrieState(trie.NewEmptyTrie())

testHeader := types.NewEmptyHeader()
block := types.NewBlock(*testHeader, *types.NewBody([]types.Extrinsic{[]byte{21}}))
Expand All @@ -436,7 +436,7 @@ func Test_Service_handleBlock(t *testing.T) {

t.Run("addBlock_error_continue", func(t *testing.T) {
t.Parallel()
trieState := rtstorage.NewTrieState(nil)
trieState := rtstorage.NewTrieState(trie.NewEmptyTrie())

testHeader := types.NewEmptyHeader()
block := types.NewBlock(*testHeader, *types.NewBody([]types.Extrinsic{[]byte{21}}))
Expand Down Expand Up @@ -465,7 +465,7 @@ func Test_Service_handleBlock(t *testing.T) {

t.Run("handle_runtime_changes_error", func(t *testing.T) {
t.Parallel()
trieState := rtstorage.NewTrieState(nil)
trieState := rtstorage.NewTrieState(trie.NewEmptyTrie())

testHeader := types.NewEmptyHeader()
block := types.NewBlock(*testHeader, *types.NewBody([]types.Extrinsic{[]byte{21}}))
Expand Down Expand Up @@ -497,7 +497,7 @@ func Test_Service_handleBlock(t *testing.T) {

t.Run("code_substitution_ok", func(t *testing.T) {
t.Parallel()
trieState := rtstorage.NewTrieState(nil)
trieState := rtstorage.NewTrieState(trie.NewEmptyTrie())

testHeader := types.NewEmptyHeader()
block := types.NewBlock(*testHeader, *types.NewBody([]types.Extrinsic{[]byte{21}}))
Expand Down Expand Up @@ -544,7 +544,7 @@ func Test_Service_HandleBlockProduced(t *testing.T) {

t.Run("happy_path", func(t *testing.T) {
t.Parallel()
trieState := rtstorage.NewTrieState(nil)
trieState := rtstorage.NewTrieState(trie.NewEmptyTrie())

digest := types.NewDigest()
err := digest.Add(
Expand Down
8 changes: 4 additions & 4 deletions dot/sync/chain_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func Test_chainSync_onBlockAnnounce(t *testing.T) {
const somePeer = peer.ID("abc")

errTest := errors.New("test error")
emptyTrieState := storage.NewTrieState(nil)
emptyTrieState := storage.NewTrieState(trie.NewEmptyTrie())
block1AnnounceHeader := types.NewHeader(common.Hash{}, emptyTrieState.MustRoot(trie.NoMaxInlineValueSize),
common.Hash{}, 1, scale.VaryingDataTypeSlice{})
block2AnnounceHeader := types.NewHeader(block1AnnounceHeader.Hash(),
Expand Down Expand Up @@ -242,7 +242,7 @@ func Test_chainSync_onBlockAnnounceHandshake_tipModeNeedToCatchup(t *testing.T)
ctrl := gomock.NewController(t)
const somePeer = peer.ID("abc")

emptyTrieState := storage.NewTrieState(nil)
emptyTrieState := storage.NewTrieState(trie.NewEmptyTrie())
block1AnnounceHeader := types.NewHeader(common.Hash{}, emptyTrieState.MustRoot(trie.NoMaxInlineValueSize),
common.Hash{}, 1, scale.VaryingDataTypeSlice{})
block2AnnounceHeader := types.NewHeader(block1AnnounceHeader.Hash(),
Expand Down Expand Up @@ -1250,7 +1250,7 @@ func createSuccesfullBlockResponse(t *testing.T, parentHeader common.Hash,
response := new(network.BlockResponseMessage)
response.BlockData = make([]*types.BlockData, numBlocks)

emptyTrieState := storage.NewTrieState(nil)
emptyTrieState := storage.NewTrieState(trie.NewEmptyTrie())
tsRoot := emptyTrieState.MustRoot(trie.NoMaxInlineValueSize)

firstHeader := types.NewHeader(parentHeader, tsRoot, common.Hash{},
Expand Down Expand Up @@ -1303,7 +1303,7 @@ func ensureSuccessfulBlockImportFlow(t *testing.T, parentHeader *types.Header,
mockStorageState.EXPECT().Lock()
mockStorageState.EXPECT().Unlock()

emptyTrieState := storage.NewTrieState(nil)
emptyTrieState := storage.NewTrieState(trie.NewEmptyTrie())
parentStateRoot := previousHeader.StateRoot
mockStorageState.EXPECT().TrieState(&parentStateRoot).
Return(emptyTrieState, nil)
Expand Down
6 changes: 3 additions & 3 deletions lib/runtime/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type Storage interface {
ClearPrefix(prefix []byte) (err error)
ClearPrefixLimit(prefix []byte, limit uint32) (
deleted uint32, allDeleted bool, err error)
BeginStorageTransaction()
CommitStorageTransaction()
RollbackStorageTransaction()
StartTransaction()
Commit()
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
Rollback()
LoadCode() []byte
}

Expand Down
Loading
Loading