Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Apr 18, 2024
1 parent edfaa44 commit c7102bf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
11 changes: 10 additions & 1 deletion yarn-project/circuits.js/src/contract/contract_class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type ContractArtifact, type FunctionArtifact, FunctionSelector, FunctionType } from '@aztec/foundation/abi';
import { Fr } from '@aztec/foundation/fields';
import { createDebugLogger } from '@aztec/foundation/log';
import { type ContractClass, type ContractClassWithId } from '@aztec/types/contracts';

import { computeArtifactHash } from './artifact_hash.js';
Expand Down Expand Up @@ -39,7 +40,11 @@ export function getContractClassFromArtifact(
packedBytecode,
privateFunctions,
};
return { ...contractClass, ...computeContractClassIdWithPreimage(contractClass) };

const classIdWithPreimage = computeContractClassIdWithPreimage(contractClass);

getLogger().debug('Computed contract class', classIdWithPreimage);
return { ...contractClass, ...classIdWithPreimage };
}

export function getContractClassPrivateFunctionFromArtifact(
Expand All @@ -59,3 +64,7 @@ export function computeVerificationKeyHash(_verificationKeyInBase64: string) {
// return Fr.fromBuffer(hashVK(Buffer.from(verificationKeyInBase64, 'hex')));
return Fr.ZERO;
}

function getLogger() {
return createDebugLogger('aztec:circuits:contract_class');
}
10 changes: 9 additions & 1 deletion yarn-project/circuits.js/src/contract/contract_instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { type ContractArtifact, type FunctionArtifact, getDefaultInitializer } f
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr, Point } from '@aztec/foundation/fields';
import { createDebugLogger } from '@aztec/foundation/log';
import { type ContractInstance, type ContractInstanceWithAddress } from '@aztec/types/contracts';

import { getContractClassFromArtifact } from '../contract/contract_class.js';
Expand Down Expand Up @@ -52,7 +53,10 @@ export function getContractInstanceFromDeployParams(
version: 1,
};

return { ...instance, address: computeContractAddressFromInstance(instance) };
const address = computeContractAddressFromInstance(instance);

getLogger().debug('Computed contract instance', { address, ...instance });
return { ...instance, address };
}

function getConstructorArtifact(
Expand All @@ -68,3 +72,7 @@ function getConstructorArtifact(
}
return requestedConstructorArtifact ?? getDefaultInitializer(artifact);
}

function getLogger() {
return createDebugLogger('aztec:circuits:contract_instance');
}
2 changes: 1 addition & 1 deletion yarn-project/protocol-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"clean": "rm -rf ./dest .tsbuildinfo ./src/artifacts",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests"
"test": "NODE_NO_WARNINGS=1 DEBUG=${DEBUG:-'aztec:*'} node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests"
},
"inherits": [
"../package.common.json",
Expand Down
5 changes: 3 additions & 2 deletions yarn-project/protocol-contracts/package.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"generate:noir-contracts": "./scripts/copy-contracts.sh",
"build:dev": "tsc -b --watch",
"build:ts": "tsc -b",
"clean": "rm -rf ./dest .tsbuildinfo ./src/artifacts"
"clean": "rm -rf ./dest .tsbuildinfo ./src/artifacts",
"test": "NODE_NO_WARNINGS=1 DEBUG=${DEBUG:-'aztec:*'} node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests"
}
}
}

0 comments on commit c7102bf

Please sign in to comment.