Skip to content
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

Transpiling Hardcoded Constructor Values #169

Merged
merged 5 commits into from
Jun 30, 2020

Conversation

ben-chain
Copy link
Collaborator

@ben-chain ben-chain commented Jun 30, 2020

Description

It turned out that if a constructor looks something like

constructor() {
   storeVal(abi.encode('I am a hardcoded solidity value'));
}

Then the hardcoded val is handled a little differently than constants--it's put after the auxdata in the initcode. This introduced a bug where we accidentally purged that hardcoded value with stripAuxData().

This PR fixes by removing auxdata only if there's no additional data proceeding it. If there is, then it instead fills the auxdata with 00s.

Questions

N/A

Metadata

Fixes

  • Fixes YAS 446

Contributing Agreement

Copy link
Contributor

@K-Ho K-Ho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

buildJSON: any,
isDeployedBytecode: boolean
): Buffer => {
const auxDataObject = buildJSON.evm.legacyAssembly['.data']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just double checking that this should be ['.data'] and not .data or ['data']

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Weird I know.

Comment on lines +59 to +63
bytecodeWithoutAuxdata.fill(
0,
auxDataPosition,
auxDataPosition + auxDataBuf.byteLength
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍👍

Comment on lines 99 to 123
const expectedInnerBytesBeingHashed = Buffer.from(
ethers.utils.toUtf8Bytes(
'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'
)
)
log.debug(
`expectedInnerBytesBeingHashed: ${bufToHexString(
expectedInnerBytesBeingHashed
)}`
)
const expectedInnerHashRaw = ethers.utils.keccak256(
expectedInnerBytesBeingHashed
)
log.debug(`expectedInnerHashRaw: ${expectedInnerHashRaw}`)
const expectedInnerHashAndValEncoded = ethers.utils.defaultAbiCoder.encode(
['bytes32', 'uint256'],
[expectedInnerHashRaw, 1]
)
log.debug(
`expectedInnerHashAndValEncoded: ${expectedInnerHashAndValEncoded}`
)
const expectedOuterHash = ethers.utils.keccak256(
expectedInnerHashAndValEncoded
)
log.debug(`expected final outer hash: ${expectedOuterHash}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, this was set up for debugging to figure out which stage it was failing at. Removing

@ben-chain ben-chain merged commit 7c08e11 into master Jun 30, 2020
@gakonst gakonst deleted the feat/YAS446/hardcoded-constructor-abi-encode branch March 18, 2021 15:09
bnoieh pushed a commit to bnoieh/optimism that referenced this pull request Apr 3, 2024
ClaytonNorthey92 added a commit to hemilabs/optimism that referenced this pull request Dec 9, 2024
c9dbc5f58 Test fix & fmt
fcf735497 ExternalHeaderMode rebase
f09d4e5ff Add for wind/unwind support to tbc (ethereum-optimism#159)
5c764a0cd popm: exclude tx outputs that would be dust (ethereum-optimism#186)
1f168f225 popm/wasm: fix dispatch params for {add,remove}EventListener (ethereum-optimism#181)
383611feb popm/wasm: add 'minerStatus' method (ethereum-optimism#178)
6a94b4c0b popm/wasm: rename KeyResult fields and add bitcoinScriptHash (ethereum-optimism#177)
9c4cea583 popm/wasm: add events and clean up globals (ethereum-optimism#175)
a2372394d popm: improve UTXO selection when creating Bitcoin transaction (ethereum-optimism#173)
939813cac popm/wasm: fix ethereum address when generating and parsing keys (ethereum-optimism#174)
9245995ef Updated localnet to use more recent commits of optimism and op-geth (ethereum-optimism#139)
159fbc5f5 ci: improve runtime of high usage CI workflows (ethereum-optimism#163)
60a3489db popm/wasm: add 'bitcoinAddressToScriptHash' method (ethereum-optimism#169)
fe9752a5a popm/wasm: add 'parseKey' method (ethereum-optimism#168)
65aa0caef ci: add registry-url to setup-node in release (ethereum-optimism#167)
8922ce805 popm/wasm: add new @hemilabs/pop-miner NPM package (ethereum-optimism#162)
67166046b scripts: add release script (ethereum-optimism#164)
eea96059b ci: add labeler action (ethereum-optimism#165)

git-subtree-dir: heminetwork
git-subtree-split: c9dbc5f58a7f997fa4b3af0d765a2967ed3462d1
blockchaindevsh added a commit to blockchaindevsh/optimism that referenced this pull request Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants