Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Nov 6, 2024
1 parent eb6053f commit 970caba
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
11 changes: 11 additions & 0 deletions noir-projects/noir-contracts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ echo "Compiling contracts..."
NARGO=${NARGO:-../../noir/noir-repo/target/release/nargo}
$NARGO compile --silence-warnings --inliner-aggressiveness 0

protocol_contracts=$(jq -r '.[]' "./protocol_contracts.json")
for contract in $protocol_contracts; do
artifactPath="./target/$contract.json"
readarray -t fnNames < <(jq -r '.functions[] | select(.custom_attributes | index("private")) | .name' "$artifactPath")
readarray -t fnBytecodes < <(jq -r '.functions[] | select(.custom_attributes | index("private")) | .bytecode' "$artifactPath")

for i in "${!fnBytecodes[@]}"; do
echo "${fnNames[$i]}, $(echo -n "${fnBytecodes[$i]}" | sha256sum | awk '{print $1}')"
done
done

echo "Generating protocol contract vks..."
BB_HASH=${BB_HASH:-$(cd ../../ && git ls-tree -r HEAD | grep 'barretenberg/cpp' | awk '{print $3}' | git hash-object --stdin)}
echo Using BB hash $BB_HASH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ contract ContractInstanceDeployer {
}
}

#[private]
fn foo_bar(a: Field) -> Field {
a + 1
}

#[private]
fn deploy(
salt: Field,
Expand Down
11 changes: 5 additions & 6 deletions yarn-project/circuits.js/src/contract/artifact_hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,14 @@ export function computeFunctionArtifactHash(
| (Pick<FunctionArtifact, 'bytecode'> & { functionMetadataHash: Fr; selector: FunctionSelector }),
) {
const selector = 'selector' in fn ? fn.selector : FunctionSelector.fromNameAndParameters(fn);
// TODO(#5860): make bytecode part of artifact hash preimage again
// const bytecodeHash = sha256Fr(fn.bytecode).toBuffer();
// const metadataHash = 'functionMetadataHash' in fn ? fn.functionMetadataHash : computeFunctionMetadataHash(fn);
// return sha256Fr(Buffer.concat([numToUInt8(VERSION), selector.toBuffer(), metadataHash.toBuffer(), bytecodeHash]));
return sha256Fr(Buffer.concat([numToUInt8(VERSION), selector.toBuffer()]));

const bytecodeHash = sha256Fr(fn.bytecode).toBuffer();
const metadataHash = 'functionMetadataHash' in fn ? fn.functionMetadataHash : computeFunctionMetadataHash(fn);
return sha256Fr(Buffer.concat([numToUInt8(VERSION), selector.toBuffer(), metadataHash.toBuffer(), bytecodeHash]));
}

export function computeFunctionMetadataHash(fn: FunctionArtifact) {
return sha256Fr(Buffer.from(JSON.stringify(fn.returnTypes), 'utf8'));
return sortAndHashArtifactMetadata(fn.returnTypes);
}

function getLogger() {
Expand Down
14 changes: 7 additions & 7 deletions yarn-project/protocol-contracts/src/protocol_contract_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ export const ProtocolContractAddress: Record<ProtocolContractName, AztecAddress>
};

export const ProtocolContractLeaf = {
AuthRegistry: Fr.fromString('0x1f8bfccaf4965336c66ffb52c7b39b9637105f019ac5f4d795e7ba3b3398a34a'),
ContractInstanceDeployer: Fr.fromString('0x08b46b68aea276ffcf07c6b46d9bf4397d51a589a63b8b25f364fea25e2071e9'),
ContractClassRegisterer: Fr.fromString('0x18a38fb40d939fa5e6d452918f6c3955a3bda92088579634fb4d36392048516f'),
MultiCallEntrypoint: Fr.fromString('0x1bace4b543ec90410c8427b13c9d6609f649ab878c9d50c615ec821c77571e3e'),
FeeJuice: Fr.fromString('0x1de6b0dace07dabe41559101f328fe3ab628b67439fccf8d3921199de6da0c50'),
Router: Fr.fromString('0x1bfe36b062c01de3567f477c9ee7d9e1306edfe3296123906506b8d7ab7cd9d9'),
AuthRegistry: Fr.fromString('0x269750e02628ed85ee8adb2200869bd263fb57895822ec6249671e7dbd4ffeff'),
ContractInstanceDeployer: Fr.fromString('0x03d3336cdfa768b7db364933bc1c444a5bb85b687f3308ff18c915053a617d03'),
ContractClassRegisterer: Fr.fromString('0x16a4d230f65a8216df007da8de38dac810bac799df0d6644ff01c23ee9781c47'),
MultiCallEntrypoint: Fr.fromString('0x08d96cd26b1e2a47d49325b713100cb2a351cb022e611e36b54bfffabdf8c128'),
FeeJuice: Fr.fromString('0x1b5e3235fe96b9828c8198262104ab50d47e5e711db48c5bcdceb13b1a73a61a'),
Router: Fr.fromString('0x0b2b671b52e3ecff727a1bbfb95e413446f8feb06886e17c364db5589dea8846'),
};

export const protocolContractTreeRoot = Fr.fromString(
'0x2cb2aa3df6e2339c2ad3c20a8279e24eaf1bbb3e341c1af6296ea587c248ce72',
'0x0136c620967994b0a02b4cd3a0dd288925d413c45f8ae65fd291ec2d192ab25f',
);

0 comments on commit 970caba

Please sign in to comment.