Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
remove block number
Signed-off-by: turuslan <[email protected]>
  • Loading branch information
turuslan committed Jul 29, 2022
commit 2f1726d85a999e86d6e97bdb83e4c922b09665b1
8 changes: 3 additions & 5 deletions core/runtime/runtime_api/impl/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@ namespace kagome::runtime {
const primitives::Block &block) {
OUTCOME_TRY(parent, header_repo_->getBlockHeader(block.header.parent_hash));
BOOST_ASSERT(parent.number == block.header.number - 1);
OUTCOME_TRY(changes_tracker_->onBlockExecutionStart(
block.header.parent_hash, parent.number));
OUTCOME_TRY(
changes_tracker_->onBlockExecutionStart(block.header.parent_hash));
OUTCOME_TRY(executor_->persistentCallAt<void>(
block.header.parent_hash, "Core_execute_block", block));
return outcome::success();
}

outcome::result<storage::trie::RootHash> CoreImpl::initialize_block(
const primitives::BlockHeader &header) {
OUTCOME_TRY(changes_tracker_->onBlockExecutionStart(
header.parent_hash,
header.number - 1)); // parent's number
OUTCOME_TRY(changes_tracker_->onBlockExecutionStart(header.parent_hash));
const auto res = executor_->persistentCallAt<void>(
header.parent_hash, "Core_initialize_block", header);
if (res.has_value()) {
Expand Down
3 changes: 1 addition & 2 deletions core/storage/changes_trie/changes_tracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ namespace kagome::storage::changes_trie {
* Supposed to be called when a block execution starts
*/
virtual outcome::result<void> onBlockExecutionStart(
primitives::BlockHash new_parent_hash,
primitives::BlockNumber new_parent_number) = 0;
primitives::BlockHash new_parent_hash) = 0;

/**
* Supposed to be called when an entry is put into the tracked storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ namespace kagome::storage::changes_trie {
logger_{log::createLogger("Storage Changes Tracker", "changes_trie")} {}

outcome::result<void> StorageChangesTrackerImpl::onBlockExecutionStart(
primitives::BlockHash new_parent_hash,
primitives::BlockNumber new_parent_number) {
primitives::BlockHash new_parent_hash) {
parent_hash_ = new_parent_hash;
// new block -- new extrinsics
actual_val_.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ namespace kagome::storage::changes_trie {
~StorageChangesTrackerImpl() override = default;

outcome::result<void> onBlockExecutionStart(
primitives::BlockHash new_parent_hash,
primitives::BlockNumber new_parent_number) override;
primitives::BlockHash new_parent_hash) override;

void onPut(const common::BufferView &key,
const common::BufferView &value,
Expand Down
8 changes: 3 additions & 5 deletions test/core/runtime/wavm/core_integration_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ TEST_F(CoreTest, DISABLED_VersionTest) {
*/
TEST_F(CoreTest, DISABLED_ExecuteBlockTest) {
auto block = createBlock("block_hash"_hash256, 42);
EXPECT_CALL(
*changes_tracker_,
onBlockExecutionStart(block.header.parent_hash, block.header.number - 1))
EXPECT_CALL(*changes_tracker_,
onBlockExecutionStart(block.header.parent_hash))
.WillOnce(Return(outcome::success()));

ASSERT_TRUE(core_->execute_block(block));
Expand All @@ -81,8 +80,7 @@ TEST_F(CoreTest, DISABLED_ExecuteBlockTest) {
*/
TEST_F(CoreTest, DISABLED_InitializeBlockTest) {
auto header = createBlockHeader("block_hash"_hash256, 42);
EXPECT_CALL(*changes_tracker_,
onBlockExecutionStart(header.parent_hash, header.number - 1))
EXPECT_CALL(*changes_tracker_, onBlockExecutionStart(header.parent_hash))
.WillOnce(Return(outcome::success()));

ASSERT_TRUE(core_->initialize_block(header));
Expand Down
3 changes: 1 addition & 2 deletions test/core/storage/changes_trie/changes_tracker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ TEST(ChangesTrieTest, IntegrationWithOverlay) {
std::shared_ptr<ChangesTracker> changes_tracker =
std::make_shared<StorageChangesTrackerImpl>(storage_subscription_engine,
chain_subscription_engine);
EXPECT_OUTCOME_TRUE_1(
changes_tracker->onBlockExecutionStart("aaa"_hash256, 42));
EXPECT_OUTCOME_TRUE_1(changes_tracker->onBlockExecutionStart("aaa"_hash256));
auto batch = PersistentTrieBatchImpl::create(
codec,
serializer,
Expand Down
3 changes: 1 addition & 2 deletions test/mock/core/storage/changes_trie/changes_tracker_mock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ namespace kagome::storage::changes_trie {
public:
MOCK_METHOD(outcome::result<void>,
onBlockExecutionStart,
(primitives::BlockHash new_parent_hash,
primitives::BlockNumber new_parent_number),
(primitives::BlockHash new_parent_hash),
(override));

MOCK_METHOD(void,
Expand Down