Skip to content

Commit

Permalink
Snapshot trie on submit extrinsic.
Browse files Browse the repository at this point in the history
  • Loading branch information
arijitAD committed Jun 18, 2021
1 parent 96c43de commit 0aa4c84
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 6 additions & 0 deletions dot/core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,12 @@ func (s *Service) HandleSubmittedExtrinsic(ext types.Extrinsic) error {
return nil
}

ts, err := s.storageState.TrieState(nil)
if err != nil {
return err
}
s.rt.SetContextStorage(ts)

// the transaction source is External
// validate the transaction
externalExt := types.Extrinsic(append([]byte{byte(types.TxnExternal)}, ext...))
Expand Down
9 changes: 1 addition & 8 deletions dot/state/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,7 @@ func (s *StorageState) TrieState(root *common.Hash) (*rtstorage.TrieState, error
s.lock.RUnlock()

if t != nil && t.MustHash() != *root {
var err error
t, err = s.LoadFromDB(*root)
if err != nil {
return nil, err
}
if t.MustHash() != *root {
panic("trie does not have expected root")
}
panic("trie does not have expected root")
}

if t == nil {
Expand Down
2 changes: 1 addition & 1 deletion tests/polkadotjs_test/start_polkadotjs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestStartGossamerAndPolkadotAPI(t *testing.T) {
command := "npx mocha ./test"
parts := strings.Fields(command)
data, err := exec.Command(parts[0], parts[1:]...).Output()
require.NoError(t, err, fmt.Sprintf("%s", data))
require.NoError(t, err, data)

//uncomment this to see log results from javascript tests
//fmt.Printf("%s\n", data)
Expand Down

0 comments on commit 0aa4c84

Please sign in to comment.