-
Notifications
You must be signed in to change notification settings - Fork 686
BUG: not possible to delete or set storage on forked chain #436
Comments
I think this could be an unrelated bug in the eth_getStorageAt implementation: The SSTORE does a PUT on key The storage seems to be set correctly though, for example it can be retrieved later via |
It's also pretty obvious where this bug is: If you compare https://github.com/trufflesuite/ganache-core/blob/develop/lib/blockchain_double.js#L1103 and https://github.com/trufflesuite/ganache-core/blob/develop/lib/utils/forkedblockchain.js#L276 you can see the disparity. Opened a very small PR for this #438 |
I did test your suggested fix back here #652 (comment) is this merged fix something else I should try? |
I think this issue (which is unrelated to the other issue of not being able
to set storage to 0) should be fixed in develop by the merge of
#438
…On Mon 8. Jul 2019 at 15:20, Elena Dimitrova ***@***.***> wrote:
I did test your suggested fix back here trufflesuite/ganache#652
(comment)
<#652 (comment)>
is this merged fix something else I should try?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#436>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAXEY6LFD6IAQSTBMNVWCTP6M5KZANCNFSM4HY4YOXQ>
.
|
I tested the fix works as of EDIT: I tested #652 as well but that issue still persists. |
Closing as @elenadimitrova can confirm this issue has been fixed in the latest beta! Thanks @elenadimitrova! |
SSTORE
operations fail to have effect although transactions are reported successful. This is only present on a forked chain.Expected Behavior
SSTORE(X, Y)
should set storage slot X to value Y on a forked chain.Current Behavior
SSTORE(X, Y)
has no effect on storage, irrespective of whether this is setting a slot from zero to non-zero value, or the other way around. Found when testing a possibly related issue #653Steps to Reproduce (for bugs)
Use the following contract for testing
Start local ganache instance in debug mode
yarn run ganache-cli --debug
(will run on http://localhost:8545)Start the truffle console against the local development instance above
yarn run truffle console
In the console, create a new instance of
ContractEditing
viaconst contractEditing = await ContractEditing.new()
In the console, for the test contract instance, set storage
slot 1
tovalue 0x02
await contractEditing.setStorageSlot(1, "0x02")
Ensure the value is set
await web3.eth.getStorageAt(contractEditing.address, 1)
you should get back
0x0200000000000000000000000000000000000000000000000000000000000000
Now fork the above chain in a new instance running on a different port, e.g.
8900
yarn run ganache-cli --fork http://localhost:8545 --port 8900
Add truffle config for a new local network running on the above port
Start the truffle console against the forked development chain
yarn run truffle console --network testFork
Initialise the
ContractEditing
instance from the original dev chain (you'll need the address of the contract off development chain, e.g.0x4D6f43bbA56AE29BD5a69C0FE08f034Bb318BeaE
)const contractEditing = await ContractEditing.at("0x4D6f43bbA56AE29BD5a69C0FE08f034Bb318BeaE")
Ensure the storage slot is what we set it to in step 4 via rerunning
await web3.eth.getStorageAt(contractEditing.address, 1)
you should still get back
0x0200000000000000000000000000000000000000000000000000000000000000
Now try changing that storage slot in the forked chain
await contractEditing.setStorageSlot(1, "0x03")
Ensure the storage slot has changed:
await web3.eth.getStorageAt(contractEditing.address, 1)
you should get back the new value
0x03
but we still get back0x0200000000000000000000000000000000000000000000000000000000000000
You can try different combinations of the storage slot changes. I haven't been able to get anything to stick on the forked chain.
Context
This was found during testing of #652 which might be one of the symptoms of this issue.
The above tests also fail with the dirty hack proposed here #653 (comment)
Your Environment
Ganache CLI v6.4.3 (ganache-core: 2.5.5)
The text was updated successfully, but these errors were encountered: