Commit 43ab823d authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: PR review comments

parent 9edfdd58
...@@ -113,7 +113,7 @@ const replaceImmutables = async ( ...@@ -113,7 +113,7 @@ const replaceImmutables = async (
outputContract.evm.deployedBytecode.immutableReferences outputContract.evm.deployedBytecode.immutableReferences
const names = {} const names = {}
// Recursively fine all of the immutables by traversing the solc output ast // Recursively find all of the immutables by traversing the solc output ast
const findNames = (ast: any) => { const findNames = (ast: any) => {
// Add the name of the variable if it is an immutable // Add the name of the variable if it is an immutable
const isImmutable = ast.mutability === 'immutable' const isImmutable = ast.mutability === 'immutable'
...@@ -159,6 +159,12 @@ const replaceImmutables = async ( ...@@ -159,6 +159,12 @@ const replaceImmutables = async (
// Insert the value at each one // Insert the value at each one
for (const offset of offsets) { for (const offset of offsets) {
if (offset.length !== 32) {
throw new Error(
`Immutable slicing must be updated to handle arbitrary size immutables`
)
}
deployedBytecode = ethers.utils.hexConcat([ deployedBytecode = ethers.utils.hexConcat([
hexDataSlice(deployedBytecode, 0, offset.start), hexDataSlice(deployedBytecode, 0, offset.start),
hexZeroPad(value, 32), hexZeroPad(value, 32),
...@@ -434,6 +440,10 @@ task('genesis-l2', 'create a genesis config') ...@@ -434,6 +440,10 @@ task('genesis-l2', 'create a genesis config')
? await replaceImmutables(hre, name, immutableConfig) ? await replaceImmutables(hre, name, immutableConfig)
: artifact.deployedBytecode : artifact.deployedBytecode
assertEvenLength(deployedBytecode)
// TODO(tynes): initialize contracts that should be initialized
// in the implementations here
alloc[allocAddr] = { alloc[allocAddr] = {
nonce: '0x00', nonce: '0x00',
balance: '0x00', balance: '0x00',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment