-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Transpiling Hardcoded Constructor Values #169
Conversation
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!
buildJSON: any, | ||
isDeployedBytecode: boolean | ||
): Buffer => { | ||
const auxDataObject = buildJSON.evm.legacyAssembly['.data'] |
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.
just double checking that this should be ['.data']
and not .data
or ['data']
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.
Yep! Weird I know.
bytecodeWithoutAuxdata.fill( | ||
0, | ||
auxDataPosition, | ||
auxDataPosition + auxDataBuf.byteLength | ||
) |
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.
👍👍👍
packages/rollup-dev-tools/test/transpiler/abi-encoded-constants-transpilation.spec.ts
Outdated
Show resolved
Hide resolved
packages/rollup-dev-tools/test/transpiler/abi-encoded-constants-transpilation.spec.ts
Outdated
Show resolved
Hide resolved
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}`) |
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.
might be cleaner to just do this all in one go and not log the intermediate values (e.g. https://github.com/ethereum-optimism/uniswap-v2-core/blob/706c0ef8749511d9c36a05e459a2ace9099c85ce/test/UniswapV2ERC20.spec.ts#L37-L52)
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.
Ah yeah, this was set up for debugging to figure out which stage it was failing at. Removing
…s-transpilation.spec.ts Co-authored-by: Kevin Ho <[email protected]>
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
Description
It turned out that if a constructor looks something like
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
00
s.Questions
N/A
Metadata
Fixes
Contributing Agreement