-
Notifications
You must be signed in to change notification settings - Fork 100
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
OracleService #326
OracleService #326
Conversation
return input; | ||
|
||
JObject beforeObject = JObject.Parse(input); | ||
JArray afterObjects = new JArray(beforeObject.SelectTokens(filterArgs).ToArray()); // TODO |
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.
Filter will be a json filter (XPATH), or a contract execution?
-> Contract execution it's harder because the execution fee but it's transparent to the nodes, if we use a XPATH filters we will have a lot of underterminism betwen different implementations or libraries.
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.
JSONPath
?
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.
According to neo-project/neo#1259 it seems that was decided JSONPath
but for me it has two important dissadvantages.
- Cost of gas, we will not have control over how much time was spent in this filter.
- Same implementation throughout the different systems.
But it's ok for me, I am not against to use JsonPath.
src/Oracle/Oracle.cs
Outdated
private CancellationTokenSource cancelSource; | ||
|
||
private static readonly IOracleProtocol Https = new OracleHttpProtocol(); | ||
private static readonly TimeSpan MaxTaskTimeout = TimeSpan.FromMinutes(5); |
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.
It should be configurable or stored in the policy
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.
Should this be related to the fees?
src/Oracle/Oracle.cs
Outdated
{ | ||
try | ||
{ | ||
var url = new Uri("http://" + node + "/"); |
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.
Maybe we should force oracles to have https with his publicKey
src/Oracle/Oracle.cs
Outdated
ECPoint[] nodes = NativeContract.Oracle.GetOracleNodes(snapshot); | ||
if (task.Signs.Count >= nodes.Length / 3 && task.Tx != null) | ||
{ | ||
var contract = Contract.CreateMultiSigContract(nodes.Length - (nodes.Length - 1) / 3, nodes); |
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.
We should add in rpc allowed nodes, or allowed client certificates, in order to allow or not only the oracle nodes, because otherwise anyone can fill the rpc queue and deny the service. |
I think it has been done in:
|
I'll fix them tomorrow. |
…into async-oracle
Fixed. It's because the script of native contract has been adjusted. See https://github.com/neo-project/neo/blob/8b1509f3a2fb7fa62a958a997fef18b7a30cfe1a/src/neo/SmartContract/Native/NativeContract.cs#L41-L49 |
Test passed with following scenarios:
@shargon @Tommo-L @erikzhang please help review the cases, in case I miss something. |
These cases are fine. Thanks. |
Conflicts |
Done. |
Let me do a smoke test. |
Assert.AreEqual(@"[""Acme Co""]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[0].Name"))); | ||
Assert.AreEqual("[50]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[0].Products[0].Price"))); | ||
Assert.AreEqual(@"[""Elbow Grease""]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[1].Products[0].Name"))); | ||
Assert.AreEqual(@"[{""Name"":""Elbow Grease"",""Price"":99.95}]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[1].Products[0]"))); |
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.
should add Filter(json,"") and Filter(json,null)
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.
I'll add it.
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.
neo-modules/src/OracleService/OracleService.cs
Lines 427 to 428 in 0acf93b
if (string.IsNullOrEmpty(filterArgs)) | |
return Utility.StrictUTF8.GetBytes(input); |
It returns the unmodified input.
Smoke test passed. |
Merge? |
* init * move * Clean code * Update src/Oracle/Oracle.cs * fix * Update src/Oracle/Oracle.cs * fix oracle * format * fix * optimize * optimize * format * fix * add CheckOracleAccount * fix * Update src/Oracle/Protocol/OracleHttpProtocol.cs * Update src/Oracle/Oracle.cs * fix * format * fix * Update Oracle.cs * fix timeout * fix timeout2 * optimze * format * Apply OracleHttpProtocol.cs * optimize * fix * remove * fix * optimize * Apply recommmendations * fix * add backupTx * sort public key * avoid two txs * send backup sign after timeout * exchange arguments of AddResponseTxSign * format * format * add cache * fix * optimize password * up error code * format * fix and add lock * fix * optimize * up oracle response code * use base64 * fix * remove useless library * fix * optimize * optimize * rename to OracleService * avoid duplicate request * Replace HashsetCache by ConcurrentDictionary * fix * fix * fix * clean code * rename Designate to Designation * Update src/Oracle/OracleService.cs Co-authored-by: Shargon <[email protected]> * fix * Update projects * Rename * optimize code * static AllowPrivateHost/Timeout * Update src/OracleService/Protocols/OracleHttpProtocol.cs Co-authored-by: Erik Zhang <[email protected]> * apply erik's suggestion * fix * fix * fix 2/2 * Update OracleService.cs * CI01118 * add Process * Optimize * Remove unused parameter * readonly * Use System.Threading.Timer * Rename * Update OracleService.cs * Update OracleService.cs * Rename * Add Settings.cs * Move IsInternal to Helper.cs * Update OracleService.cs * Remove Utility alias * Use a single HttpClient * Use HttpCompletionOption.ResponseContentRead * private class * Simplify OracleService.cs * Use Interlocked * fix * Using lock in OnTimer method * Replace lock by concurrentdictionary * Optimize * Simplify * async * Prevent reentry * Optimize * private * Prevent multiple starts * fix * fix * Optimize CheckOracleAccount * Fix OnStop * Reorder methods * Optimize CreateResponseTx * fix * Remove WithTimeout * Add check * add oracle ut * Delete Neo.Plugins.OracleService.Tests.csproj * Delete OracleServiceTest.cs * add try-catch when call Filter * fix and add UT * Remove empty line * Fix OnPersist * Optimize iteration * more optimize * fix ut * fix * Optimize * use random * Json un-indented * Replace nonce for deterministic value * Replace nonce * Add UT for filters Co-authored-by: Shargon <[email protected]> Co-authored-by: Owen Zhang <[email protected]> Co-authored-by: Erik Zhang <[email protected]>
No description provided.