Can't create Oracle
Closed this issue · 5 comments
I am referring to (1) https://github.com/gnosis/gnosis.js/ for the dev environment setup (ganache-cli and gnosis contract migration) and to (2)
https://gnosis.github.io/gnosis.js/tutorial-developer-guide.html for the JavaScript interaction part.
I can successfully compile and migrate the gnosis-contract in my local chain (see attached console std output), import the gnosis.js library in an HTML page. I then open that webpage in the browser and operate from the WebInspector console.
From the JS console, I can success
ganache-cli_output.txt
gnosis-contract-migrate-output.txt
fully call the Math methods and also create on ipFs the example event in the guide. When I try to create the centralizedOracle thought, I always get an exception:
const oracle = await gnosis.createCentralizedOracle(ipfsHash)
utils.js:287 Uncaught (in promise) TransactionError: CentralizedOracleFactory(0xcfeb..a601).createCentralizedOracle("Qme8yRqWZd5GhDcv2rs7ibvZGfF93ddXggBLVh6aggckjn")
failed with Error: VM Exception while processing transaction: revert Error: CentralizedOracleFactory(0xcfeb..a601).createCentralizedOracle("Qme8yRqWZd5GhDcv2rs7ibvZGfF93ddXggBLVh6aggckjn")
failed with Error: VM Exception while processing transaction: revert
at new TransactionError (file:///Users/marcoz/gnosis.js/dist/gnosis.js:8337:148)
at _callee3$ (file:///Users/marcoz/gnosis.js/dist/gnosis.js:7919:31)
at tryCatch (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21746:40)
at Generator.invoke [as _invoke] (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21980:22)
at Generator.prototype.(anonymous function) [as throw] (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21798:21)
at step (file:///Users/marcoz/gnosis.js/dist/gnosis.js:8524:30)
at file:///Users/marcoz/gnosis.js/dist/gnosis.js:8537:13
at <anonymous>
TransactionError @ utils.js:287
_callee3$ @ utils.js:328
tryCatch @ runtime.js:62
invoke @ runtime.js:296
prototype.(anonymous function) @ runtime.js:114
step @ asyncToGenerator.js:17
(anonymous) @ asyncToGenerator.js:30
Promise rejected (async)
(anonymous) @ VM138:1
async function (async)
(anonymous) @ VM138:1
(anonymous) @ VM138:1
utils.js:287 Uncaught (in promise) Error: CentralizedOracleFactory(0xcfeb..a601).createCentralizedOracle("Qme8yRqWZd5GhDcv2rs7ibvZGfF93ddXggBLVh6aggckjn")
failed with Error: VM Exception while processing transaction: revert
at new TransactionError (file:///Users/marcoz/gnosis.js/dist/gnosis.js:8337:148)
at _callee3$ (file:///Users/marcoz/gnosis.js/dist/gnosis.js:7919:31)
at tryCatch (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21746:40)
at Generator.invoke [as _invoke] (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21980:22)
at Generator.prototype.(anonymous function) [as throw] (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21798:21)
at step (file:///Users/marcoz/gnosis.js/dist/gnosis.js:8524:30)
at file:///Users/marcoz/gnosis.js/dist/gnosis.js:8537:13
at <anonymous>
And from the ganache-cli console, I see the corresponding chain error:
net_version
eth_sendTransaction
Transaction: 0x1b96f3428c65b47d581ac643af8af60c1c8122fd19df131b3ef46ba7032502d6
Gas usage: 89527
Block Number: 14
Block Time: Sun Feb 11 2018 11:37:22 GMT+0100 (CET)
Runtime Error: revert
Ah, I was able to reproduce the error with this... hmm...
Yes, so for some reason, the gas limits that should have been set have not been set, causing the transaction to use up the default 90k transaction gas limit, then failing. Specifying the gas amount to 400k would fix this, but the odd thing is the transpiled bundled version doesn't do that while the transpiled version running off of Node.js does. Also, the gas stats which would normally set those limits are available to the contracts and can be reached from the main gnosis
instance. Furthermore, we've already used gnosis.js extensively in an actual front-end interface, and this issue has not come up... this is very mysterious basically, and I don't have an immediate answer as to why it wouldn't work in the tutorial, but I am looking into it.
Okay, I found the issue, and it will be resolved soon. Basically, there is a lodash-webpack-plugin
which is used to reduce the size of the final build, but its default behavior is to remove feature sets and replace them with noops such as the collections
feature, which is to
Support objects in “Collection” methods.
This caused a _.forIn
call which sets default gas limits in the attached contract abstraction instances to be turned into a noop in the webpacked bundles gnosis.js
and gnosis.min.js
. As a result, many calls, such as the call for creating centralized oracles, will execute with not enough gas by default when using the bundled javascript files.
Since the frontend we are developing uses a setup with does not use the lodash-webpack-plugin
, it doesn't face the same issue. Therefore, this fully explains the symptoms I've observed in the previous comment.
In the future, regressions for this issue could be mitigated by running the test suite against the webpacked versions of the code as well. I'll have to look into doing so at some point.
Got the following report about this issue:
I tried to verify your fix but I get the same error
here what I did:
git fetch
git checkout tag/v1.1.3
npm install
to re generate the js files- open my index.html in the browser, with the code to import the Gnosis library (I checked that the page refers to the dist/gnosis.js file just created)
- from the browser js console I run again the tutorial steps as before, and I see the same error
all this running again a local chain created freshly with ganache-cli, and after migrating again the gnosis-contracts
Could not repro, and reporter resolved this by refreshing their cache.