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

Commit e13a37e

Browse files
kamilsax3medima17
authored andcommitted
Feature/stateless validation rules (#1148)
* Introduce new stateless validation rules Signed-off-by: kamilsa <[email protected]>
1 parent 3ff318a commit e13a37e

40 files changed

+650
-697
lines changed

irohad/ametsuchi/impl/storage_impl.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,62 +121,62 @@ namespace iroha {
121121
protected:
122122
const std::string init_ = R"(
123123
CREATE TABLE IF NOT EXISTS role (
124-
role_id character varying(45),
124+
role_id character varying(32),
125125
PRIMARY KEY (role_id)
126126
);
127127
CREATE TABLE IF NOT EXISTS domain (
128-
domain_id character varying(164),
129-
default_role character varying(45) NOT NULL REFERENCES role(role_id),
128+
domain_id character varying(255),
129+
default_role character varying(32) NOT NULL REFERENCES role(role_id),
130130
PRIMARY KEY (domain_id)
131131
);
132132
CREATE TABLE IF NOT EXISTS signatory (
133133
public_key bytea NOT NULL,
134134
PRIMARY KEY (public_key)
135135
);
136136
CREATE TABLE IF NOT EXISTS account (
137-
account_id character varying(197),
138-
domain_id character varying(164) NOT NULL REFERENCES domain,
137+
account_id character varying(288),
138+
domain_id character varying(255) NOT NULL REFERENCES domain,
139139
quorum int NOT NULL,
140140
transaction_count int NOT NULL DEFAULT 0,
141141
data JSONB,
142142
PRIMARY KEY (account_id)
143143
);
144144
CREATE TABLE IF NOT EXISTS account_has_signatory (
145-
account_id character varying(197) NOT NULL REFERENCES account,
145+
account_id character varying(288) NOT NULL REFERENCES account,
146146
public_key bytea NOT NULL REFERENCES signatory,
147147
PRIMARY KEY (account_id, public_key)
148148
);
149149
CREATE TABLE IF NOT EXISTS peer (
150150
public_key bytea NOT NULL,
151-
address character varying(21) NOT NULL UNIQUE,
151+
address character varying(261) NOT NULL UNIQUE,
152152
PRIMARY KEY (public_key)
153153
);
154154
CREATE TABLE IF NOT EXISTS asset (
155-
asset_id character varying(197),
156-
domain_id character varying(164) NOT NULL REFERENCES domain,
155+
asset_id character varying(288),
156+
domain_id character varying(255) NOT NULL REFERENCES domain,
157157
precision int NOT NULL,
158158
data json,
159159
PRIMARY KEY (asset_id)
160160
);
161161
CREATE TABLE IF NOT EXISTS account_has_asset (
162-
account_id character varying(197) NOT NULL REFERENCES account,
163-
asset_id character varying(197) NOT NULL REFERENCES asset,
162+
account_id character varying(288) NOT NULL REFERENCES account,
163+
asset_id character varying(288) NOT NULL REFERENCES asset,
164164
amount decimal NOT NULL,
165165
PRIMARY KEY (account_id, asset_id)
166166
);
167167
CREATE TABLE IF NOT EXISTS role_has_permissions (
168-
role_id character varying(45) NOT NULL REFERENCES role,
168+
role_id character varying(32) NOT NULL REFERENCES role,
169169
permission_id character varying(45),
170170
PRIMARY KEY (role_id, permission_id)
171171
);
172172
CREATE TABLE IF NOT EXISTS account_has_roles (
173-
account_id character varying(197) NOT NULL REFERENCES account,
174-
role_id character varying(45) NOT NULL REFERENCES role,
173+
account_id character varying(288) NOT NULL REFERENCES account,
174+
role_id character varying(32) NOT NULL REFERENCES role,
175175
PRIMARY KEY (account_id, role_id)
176176
);
177177
CREATE TABLE IF NOT EXISTS account_has_grantable_permissions (
178-
permittee_account_id character varying(197) NOT NULL REFERENCES account,
179-
account_id character varying(197) NOT NULL REFERENCES account,
178+
permittee_account_id character varying(288) NOT NULL REFERENCES account,
179+
account_id character varying(288) NOT NULL REFERENCES account,
180180
permission_id character varying(45),
181181
PRIMARY KEY (permittee_account_id, account_id, permission_id)
182182
);

irohad/execution/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ target_link_libraries(command_execution
2626
${Boost_LIBRARIES}
2727
logger
2828
common_execution
29-
validator
3029
rxcpp
3130
shared_model_default_builders
3231
)

irohad/execution/impl/command_executor.cpp

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "interfaces/commands/command.hpp"
2424
#include "model/permissions.hpp"
2525
#include "utils/amount_utils.hpp"
26-
#include "validator/domain_name_validator.hpp"
2726

2827
namespace iroha {
2928

@@ -725,56 +724,33 @@ namespace iroha {
725724
const shared_model::interface::CreateAccount &command,
726725
ametsuchi::WsvQuery &queries,
727726
const shared_model::interface::types::AccountIdType &creator_account_id) {
728-
return
729-
// Name is within some range
730-
not command.accountName().empty()
731-
// Account must be well-formed (no system symbols)
732-
and ::validator::isValidDomainName(command.accountName());
727+
return true;
733728
}
734729

735730
bool CommandValidator::isValid(
736731
const shared_model::interface::CreateAsset &command,
737732
ametsuchi::WsvQuery &queries,
738733
const shared_model::interface::types::AccountIdType &creator_account_id) {
739-
return
740-
// Name is within some range
741-
not command.assetName().empty() && command.assetName().size() < 10 &&
742-
// Account must be well-formed (no system symbols)
743-
std::all_of(std::begin(command.assetName()),
744-
std::end(command.assetName()),
745-
[](char c) { return std::isalnum(c); });
734+
return true;
746735
}
747736

748737
bool CommandValidator::isValid(
749738
const shared_model::interface::CreateDomain &command,
750739
ametsuchi::WsvQuery &queries,
751740
const shared_model::interface::types::AccountIdType &creator_account_id) {
752-
return
753-
// Name is within some range
754-
not command.domainId().empty() and command.domainId().size() < 10 and
755-
// Account must be well-formed (no system symbols)
756-
std::all_of(std::begin(command.domainId()),
757-
std::end(command.domainId()),
758-
[](char c) { return std::isalnum(c); });
741+
return true;
759742
}
760743

761744
bool CommandValidator::isValid(
762745
const shared_model::interface::CreateRole &command,
763746
ametsuchi::WsvQuery &queries,
764747
const shared_model::interface::types::AccountIdType &creator_account_id) {
765-
auto role_is_a_subset = std::all_of(
748+
return std::all_of(
766749
command.rolePermissions().begin(),
767750
command.rolePermissions().end(),
768751
[&queries, &creator_account_id](auto perm) {
769752
return checkAccountRolePermission(creator_account_id, queries, perm);
770753
});
771-
772-
return role_is_a_subset and not command.roleName().empty()
773-
and command.roleName().size() < 8 and
774-
// Role must be well-formed (no system symbols)
775-
std::all_of(std::begin(command.roleName()),
776-
std::end(command.roleName()),
777-
[](char c) { return std::isalnum(c) and islower(c); });
778754
}
779755

780756
bool CommandValidator::isValid(
@@ -850,10 +826,6 @@ namespace iroha {
850826
const shared_model::interface::TransferAsset &command,
851827
ametsuchi::WsvQuery &queries,
852828
const shared_model::interface::types::AccountIdType &creator_account_id) {
853-
if (command.amount().intValue() == 0) {
854-
return false;
855-
}
856-
857829
auto asset = queries.getAsset(command.assetId());
858830
if (not asset) {
859831
return false;

irohad/model/execution/command_executor.hpp

Whitespace-only changes.

irohad/model/execution/command_executor_factory.hpp

Whitespace-only changes.

irohad/model/execution/common_executor.hpp

Whitespace-only changes.

irohad/model/execution/impl/command_executor.cpp

Whitespace-only changes.

irohad/model/execution/impl/command_executor_factory.cpp

Whitespace-only changes.

irohad/model/execution/impl/common_executor.cpp

Whitespace-only changes.

0 commit comments

Comments
 (0)