-
Notifications
You must be signed in to change notification settings - Fork 40
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
Conversation
SUGGESTIONS BEFORE MERGE:
|
Codecov Report
Additional details and impacted files@@ 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 |
There was a problem hiding this 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
There was a problem hiding this 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
df1aad9
to
cfbd435
Compare
libethereum/Precompiled.cpp
Outdated
@@ -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 |
There was a problem hiding this comment.
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
libethereum/Precompiled.cpp
Outdated
@@ -677,19 +679,21 @@ static const std::list< std::string > g_listReadableConfigParts{ "sealEngine", | |||
//"genesis.*" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
libethereum/Precompiled.cpp
Outdated
return boost::algorithm::starts_with( callData, "skaleConfig.sChain.nodes." ); | ||
} | ||
|
||
static std::pair< std::string, unsigned > parseHistoricFieldReuqest( const std::string& callData ) { |
There was a problem hiding this comment.
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
} 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() ); | ||
} |
There was a problem hiding this comment.
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
libethereum/Precompiled.cpp
Outdated
strValue = skutils::tools::trim_copy( | ||
joValue.is_string() ? joValue.get< std::string >() : joValue.dump() ); | ||
} | ||
|
||
dev::u256 uValue( strValue.c_str() ); |
There was a problem hiding this comment.
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
libethereum/Precompiled.cpp
Outdated
@@ -677,19 +679,21 @@ static const std::list< std::string > g_listReadableConfigParts{ "sealEngine", | |||
//"genesis.*" | |||
//"params.*", |
There was a problem hiding this comment.
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
…etwork/skaled into bug/1702-adopt-precompiled-oracle
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:
verifyOracleResponse
functioncheckOracleResponse
call. see resulttest.txt
to verify on qa network:
oracle-demo
repo for it)verifyOracleResponse
functioncheckOracleResponse
call. see resultcheckOracleResponse
function and check its status.