Currently, @shargon has submitted a implementation of built-in Oracle.The content is basically consistent with our discussion at the time, and of course, appropriate adjustments have been made.But we also found some problems in the review process.As @erikzhang said,"Maybe we should rethink each aspect of the two solutions and find out which suits us best."
Flow Chart

Process:
Advantage
Disadvantages
Flow Chart


Process:
Advantage
Disadvantages
Mechanism| Synchronization| ASynchronization
-- | -- | --
Block state association | Strong | Weak
Total execution time | Strong limit | Weak limit
Permission | No additional mechanism | Additional mechanism
Charging | No additional mechanism | Additional mechanism
Originality | High | Low
Both solutions only solve the problem of data handling, but there is not much thinking about trusted data sources.We recommend introducing the concept of a trusted data source DataProvider.
DataProvider
Trusted data provider. The data source can be registered as a DataProvider in the contract, and also provide a method of data audit. Anyone can audit the data of the data source that has been chained according to the corresponding data audit method.

Why do we need an Oracle like this?
Because of this, we consider introducing the DataProvider in the Oracle solution, which is mainly responsible for:
At this time, any node can become an Oracle miner, only responsible for transfering data on the chain.
For non-verifiable data, oracle miner will also transfer it, but Oracle does not provide data verification, the developer should bear the responsibility. We advocate and encourage to transfer verifiable data.
In this way, whether synchronous or asynchronous, I think the biggest difference between us and traditional Oracle is that we have built-in verifiable Oracle.
Disadvantages
- Memory pool spam attack.
- Highly related to the state of the block, it must be executed within a block.
I think that the sync oracle doesn't include a mempool attack, it can have the same checks than the currently memory pool, so there are no difference.
According to the state of block, my opinion: if your request use any block data, you can be lucky and receive the right response, or a FAULT, there are no problem with this for me, users should not use this data for compose the url, but if they did it, oracle nodes will deals with it, usually with a FAULT.
For me we don't need to do an extra work for oracle nodes in each block, otherwise you can have a spam attack, with sync or async version. Oracles should do his work, download the data, the rest of the work should be made by mempool when the receive the response or the request TX.
According to the state of block, my opinion: if your request use any block data, you can be lucky and receive the right response, or a FAULT, there are no problem with this for me, users should not use this data for compose the url, but if they did it, oracle nodes will deals with it, usually with a FAULT.
I agree. I think this is not a oracle problem, it's the blockchain problem. For a contract, which use block height for switch, also face the problem. The tx may be valid and execute successful before packaged, but after that it may fail.
if(height == xxx)
...
else if (height == yyy)
...
else
...
Synchronization
DisadvantagesMemory pool spam attack.
I thought this one had already been discussed in #1527, but I can reiterate the main point here --- having the same level of fee payment guarantees as for regular transactions (and we do have it) should be enough for Oracle transactions.
Highly related to the state of the block, it must be executed within a block.
And that one actually looks more like a feature to me, because long unpredictable delays between different requests and especially between initial blockchain state and blockchain state when the transaction will finally be executed will easily lead to distorted reality seen by the contract. It's almost like a rolling shutter effect, not something I'd like to see when executing a contract, especially if it somehow relates to any kind of asset.
DataProvider
The data source can be registered as a DataProvider in the contract, and also provide a method of data audit
I would probably not mix this (trust) issue in here, verifiable data is good, but it only works if your data provider signs it and you have some way to verify it on-chain (basically, there is a corresponding contract that knows the appropriate keys) and even then this data needs to be brought into the chain by Oracles and we're better concentrate on the way they gonna do that here.
+1 - yes, this is akin to a feature from my perspective as well. Agree with Roman's comments wrt stale reference data.
Got it
Any conclusion?
I already have a perfect asynchronous solution.
Asynchronous solution it's something that any dapps can make, in any time, and probably better than us because they will be focused in that. What it's the sense of offer a core solution that can be improved in any time by third parties? There are no syncronous solutions in other blockchains only for one reason, they can't do that althought they want to, it's required to be integrated in the core of the blockchain, so... we only the chance now, with neo3. We can be unique.
The synchronization solution requires special ordering or delay of transactions. This process requires the participation of consensus nodes, which seems a bit weird.
The synchronization solution cannot access the URLs related to the current time, and this may be a very common scenario.
The asynchronous solution needs to solve the problem of fees and witnesses. These problems can only be solved by the core, not by the contract.
The synchronization solution requires special ordering or delay of transactions. This process requires the participation of consensus nodes, which seems a bit weird.
Agree, it's weird, but it only affect to the sort of the mempool. Both solutions will have weird things like onPostPersit xD
The synchronization solution cannot access the URLs related to the current time, and this may be a very common scenario.
You will have the same problem in async version, you will need to invalidate the original request if the time changed. Because if OracleCN sign the transaction at block 1, and now it's block 2, it doesn't care if it's async or sync, it will require to be invalidated, if you want to be able to that, I think that it's not required.
The asynchronous solution needs to solve the problem of fees and witnesses. These problems can only be solved by the core, not by the contract.
This can be done by a smart contract. We have dapps in ethereum that currently are working without this issue, you need to deposit your token, and the bridge will take the reward. (https://witnet.io/about#bridges)
We already have CreateCallback syscalls, can we add CreateTask syscall? This can be applied in oracle, like the following:
js
var trigger = oracle contract
var contract = request contract
var extraData = oracleResponseFee
CreateTask(trigger, contract, method, params, extraData)
CreateTask syscall will call the RegisterTask(contract, method, params, extraData) method of OracleContract, which will save the task(=contract.method(params)) and call AddGas(oracleResponseFee).request at last.And the CreateTask can also be used to collect signatures onchain, to solve this problem https://github.com/neo-project/neo/issues/1573
What's the difference between it and the asynchronous oracle?
No big difference, it's just pseudo-synchronization, and user does not need to set responseFee. The only concern is that our previous propaganda is the synchronization scheme.
I don't think it is a good idea to create a new SYSCALL for just pseudo synchronization. And it is the same as calling the RegisterTask method of the oracle contract directly. The only difference now is that the name of this method is called Request.
The only difference now is that the name of this method is called Request.
If so, why not we use the pseudo synchronization, very little code needs to be changed, and it can also be different from traditional asynchronous oracle.
Most helpful comment
I thought this one had already been discussed in #1527, but I can reiterate the main point here --- having the same level of fee payment guarantees as for regular transactions (and we do have it) should be enough for Oracle transactions.
And that one actually looks more like a feature to me, because long unpredictable delays between different requests and especially between initial blockchain state and blockchain state when the transaction will finally be executed will easily lead to distorted reality seen by the contract. It's almost like a rolling shutter effect, not something I'd like to see when executing a contract, especially if it somehow relates to any kind of asset.
I would probably not mix this (trust) issue in here, verifiable data is good, but it only works if your data provider signs it and you have some way to verify it on-chain (basically, there is a corresponding contract that knows the appropriate keys) and even then this data needs to be brought into the chain by Oracles and we're better concentrate on the way they gonna do that here.