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

[release-8.0] Add exclusion list to disambiguation #2536

Merged
merged 1 commit into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@
<LOG_SC>false</LOG_SC>
<DISABLE_SCILLA_LIB>false</DISABLE_SCILLA_LIB>
<SCILLA_SERVER_PENDING_IN_MS>1500</SCILLA_SERVER_PENDING_IN_MS>
<disambiguate_exclusion_list>
<entry>
<CONTRACT_ADDRESS>0000000000000000000000000000000000000000</CONTRACT_ADDRESS>
</entry>
</disambiguate_exclusion_list>
</smart_contract>
<tests>
<ENABLE_CHECK_PERFORMANCE_LOG>false</ENABLE_CHECK_PERFORMANCE_LOG>
Expand Down
5 changes: 5 additions & 0 deletions constants_local.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@
<LOG_SC>true</LOG_SC>
<DISABLE_SCILLA_LIB>false</DISABLE_SCILLA_LIB>
<SCILLA_SERVER_PENDING_IN_MS>1500</SCILLA_SERVER_PENDING_IN_MS>
<disambiguate_exclusion_list>
<entry>
<CONTRACT_ADDRESS>0000000000000000000000000000000000000000</CONTRACT_ADDRESS>
</entry>
</disambiguate_exclusion_list>
</smart_contract>
<tests>
<ENABLE_CHECK_PERFORMANCE_LOG>false</ENABLE_CHECK_PERFORMANCE_LOG>
Expand Down
12 changes: 12 additions & 0 deletions src/common/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ ReadVerifierExclusionListFromConstantsFile() {
return result;
}

const vector<string> ReadDisambiguateExclusionListFromConstantsFile() {
auto pt = PTree::GetInstance();
vector<string> result;
for (auto& entry :
pt.get_child("node.smart_contract.disambiguate_exclusion_list")) {
result.emplace_back(entry.second.get<string>("CONTRACT_ADDRESS"));
}
return result;
}

bool ISOLATED_SERVER = false;

bool SCILLA_PPLIT_FLAG = true;
Expand Down Expand Up @@ -574,6 +584,8 @@ const bool DISABLE_SCILLA_LIB{
ReadConstantString("DISABLE_SCILLA_LIB", "node.smart_contract.") == "true"};
const unsigned int SCILLA_SERVER_PENDING_IN_MS{
ReadConstantNumeric("SCILLA_SERVER_PENDING_IN_MS", "node.smart_contract.")};
const vector<string> DISAMBIGUATE_EXCLUSION_LIST{
ReadDisambiguateExclusionListFromConstantsFile()};

// Test constants
const bool ENABLE_CHECK_PERFORMANCE_LOG{
Expand Down
2 changes: 2 additions & 0 deletions src/common/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ extern const bool ENABLE_SCILLA_MULTI_VERSION;
extern const bool LOG_SC;
extern const bool DISABLE_SCILLA_LIB;
extern const unsigned int SCILLA_SERVER_PENDING_IN_MS;
// TODO: Remove disambiguate_exclusion_list after data migration
extern const std::vector<std::string> DISAMBIGUATE_EXCLUSION_LIST;
// TODO: Remove FIELDS_MAP_DEPTH_INDICATOR after data migration
const std::string FIELDS_MAP_DEPTH_INDICATOR = "_fields_map_depth";
const std::string MAP_DEPTH_INDICATOR = "_depth";
Expand Down
27 changes: 17 additions & 10 deletions src/libData/AccountData/AccountStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,9 @@ bool AccountStore::MigrateContractStates(

for (const auto& i : m_state) {
Address address(i.first);
const string strAddress = address.hex();

LOG_GENERAL(INFO, "Address: " << address.hex());
LOG_GENERAL(INFO, "Address: " << strAddress);

Account account;
if (!account.DeserializeBase(bytes(i.second.begin(), i.second.end()), 0)) {
Expand All @@ -660,12 +661,12 @@ bool AccountStore::MigrateContractStates(
if (account.isContract()) {
account.SetAddress(address);
if (!contract_address_output_filename.empty()) {
os_1 << address.hex() << endl;
os_1 << strAddress << endl;
}
} else {
this->AddAccount(address, account, true);
if (!normal_address_output_filename.empty()) {
os_2 << address.hex() << endl;
os_2 << strAddress << endl;
}
continue;
}
Expand Down Expand Up @@ -747,12 +748,18 @@ bool AccountStore::MigrateContractStates(
.FetchStateJsonForContract(stateBeforeMigration, address, "", {},
true);

uint64_t gasRem = UINT64_MAX;
InvokeInterpreter(DISAMBIGUATE, disPrint, scilla_version, false, gasRem,
std::numeric_limits<uint128_t>::max(), ret_checker,
receipt);
if (find(DISAMBIGUATE_EXCLUSION_LIST.begin(),
DISAMBIGUATE_EXCLUSION_LIST.end(),
strAddress) != DISAMBIGUATE_EXCLUSION_LIST.end()) {
LOG_GENERAL(INFO, "Disambiguate skipped: " << strAddress);
} else {
uint64_t gasRem = UINT64_MAX;
InvokeInterpreter(DISAMBIGUATE, disPrint, scilla_version, false, gasRem,
std::numeric_limits<uint128_t>::max(), ret_checker,
receipt);

LOG_GENERAL(INFO, "Disambiguate tool output: " << disPrint);
LOG_GENERAL(INFO, "Disambiguate tool output: " << disPrint);
}

#if MIGRATE_INIT_JSON

Expand Down Expand Up @@ -801,7 +808,7 @@ bool AccountStore::MigrateContractStates(
numContractNullFixedStates++;
} else if (!compareStateJSONs(stateBeforeMigration,
stateAfterMigration)) {
LOG_GENERAL(INFO, "States changed for " << address.hex());
LOG_GENERAL(INFO, "States changed for " << strAddress);
numContractChangedStates++;
} else {
numContractUnchangedStates++;
Expand All @@ -816,7 +823,7 @@ bool AccountStore::MigrateContractStates(
bind1st(std::equal_to<char>(), SCILLA_INDEX_SEPARATOR));
if (fragments.size() < 3) {
LOG_GENERAL(WARNING,
"Error fetching (field_name, type): " << address.hex());
"Error fetching (field_name, type): " << strAddress);
} else {
LOG_GENERAL(
INFO, "field=" << fragments[2] << " type="
Expand Down