-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Inject bytecode for a contract/ how to debug when only have interface for already deployed contracts #3301
Comments
Thanks for opening this! For the stacktrace problem, I'm not sure there's a fix right now, but sounds like something @haltman-at will want to know about! For
(or This will tell Truffle to download verified contracts from Etherscan and allow you to debug them. Note that your forked network's network ID must match the network ID for the network you're forking from (This is default behavior with ganache-cli, but wanted to warn you in case you're overriding the network ID yourself!) For more info, see our recent blog post about (If you try this, please let us know if you get it working or not!) |
Cool - thank you for the quick reply - my attempt:
so I tried it against a forked ganache and it errored out with
which might or not be related to how i set up my config, based off how sol-trace had in their exmaple truffle repo const ProviderEngine = require('web3-provider-engine');
const WebsocketSubprovider = require('web3-provider-engine/subproviders/websocket.js');
const {
TruffleArtifactAdapter,
RevertTraceSubprovider,
} = require('@0x/sol-trace');
const projectRoot = '.';
const solcVersion = '0.6.5+commit.f956cc89';
const defaultFromAddress = '0xe8B479...0';
const isVerbose = true;
const artifactAdapter = new TruffleArtifactAdapter(projectRoot, solcVersion);
const revertTraceSubprovider = new RevertTraceSubprovider(
artifactAdapter,
defaultFromAddress,
isVerbose
);
const provider = new ProviderEngine();
provider.addProvider(revertTraceSubprovider);
provider.addProvider(
new WebsocketSubprovider({rpcUrl: 'http://localhost:8545'})
);
provider.start((err) => {
if (err !== undefined) {
console.log(err);
process.exit(1);
}
});
provider.send = provider.sendAsync.bind(provider);
module.exports = {
networks: {
forked: {
provider,
network_id: '1',
skipDryRun: true,
},
}, |
So taking a look at this -- it looks like a lot of the issue is with this external tool, the 0x tracer? I don't think we can help you with that. However, it seems you're also reporting a crash in the Truffle debugger? That I should be able to do something about if I can reproduce it. Do you have reproduction steps for that, or perhaps a reproduction project I could take a look at? Thank you! |
ya - apologies - so I removed the sol-trace stuff and the debugger did give awesome stack trace! I'll also mention that since posting issue - I switched to ganache built off beta branch , which works better than current release
the line numbers don't match up with original source but that's totally fine - the temp files are correct wrt content of source. AMAZING JOB FOLKS!! I love this feature. I will close because now there is a different issue - the real revert reason is
in UniswapV2Pair.sol:182, but after reverting the txn, ganache keeps the lock value - so the debug is going to the wrong place, reported many times in uniswap discord chat & after a failed swap iteration, I restart ganache so the locked value is fresh again. Thank you so much team - this is an amazing project - amazing tools |
Somewhat related to this other recently opened issue
0xProject/0x-monorepo#2679
I have interfaces that I'm using in my contract which I deployed against my forked ganache node - and interacting with the deployed contract via
truffle console --network forked
the contract has a method call that is exploding and via the 0x stack tracer , I get the line that is exploding, but no deeper insight into the stack because i don't have the bytecode of the external libraries, just their interfaces.
in principle, the chain does have the bytecode, and I tried adding the byte code into the build aritifacts by hand for the bytecode key value but this is hacky and it didn't produce any good results either.
I also tried
truffle debug
but truffle debug itself broke onso its not clear to me, what is the right flow to debug when you use external, already deployed contracts
I suppose I can build all my dependencies as well - but I am not sure how to do that either because curve.fi uses vyber and contracts expects everything to be just
.sol
thank you
The text was updated successfully, but these errors were encountered: