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

Bug/1702 adopt precompiled oracle #1713

Merged
merged 35 commits into from
Nov 23, 2023

Conversation

olehnikolaiev
Copy link
Contributor

@olehnikolaiev olehnikolaiev commented Oct 31, 2023

fixes #1702

added two category of test in unit tests
the first one in ClientTest.cpp to test that precompiled contracts return different value depending on current block timestamp
the second one in PrecompiledTests.cpp to test that skaled properly parses historical data in config

tested manually on local machine as following:

  • deploy oracle contract
  • send oracle request and wait for response
  • hard-code response to the attached contract. it will submit the response to verifyOracleResponse function
  • send txn to the contract that do the checkOracleResponse call. see result
    test.txt

to verify on qa network:

  • deploy oracle contract
  • stop one of the skaled containers
  • send oracle request and wait for response (you can use oracle-demo repo for it)
  • hard-code response to the attached contract. it will submit the response to verifyOracleResponse function
  • send txn to the contract that do the checkOracleResponse call. see result
  • do several node rotations on the chain
  • turn on the container that was stopped. wait till it catchup the txn with checkOracleResponse function and check its status.
  • wait for 2 snapshots interval to verify that stateRoot is the same on all nodes

Copy link

codecov bot commented Nov 1, 2023

Codecov Report

Merging #1713 (d301345) into v3.18.0 (9339f77) will increase coverage by 0.35%.
Report is 1 commits behind head on v3.18.0.
The diff coverage is 87.62%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           v3.18.0    #1713      +/-   ##
===========================================
+ Coverage    45.18%   45.53%   +0.35%     
===========================================
  Files          351      353       +2     
  Lines        51475    51633     +158     
===========================================
+ Hits         23258    23512     +254     
+ Misses       28217    28121      -96     

Copy link
Collaborator

@kladkogex kladkogex left a comment

Choose a reason for hiding this comment

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

Please use a patch mechanism to switch the code changes on at a particular block id

Also please provided a detailed explaination in pull request description how the pull request was tested

Copy link
Collaborator

@kladkogex kladkogex left a comment

Choose a reason for hiding this comment

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

please either add detailed comments how the fix was made (preferred)
Or describe details of the fix in pull request

@kladkogex kladkogex force-pushed the bug/1702-adopt-precompiled-oracle branch from df1aad9 to cfbd435 Compare November 7, 2023 15:31
kladkogex
kladkogex previously approved these changes Nov 8, 2023
@@ -677,19 +679,21 @@ static const std::list< std::string > g_listReadableConfigParts{ "sealEngine",
//"genesis.*"
//"params.*",

"skaleConfig.nodeInfo.wallets.ima.commonBLSPublicKey*",
"skaleConfig.nodeInfo.wallets.ima.BLSPublicKey*",
// skaled-1702
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove the commented out section

According to the code guidelines we do not keep dead code

@@ -677,19 +679,21 @@ static const std::list< std::string > g_listReadableConfigParts{ "sealEngine",
//"genesis.*"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove sealEngine parameter, since it is never used, and is always equal to ethHash

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please change stat_is_accessible_json_path fuction to use boost starts_with

return boost::algorithm::starts_with( callData, "skaleConfig.sChain.nodes." );
}

static std::pair< std::string, unsigned > parseHistoricFieldReuqest( const std::string& callData ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please improve so that exact matches are always used, so inccorect strings do not result in a match

Comment on lines +813 to +819
} else {
nlohmann::json joConfig = g_configAccesssor->getConfigJSON();
nlohmann::json joValue =
skutils::json_config_file_accessor::stat_extract_at_path( joConfig, rawName );
strValue = skutils::tools::trim_copy(
joValue.is_string() ? joValue.get< std::string >() : joValue.dump() );
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please change so that the else {} part is only used when the patch is enabled, since stat_extract_at_path is unsecure and complex. If it is needed, it needs to be rewritten in a clean and secure
way using standard C++ and boost libraries

strValue = skutils::tools::trim_copy(
joValue.is_string() ? joValue.get< std::string >() : joValue.dump() );
}

dev::u256 uValue( strValue.c_str() );
Copy link
Collaborator

Choose a reason for hiding this comment

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

c_str() is not needed here since the constructor takes std::string

@@ -677,19 +679,21 @@ static const std::list< std::string > g_listReadableConfigParts{ "sealEngine",
//"genesis.*"
//"params.*",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please correct stat_parse_u256_hex_or_dec() function.

The constructor of u256 boost::multiprecision::number can take both decimal and hex string and autodetect.

Therefore, this function can be simplified to just calling constructor of u256

libethereum/Precompiled.cpp Outdated Show resolved Hide resolved
libethereum/Precompiled.cpp Outdated Show resolved Hide resolved
libethereum/Precompiled.cpp Outdated Show resolved Hide resolved
dimalit
dimalit previously approved these changes Nov 13, 2023
kladkogex
kladkogex previously approved these changes Nov 21, 2023
dimalit
dimalit previously approved these changes Nov 22, 2023
@kladkogex kladkogex self-requested a review November 23, 2023 16:29
@olehnikolaiev olehnikolaiev merged commit 1de9f45 into v3.18.0 Nov 23, 2023
8 checks passed
@olehnikolaiev olehnikolaiev deleted the bug/1702-adopt-precompiled-oracle branch November 23, 2023 16:37
@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

adopt some of the precompiled contracts to process schain groups logic
4 participants