-
Notifications
You must be signed in to change notification settings - Fork 51
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
Allow reading deployedBytecode.object code object from JSON file #659
Conversation
Can you write down, or reference, what is the structure of the JSON file? |
Yes, good point. So I actually can't really find any reference for this -- it seems to be by forge, for forge. It has actually broken our build before, because we use the JSON to read out e.g. the AST. And I can't seem to find a good description of this JSON format on forge's website. However, the most important two parts of it for us are:
Where the So I decided to take the -- | Reads a foundry json output
readFoundryJSON :: Text -> Text -> Err (Contracts, Asts, Sources)
readFoundryJSON contractName json = do
runtime <- maybeToEither "missing 'deployedBytecode' field" $ json ^? key "deployedBytecode"
runtimeCode <- maybeToEither "missing 'deployedBytecode.object' field" $
(toCode contractName) . strip0x'' <$> runtime ^? key "object" % _String
runtimeSrcMap <- case runtime ^? key "sourceMap" % _String of
Nothing -> Right $ force "Source map creation error" $ makeSrcMaps "" -- sourceMap is optional
Just smap -> maybeToEither "invalid sourceMap format" $ makeSrcMaps smap |
Damn. Actually, we could reuse that function, |
OK, I'll rewrite this and ping you when I'm done. I'm sorry for this mess. |
readFoundryJSON
)
OK, I had a look -- the alternative way of doing this, via What do you think would be needed for this PR to be acceptable? Maybe some more documentation? Or better command line description? I see your point, but I am not sure what would be the best way to address it. |
readFoundryJSON
)Co-authored-by: Martin Blicha <[email protected]>
Co-authored-by: Martin Blicha <[email protected]>
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.
LGTM!
Description
Sometimes, as reported by users, the command line limit of 8k characters is too few for a contract. In these cases, it's actually impossible to run
--symbolic
of--equivalance
. So for these cases, I created--code-file
and--code-a-file
and--code-b-file
which can be given as an alternative. Then the.deployedBytecode.object
object is read from the provided Forge JSON file.Unfortunately, Forge JSON is not currently documented, and my understanding is that it's not documented because they want to be able to change it to meet their requirements. However, it's kind of a semi-default for many systems (e.g. also Halmos) to read Forge JSON files. I will open an issue at Forge to ask them about this JSON file's format.
Checklist