Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

shared storage limit #2222

Open
wants to merge 2 commits into
base: trunk/insertion-status
Choose a base branch
from

Conversation

MBoldyrev
Copy link
Contributor

@MBoldyrev MBoldyrev commented Apr 11, 2019

Description of the Change

A set of classes providing a shared limit between several storages.

Benefits

Possible Drawbacks

Usage Examples or Tests [optional]

please refer to storage_shared_limit_test: https://github.com/MBoldyrev/iroha/blob/wip/mst-shared-limit/test/module/libs/storage_shared_limit/storage_shared_limit_test.cpp

Alternate Designs [optional]

@MBoldyrev MBoldyrev changed the title Wip/mst shared limit MST: propagator to PCS & shared limit Apr 11, 2019
@MBoldyrev MBoldyrev self-assigned this Apr 11, 2019
@MBoldyrev MBoldyrev added the mst multisignature transactions label Apr 11, 2019
@MBoldyrev MBoldyrev force-pushed the wip/mst-shared-limit branch from 9b98ea7 to a3e6f62 Compare April 12, 2019 08:42
@lebdron lebdron requested a review from muratovv April 12, 2019 11:17
Copy link
Contributor

@muratovv muratovv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed only the part of the PR. It seems we have to discuss the interface first and move further with the review.

irohad/multi_sig_transactions/impl/mst_processor_impl.cpp Outdated Show resolved Hide resolved
logger::LoggerPtr log)
: log_(std::move(log)),
pcs_(pcs),
pending_batches_(storage_limit->create<InternalStorage>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess better to create storage in the outer scope of the ctor and pass it here.

// when state does not contain transaction
if (this->rawInsert(rhs_batch)) {
// there is enough room for the new batch
BOOST_VERIFY_MSG(state_update.updated_state_->rawInsert(rhs_batch),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point to check the insertion twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we check the insertion to state update, which is expected to accept the batch unconditionally (it has no limits). and above we check the insertion to local storage, which is limited and may deny new batch, which is OK.

log_->info("Dropped a batch because it did not fit into storage: {}",
*rhs_batch);
}
return {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method should return void as I see. What is the default value is assumed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is a lambda that extracts batches to be moved from MstState's internal storage. The return type is any iterable, in this case it is a vector: https://github.com/hyperledger/iroha/blob/a3e6f62460abc4c086a94ca32c4c0c19ca7b98a8/irohad/multi_sig_transactions/state/impl/mst_state.cpp#L206


namespace iroha {

struct LimitableStorage {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add documentation for this and further classes/methods in this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like with this PR we want to solve two tasks:

  1. Limit some storage with an upper bound size
  2. Make "defer" remove from the collection.

The first task can be solved by StorageLimit strategy and this strategy should be passed into a collection as the dependency.

The second task should be solved by inheritance at the collection from an interface with such semantics:

template<typename Item>
class DeferRemove {
Proxy deferRemove(Key); // Key is some tag for removing objects from the collection here it is doesn't matter finalized interface. Only proxy is important here.
}

template<typename Item>
class Proxy {

Item release(); // method removes item from initial collection
private:
Iter<Item> obj; // there could be a pointer, iterator or identifier in the collection.
}

With this approach, all synchronization stuff will hold in the collection and will be consistent with the rest of the collection class and code will look cleaner because we separate two responsibilities - there is no intersection between add functionality in the collection and add which bad case of removing. Also, there is no need util classes such as MstToPcsPropagation because all stuff is doing in one subscribe on PCS.

irohad/multi_sig_transactions/storage/storage_limit.hpp Outdated Show resolved Hide resolved
irohad/multi_sig_transactions/storage/storage_limit.hpp Outdated Show resolved Hide resolved
Signed-off-by: Mikhail Boldyrev <[email protected]>
@MBoldyrev MBoldyrev force-pushed the wip/mst-shared-limit branch from a3e6f62 to 955cd2c Compare April 16, 2019 08:46
@MBoldyrev MBoldyrev changed the title MST: propagator to PCS & shared limit shared storage limit Apr 16, 2019
@MBoldyrev
Copy link
Contributor Author

The PR got too big and could be split to two: this one brings a more general shared storage limit, and #2230 employs it to limit MST storages.

@MBoldyrev MBoldyrev marked this pull request as ready for review April 16, 2019 09:07
@MBoldyrev MBoldyrev requested review from muratovv and lebdron April 16, 2019 09:07
Signed-off-by: Mikhail Boldyrev <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
mst multisignature transactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants