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(lib/babe): fix BABE state storing after building block #1536

Merged
merged 4 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
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
5 changes: 1 addition & 4 deletions tests/polkadotjs_test/test_transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ async function main() {
const ADDR_Bob = '0x90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22';
// bob 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty

const transfer = await api.tx.balances.transfer(bobKey.address, 12345)
.signAndSend(aliceKey, {era: 0, blockHash: '0x64597c55a052d484d9ff357266be326f62573bb4fbdbb3cd49f219396fcebf78', blockNumber:0, genesisHash: '0x64597c55a052d484d9ff357266be326f62573bb4fbdbb3cd49f219396fcebf78', nonce: 1, tip: 0, transactionVersion: 1});

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

}

main().catch(console.error);
Expand Down