Skip to content

Commit

Permalink
fix(lib/babe): fix BABE state storing after building block (#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
noot authored Apr 22, 2021
1 parent e5ae30d commit 1a3dea2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ require (
golang.org/x/net v0.0.0-20200822124328-c89045814202 // indirect
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
golang.org/x/tools v0.0.0-20200221224223-e1da425f72fd
golang.org/x/tools v0.0.0-20200221224223-e1da425f72fd // indirect
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/protobuf v1.25.0
)
Expand Down
10 changes: 9 additions & 1 deletion lib/babe/babe.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/lib/crypto/sr25519"
"github.com/ChainSafe/gossamer/lib/runtime"
rtstorage "github.com/ChainSafe/gossamer/lib/runtime/storage"
log "github.com/ChainSafe/log15"
)

Expand Down Expand Up @@ -471,8 +472,15 @@ func (b *Service) handleSlot(slotNum uint64) error {
return nil
}

old := ts.Snapshot()

// block built successfully, store resulting trie in storage state
err = b.storageState.StoreTrie(ts)
oldTs, err := rtstorage.NewTrieState(old)
if err != nil {
return err
}

err = b.storageState.StoreTrie(oldTs)
if err != nil {
logger.Error("failed to store trie in storage state", "error", err)
}
Expand Down
3 changes: 1 addition & 2 deletions tests/polkadotjs_test/test_transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ async function main() {
const ADDR_Bob = '0x90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22';
// bob 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty

const transfer = await api.tx.balances.transfer(bobKey.address, 12345)
.signAndSend(aliceKey);
const transfer = await api.tx.balances.transfer(bobKey.address, 12345).signAndSend(aliceKey);
console.log(`hxHash ${transfer}`);
}

Expand Down

0 comments on commit 1a3dea2

Please sign in to comment.