diff --git a/yarn-project/accounts/src/defaults/account_contract.ts b/yarn-project/accounts/src/defaults/account_contract.ts index f2842c9ac0f..6854af1a10b 100644 --- a/yarn-project/accounts/src/defaults/account_contract.ts +++ b/yarn-project/accounts/src/defaults/account_contract.ts @@ -1,7 +1,7 @@ import { type AccountContract, type AccountInterface, type AuthWitnessProvider } from '@aztec/aztec.js/account'; import { type CompleteAddress } from '@aztec/circuit-types'; +import { type NodeInfo } from '@aztec/circuits.js'; import { type ContractArtifact } from '@aztec/foundation/abi'; -import { type NodeInfo } from '@aztec/types/interfaces'; import { DefaultAccountInterface } from '../defaults/account_interface.js'; diff --git a/yarn-project/accounts/src/defaults/account_interface.ts b/yarn-project/accounts/src/defaults/account_interface.ts index db4c57dc669..586f790f5af 100644 --- a/yarn-project/accounts/src/defaults/account_interface.ts +++ b/yarn-project/accounts/src/defaults/account_interface.ts @@ -1,9 +1,8 @@ import { type AccountInterface, type AuthWitnessProvider } from '@aztec/aztec.js/account'; import { type EntrypointInterface, type ExecutionRequestInit } from '@aztec/aztec.js/entrypoint'; import { type AuthWitness, type TxExecutionRequest } from '@aztec/circuit-types'; -import { type AztecAddress, type CompleteAddress, Fr } from '@aztec/circuits.js'; +import { type AztecAddress, type CompleteAddress, Fr, type NodeInfo } from '@aztec/circuits.js'; import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account'; -import { type NodeInfo } from '@aztec/types/interfaces'; /** * Default implementation for an account interface. Requires that the account uses the default diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index f1b9de2b278..2e7163b3cee 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -17,12 +17,18 @@ import { type UnencryptedL2Log, } from '@aztec/circuit-types'; import { + type ContractClassPublic, ContractClassRegisteredEvent, + type ContractDataSource, ContractInstanceDeployedEvent, + type ContractInstanceWithAddress, + type ExecutablePrivateFunctionWithMembershipProof, type FunctionSelector, type Header, PrivateFunctionBroadcastedEvent, + type PublicFunction, UnconstrainedFunctionBroadcastedEvent, + type UnconstrainedFunctionWithMembershipProof, isValidPrivateFunctionMembershipProof, isValidUnconstrainedFunctionMembershipProof, } from '@aztec/circuits.js'; @@ -37,14 +43,6 @@ import { Timer } from '@aztec/foundation/timer'; import { InboxAbi, RollupAbi } from '@aztec/l1-artifacts'; import { ProtocolContractAddress } from '@aztec/protocol-contracts'; import { type TelemetryClient } from '@aztec/telemetry-client'; -import { - type ContractClassPublic, - type ContractDataSource, - type ContractInstanceWithAddress, - type ExecutablePrivateFunctionWithMembershipProof, - type PublicFunction, - type UnconstrainedFunctionWithMembershipProof, -} from '@aztec/types/contracts'; import groupBy from 'lodash.groupby'; import { diff --git a/yarn-project/archiver/src/archiver/archiver_store.ts b/yarn-project/archiver/src/archiver/archiver_store.ts index af04befb3cc..d2353d93fa4 100644 --- a/yarn-project/archiver/src/archiver/archiver_store.ts +++ b/yarn-project/archiver/src/archiver/archiver_store.ts @@ -10,15 +10,16 @@ import { type TxHash, type TxReceipt, } from '@aztec/circuit-types'; -import { type Fr, type Header } from '@aztec/circuits.js'; -import { type ContractArtifact } from '@aztec/foundation/abi'; -import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { type ContractClassPublic, type ContractInstanceWithAddress, type ExecutablePrivateFunctionWithMembershipProof, + type Fr, + type Header, type UnconstrainedFunctionWithMembershipProof, -} from '@aztec/types/contracts'; +} from '@aztec/circuits.js'; +import { type ContractArtifact } from '@aztec/foundation/abi'; +import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { type DataRetrieval } from './structs/data_retrieval.js'; import { type L1Published } from './structs/published.js'; diff --git a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts index cb0095157ab..34443ee0cec 100644 --- a/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts +++ b/yarn-project/archiver/src/archiver/archiver_store_test_suite.ts @@ -1,6 +1,14 @@ import { InboxLeaf, L2Block, LogId, LogType, TxHash } from '@aztec/circuit-types'; import '@aztec/circuit-types/jest'; -import { AztecAddress, Fr, INITIAL_L2_BLOCK_NUM, L1_TO_L2_MSG_SUBTREE_HEIGHT } from '@aztec/circuits.js'; +import { + AztecAddress, + type ContractClassPublic, + type ContractInstanceWithAddress, + Fr, + INITIAL_L2_BLOCK_NUM, + L1_TO_L2_MSG_SUBTREE_HEIGHT, + SerializableContractInstance, +} from '@aztec/circuits.js'; import { makeContractClassPublic, makeExecutablePrivateFunctionWithMembershipProof, @@ -8,11 +16,6 @@ import { } from '@aztec/circuits.js/testing'; import { times } from '@aztec/foundation/collection'; import { randomBytes, randomInt } from '@aztec/foundation/crypto'; -import { - type ContractClassPublic, - type ContractInstanceWithAddress, - SerializableContractInstance, -} from '@aztec/types/contracts'; import { type ArchiverDataStore, type ArchiverL1SynchPoint } from './archiver_store.js'; import { type L1Published } from './structs/published.js'; diff --git a/yarn-project/archiver/src/archiver/kv_archiver_store/contract_class_store.ts b/yarn-project/archiver/src/archiver/kv_archiver_store/contract_class_store.ts index df0b7c80b9b..2c63b150ad2 100644 --- a/yarn-project/archiver/src/archiver/kv_archiver_store/contract_class_store.ts +++ b/yarn-project/archiver/src/archiver/kv_archiver_store/contract_class_store.ts @@ -1,12 +1,14 @@ -import { Fr, FunctionSelector, Vector } from '@aztec/circuits.js'; -import { BufferReader, numToUInt8, serializeToBuffer } from '@aztec/foundation/serialize'; -import { type AztecKVStore, type AztecMap } from '@aztec/kv-store'; import { type ContractClassPublic, type ContractClassPublicWithBlockNumber, type ExecutablePrivateFunctionWithMembershipProof, + Fr, + FunctionSelector, type UnconstrainedFunctionWithMembershipProof, -} from '@aztec/types/contracts'; + Vector, +} from '@aztec/circuits.js'; +import { BufferReader, numToUInt8, serializeToBuffer } from '@aztec/foundation/serialize'; +import { type AztecKVStore, type AztecMap } from '@aztec/kv-store'; /** * LMDB implementation of the ArchiverDataStore interface. diff --git a/yarn-project/archiver/src/archiver/kv_archiver_store/contract_instance_store.ts b/yarn-project/archiver/src/archiver/kv_archiver_store/contract_instance_store.ts index 9aa40c56271..194d5222763 100644 --- a/yarn-project/archiver/src/archiver/kv_archiver_store/contract_instance_store.ts +++ b/yarn-project/archiver/src/archiver/kv_archiver_store/contract_instance_store.ts @@ -1,6 +1,5 @@ -import { type AztecAddress } from '@aztec/circuits.js'; +import { type AztecAddress, type ContractInstanceWithAddress, SerializableContractInstance } from '@aztec/circuits.js'; import { type AztecKVStore, type AztecMap } from '@aztec/kv-store'; -import { type ContractInstanceWithAddress, SerializableContractInstance } from '@aztec/types/contracts'; /** * LMDB implementation of the ArchiverDataStore interface. diff --git a/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts b/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts index 37a2d7d11f4..75b7afff8be 100644 --- a/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts +++ b/yarn-project/archiver/src/archiver/kv_archiver_store/kv_archiver_store.ts @@ -10,17 +10,18 @@ import { type TxHash, type TxReceipt, } from '@aztec/circuit-types'; -import { type Fr, type Header } from '@aztec/circuits.js'; -import { type ContractArtifact } from '@aztec/foundation/abi'; -import { type AztecAddress } from '@aztec/foundation/aztec-address'; -import { createDebugLogger } from '@aztec/foundation/log'; -import { type AztecKVStore } from '@aztec/kv-store'; import { type ContractClassPublic, type ContractInstanceWithAddress, type ExecutablePrivateFunctionWithMembershipProof, + type Fr, + type Header, type UnconstrainedFunctionWithMembershipProof, -} from '@aztec/types/contracts'; +} from '@aztec/circuits.js'; +import { type ContractArtifact } from '@aztec/foundation/abi'; +import { type AztecAddress } from '@aztec/foundation/aztec-address'; +import { createDebugLogger } from '@aztec/foundation/log'; +import { type AztecKVStore } from '@aztec/kv-store'; import { type ArchiverDataStore, type ArchiverL1SynchPoint } from '../archiver_store.js'; import { type DataRetrieval } from '../structs/data_retrieval.js'; diff --git a/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts b/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts index 6bb14927baa..6c1f234e435 100644 --- a/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts +++ b/yarn-project/archiver/src/archiver/memory_archiver_store/memory_archiver_store.ts @@ -15,16 +15,18 @@ import { TxReceipt, type UnencryptedL2BlockL2Logs, } from '@aztec/circuit-types'; -import { Fr, type Header, INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js'; -import { type ContractArtifact } from '@aztec/foundation/abi'; -import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { type ContractClassPublic, type ContractClassPublicWithBlockNumber, type ContractInstanceWithAddress, type ExecutablePrivateFunctionWithMembershipProof, + Fr, + type Header, + INITIAL_L2_BLOCK_NUM, type UnconstrainedFunctionWithMembershipProof, -} from '@aztec/types/contracts'; +} from '@aztec/circuits.js'; +import { type ContractArtifact } from '@aztec/foundation/abi'; +import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { type ArchiverDataStore, type ArchiverL1SynchPoint } from '../archiver_store.js'; import { type DataRetrieval } from '../structs/data_retrieval.js'; diff --git a/yarn-project/archiver/src/factory.ts b/yarn-project/archiver/src/factory.ts index 503b5d97ee0..b7f5d8d8ab8 100644 --- a/yarn-project/archiver/src/factory.ts +++ b/yarn-project/archiver/src/factory.ts @@ -1,9 +1,9 @@ +import { type ContractClassPublic } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { createStore } from '@aztec/kv-store/utils'; import { getCanonicalProtocolContract, protocolContractNames } from '@aztec/protocol-contracts'; import { type TelemetryClient } from '@aztec/telemetry-client'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; -import { type ContractClassPublic } from '@aztec/types/contracts'; import { Archiver } from './archiver/archiver.js'; import { type ArchiverConfig } from './archiver/config.js'; diff --git a/yarn-project/aztec-node/src/aztec-node/server.test.ts b/yarn-project/aztec-node/src/aztec-node/server.test.ts index 1359997c984..81df0550a50 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.test.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.test.ts @@ -9,11 +9,10 @@ import { type WorldStateSynchronizer, mockTxForRollup, } from '@aztec/circuit-types'; -import { EthAddress, Fr, MaxBlockNumber } from '@aztec/circuits.js'; +import { type ContractDataSource, EthAddress, Fr, MaxBlockNumber } from '@aztec/circuits.js'; import { type P2P } from '@aztec/p2p'; import { type GlobalVariableBuilder } from '@aztec/sequencer-client'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; -import { type ContractDataSource } from '@aztec/types/contracts'; import { type MockProxy, mock } from 'jest-mock-extended'; diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index 51a95ad8252..34b8442158d 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -33,6 +33,9 @@ import { } from '@aztec/circuit-types'; import { type ARCHIVE_HEIGHT, + type ContractClassPublic, + type ContractDataSource, + type ContractInstanceWithAddress, EthAddress, Fr, type Header, @@ -43,6 +46,7 @@ import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, type NullifierLeafPreimage, type PUBLIC_DATA_TREE_HEIGHT, + type ProtocolContractAddresses, type PublicDataTreeLeafPreimage, } from '@aztec/circuits.js'; import { computePublicDataTreeLeafSlot } from '@aztec/circuits.js/hash'; @@ -69,12 +73,6 @@ import { GlobalVariableBuilder, SequencerClient } from '@aztec/sequencer-client' import { PublicProcessorFactory, WASMSimulator, createSimulationProvider } from '@aztec/simulator'; import { type TelemetryClient } from '@aztec/telemetry-client'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; -import { - type ContractClassPublic, - type ContractDataSource, - type ContractInstanceWithAddress, - type ProtocolContractAddresses, -} from '@aztec/types/contracts'; import { createValidatorClient } from '@aztec/validator-client'; import { createWorldStateSynchronizer } from '@aztec/world-state'; diff --git a/yarn-project/aztec.js/src/account/contract.ts b/yarn-project/aztec.js/src/account/contract.ts index 6c49a3b5cf0..8408c936563 100644 --- a/yarn-project/aztec.js/src/account/contract.ts +++ b/yarn-project/aztec.js/src/account/contract.ts @@ -1,6 +1,6 @@ import { type CompleteAddress } from '@aztec/circuit-types'; +import { type NodeInfo } from '@aztec/circuits.js'; import { type ContractArtifact } from '@aztec/foundation/abi'; -import { type NodeInfo } from '@aztec/types/interfaces'; import { type AccountInterface, type AuthWitnessProvider } from './interface.js'; diff --git a/yarn-project/aztec.js/src/account_manager/index.ts b/yarn-project/aztec.js/src/account_manager/index.ts index effd1402c64..d7012cfb266 100644 --- a/yarn-project/aztec.js/src/account_manager/index.ts +++ b/yarn-project/aztec.js/src/account_manager/index.ts @@ -1,7 +1,6 @@ import { CompleteAddress, type PXE } from '@aztec/circuit-types'; -import { deriveKeys, getContractInstanceFromDeployParams } from '@aztec/circuits.js'; +import { type ContractInstanceWithAddress, deriveKeys, getContractInstanceFromDeployParams } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { type AccountContract } from '../account/contract.js'; import { type Salt } from '../account/index.js'; diff --git a/yarn-project/aztec.js/src/contract/contract.test.ts b/yarn-project/aztec.js/src/contract/contract.test.ts index 693c02c2f64..595fa96ba96 100644 --- a/yarn-project/aztec.js/src/contract/contract.test.ts +++ b/yarn-project/aztec.js/src/contract/contract.test.ts @@ -6,11 +6,15 @@ import { type TxReceipt, type TxSimulationResult, } from '@aztec/circuit-types'; -import { AztecAddress, CompleteAddress, EthAddress } from '@aztec/circuits.js'; +import { + AztecAddress, + CompleteAddress, + type ContractInstanceWithAddress, + EthAddress, + type NodeInfo, +} from '@aztec/circuits.js'; import { type L1ContractAddresses } from '@aztec/ethereum'; import { type AbiDecoded, type ContractArtifact, FunctionType } from '@aztec/foundation/abi'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; -import { type NodeInfo } from '@aztec/types/interfaces'; import { type MockProxy, mock } from 'jest-mock-extended'; diff --git a/yarn-project/aztec.js/src/contract/contract_base.ts b/yarn-project/aztec.js/src/contract/contract_base.ts index 7be0183ae8b..94efbb63a9e 100644 --- a/yarn-project/aztec.js/src/contract/contract_base.ts +++ b/yarn-project/aztec.js/src/contract/contract_base.ts @@ -1,4 +1,4 @@ -import { computePartialAddress } from '@aztec/circuits.js'; +import { type ContractInstanceWithAddress, computePartialAddress } from '@aztec/circuits.js'; import { type ContractArtifact, type ContractNote, @@ -6,7 +6,6 @@ import { type FunctionArtifact, FunctionSelector, } from '@aztec/foundation/abi'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { type Wallet } from '../account/index.js'; import { ContractFunctionInteraction } from './contract_function_interaction.js'; diff --git a/yarn-project/aztec.js/src/contract/deploy_method.ts b/yarn-project/aztec.js/src/contract/deploy_method.ts index 4afde286852..1a58dec0a65 100644 --- a/yarn-project/aztec.js/src/contract/deploy_method.ts +++ b/yarn-project/aztec.js/src/contract/deploy_method.ts @@ -1,13 +1,13 @@ import { type FunctionCall, type TxExecutionRequest } from '@aztec/circuit-types'; import { AztecAddress, + type ContractInstanceWithAddress, computePartialAddress, getContractClassFromArtifact, getContractInstanceFromDeployParams, } from '@aztec/circuits.js'; import { type ContractArtifact, type FunctionArtifact, getInitializer } from '@aztec/foundation/abi'; import { type Fr } from '@aztec/foundation/fields'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { type Wallet } from '../account/index.js'; import { deployInstance } from '../deployment/deploy_instance.js'; diff --git a/yarn-project/aztec.js/src/contract/deploy_proven_tx.ts b/yarn-project/aztec.js/src/contract/deploy_proven_tx.ts index 43f5d70e449..e364c03b20d 100644 --- a/yarn-project/aztec.js/src/contract/deploy_proven_tx.ts +++ b/yarn-project/aztec.js/src/contract/deploy_proven_tx.ts @@ -1,6 +1,5 @@ import { type PXE, type Tx } from '@aztec/circuit-types'; -import { type AztecAddress } from '@aztec/circuits.js'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; +import { type AztecAddress, type ContractInstanceWithAddress } from '@aztec/circuits.js'; import { type Wallet } from '../account/index.js'; import { type Contract } from './contract.js'; diff --git a/yarn-project/aztec.js/src/contract/deploy_sent_tx.ts b/yarn-project/aztec.js/src/contract/deploy_sent_tx.ts index b645d3dc6d2..6f59cfeb261 100644 --- a/yarn-project/aztec.js/src/contract/deploy_sent_tx.ts +++ b/yarn-project/aztec.js/src/contract/deploy_sent_tx.ts @@ -1,8 +1,7 @@ import { type PXE, type TxHash, type TxReceipt } from '@aztec/circuit-types'; -import { type AztecAddress } from '@aztec/circuits.js'; +import { type AztecAddress, type ContractInstanceWithAddress } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { type FieldsOf } from '@aztec/foundation/types'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { type Wallet } from '../account/index.js'; import { type Contract } from './contract.js'; diff --git a/yarn-project/aztec.js/src/contract/unsafe_contract.ts b/yarn-project/aztec.js/src/contract/unsafe_contract.ts index e47fb3b3266..b848e107986 100644 --- a/yarn-project/aztec.js/src/contract/unsafe_contract.ts +++ b/yarn-project/aztec.js/src/contract/unsafe_contract.ts @@ -1,5 +1,5 @@ +import { type ContractInstanceWithAddress } from '@aztec/circuits.js'; import { type ContractArtifact } from '@aztec/foundation/abi'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { type Wallet } from '../wallet/index.js'; import { ContractBase } from './contract_base.js'; diff --git a/yarn-project/aztec.js/src/deployment/deploy_instance.ts b/yarn-project/aztec.js/src/deployment/deploy_instance.ts index fe8ec9ae42d..1a35fc77a21 100644 --- a/yarn-project/aztec.js/src/deployment/deploy_instance.ts +++ b/yarn-project/aztec.js/src/deployment/deploy_instance.ts @@ -1,4 +1,4 @@ -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; +import { type ContractInstanceWithAddress } from '@aztec/circuits.js'; import { type ContractFunctionInteraction } from '../contract/contract_function_interaction.js'; import { type Wallet } from '../wallet/index.js'; diff --git a/yarn-project/aztec.js/src/index.ts b/yarn-project/aztec.js/src/index.ts index 71cf83cb176..6e202c2dc1e 100644 --- a/yarn-project/aztec.js/src/index.ts +++ b/yarn-project/aztec.js/src/index.ts @@ -79,6 +79,9 @@ export { Point, getContractClassFromArtifact, getContractInstanceFromDeployParams, + ContractClassWithId, + ContractInstanceWithAddress, + NodeInfo, } from '@aztec/circuits.js'; export { computeSecretHash } from '@aztec/circuits.js/hash'; @@ -137,9 +140,6 @@ export { EpochProofQuote, EpochProofQuotePayload, } from '@aztec/circuit-types'; -export type { NodeInfo } from '@aztec/types/interfaces'; - -export type { ContractClassWithId, ContractInstanceWithAddress } from '@aztec/types/contracts'; // TODO: These kinds of things have no place on our public api. // External devs will almost certainly have their own methods of doing these things. diff --git a/yarn-project/aztec.js/src/wallet/base_wallet.ts b/yarn-project/aztec.js/src/wallet/base_wallet.ts index 5042e0b103d..e64396187a7 100644 --- a/yarn-project/aztec.js/src/wallet/base_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/base_wallet.ts @@ -26,14 +26,15 @@ import { type NoteProcessorStats } from '@aztec/circuit-types/stats'; import { type AztecAddress, type CompleteAddress, + type ContractClassWithId, + type ContractInstanceWithAddress, type Fr, type L1_TO_L2_MSG_TREE_HEIGHT, + type NodeInfo, type PartialAddress, type Point, } from '@aztec/circuits.js'; import { type ContractArtifact } from '@aztec/foundation/abi'; -import { type ContractClassWithId, type ContractInstanceWithAddress } from '@aztec/types/contracts'; -import { type NodeInfo } from '@aztec/types/interfaces'; import { type Wallet } from '../account/wallet.js'; import { type ExecutionRequestInit } from '../entrypoint/entrypoint.js'; diff --git a/yarn-project/bb-prover/src/avm_proving.test.ts b/yarn-project/bb-prover/src/avm_proving.test.ts index 20645d878e5..5ed7f8c4c6a 100644 --- a/yarn-project/bb-prover/src/avm_proving.test.ts +++ b/yarn-project/bb-prover/src/avm_proving.test.ts @@ -1,4 +1,11 @@ -import { AvmCircuitInputs, AvmVerificationKeyData, FunctionSelector, Gas, GlobalVariables } from '@aztec/circuits.js'; +import { + AvmCircuitInputs, + AvmVerificationKeyData, + FunctionSelector, + Gas, + GlobalVariables, + SerializableContractInstance, +} from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; import { AvmSimulator, PublicSideEffectTrace, type WorldStateDB } from '@aztec/simulator'; @@ -9,7 +16,6 @@ import { initPersistableStateManager, resolveAvmTestContractAssertionMessage, } from '@aztec/simulator/avm/fixtures'; -import { SerializableContractInstance } from '@aztec/types/contracts'; import { jest } from '@jest/globals'; import { mock } from 'jest-mock-extended'; diff --git a/yarn-project/circuit-types/src/interfaces/aztec-node.ts b/yarn-project/circuit-types/src/interfaces/aztec-node.ts index aefe1d6a38a..b8f7c80634c 100644 --- a/yarn-project/circuit-types/src/interfaces/aztec-node.ts +++ b/yarn-project/circuit-types/src/interfaces/aztec-node.ts @@ -1,20 +1,18 @@ import type { ARCHIVE_HEIGHT, + ContractClassPublic, + ContractInstanceWithAddress, Header, L1_TO_L2_MSG_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, + ProtocolContractAddresses, } from '@aztec/circuits.js'; import type { L1ContractAddresses } from '@aztec/ethereum'; import type { ContractArtifact } from '@aztec/foundation/abi'; import type { AztecAddress } from '@aztec/foundation/aztec-address'; import type { Fr } from '@aztec/foundation/fields'; -import type { - ContractClassPublic, - ContractInstanceWithAddress, - ProtocolContractAddresses, -} from '@aztec/types/contracts'; import type { L2Block } from '../l2_block.js'; import type { FromLogType, GetUnencryptedLogsResponse, L2BlockL2Logs, LogFilter, LogType } from '../logs/index.js'; diff --git a/yarn-project/circuit-types/src/interfaces/pxe.ts b/yarn-project/circuit-types/src/interfaces/pxe.ts index 37e079f38b0..26721aee915 100644 --- a/yarn-project/circuit-types/src/interfaces/pxe.ts +++ b/yarn-project/circuit-types/src/interfaces/pxe.ts @@ -1,18 +1,16 @@ import { type AztecAddress, type CompleteAddress, + type ContractClassWithId, + type ContractInstanceWithAddress, type Fr, type L1_TO_L2_MSG_TREE_HEIGHT, + type NodeInfo, type PartialAddress, type Point, + type ProtocolContractAddresses, } from '@aztec/circuits.js'; import { type ContractArtifact, type EventSelector } from '@aztec/foundation/abi'; -import { - type ContractClassWithId, - type ContractInstanceWithAddress, - type ProtocolContractAddresses, -} from '@aztec/types/contracts'; -import { type NodeInfo } from '@aztec/types/interfaces'; import { type AuthWitness } from '../auth_witness.js'; import { type L2Block } from '../l2_block.js'; diff --git a/yarn-project/circuit-types/src/mocks.ts b/yarn-project/circuit-types/src/mocks.ts index 4360175ca55..f3c3f50aff6 100644 --- a/yarn-project/circuit-types/src/mocks.ts +++ b/yarn-project/circuit-types/src/mocks.ts @@ -2,6 +2,7 @@ import { AztecAddress, CallContext, ClientIvcProof, + type ContractInstanceWithAddress, EthAddress, GasSettings, LogHash, @@ -16,6 +17,7 @@ import { PrivateKernelTailCircuitPublicInputs, PublicAccumulatedDataBuilder, ScopedLogHash, + SerializableContractInstance, computeContractAddressFromInstance, computeContractClassId, getContractClassFromArtifact, @@ -32,7 +34,6 @@ import { padArrayEnd, times } from '@aztec/foundation/collection'; import { randomBigInt, randomBytes, randomInt } from '@aztec/foundation/crypto'; import { Signature } from '@aztec/foundation/eth-signature'; import { Fr } from '@aztec/foundation/fields'; -import { type ContractInstanceWithAddress, SerializableContractInstance } from '@aztec/types/contracts'; import { EncryptedNoteTxL2Logs, EncryptedTxL2Logs, Note, UnencryptedTxL2Logs } from './logs/index.js'; import { ExtendedNote, UniqueNote } from './notes/index.js'; diff --git a/yarn-project/circuits.js/src/contract/contract_address.ts b/yarn-project/circuits.js/src/contract/contract_address.ts index 348b1a2c44b..7b5edd83db0 100644 --- a/yarn-project/circuits.js/src/contract/contract_address.ts +++ b/yarn-project/circuits.js/src/contract/contract_address.ts @@ -2,11 +2,11 @@ import { type FunctionAbi, FunctionSelector, encodeArguments } from '@aztec/foun import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; -import { type ContractInstance } from '@aztec/types/contracts'; import { GeneratorIndex } from '../constants.gen.js'; import { computeVarArgsHash } from '../hash/hash.js'; import { computeAddress } from '../keys/index.js'; +import { type ContractInstance } from './interfaces/contract_instance.js'; // TODO(@spalladino): Review all generator indices in this file diff --git a/yarn-project/circuits.js/src/contract/contract_class.ts b/yarn-project/circuits.js/src/contract/contract_class.ts index 2bef5cd34f0..28a8a019b45 100644 --- a/yarn-project/circuits.js/src/contract/contract_class.ts +++ b/yarn-project/circuits.js/src/contract/contract_class.ts @@ -1,10 +1,10 @@ import { type ContractArtifact, type FunctionArtifact, FunctionSelector, FunctionType } from '@aztec/foundation/abi'; import { Fr } from '@aztec/foundation/fields'; -import { type ContractClass, type ContractClassWithId, type PublicFunction } from '@aztec/types/contracts'; import { PUBLIC_DISPATCH_SELECTOR } from '../constants.gen.js'; import { computeArtifactHash } from './artifact_hash.js'; import { type ContractClassIdPreimage, computeContractClassIdWithPreimage } from './contract_class_id.js'; +import { type ContractClass, type ContractClassWithId, type PublicFunction } from './interfaces/index.js'; /** Contract artifact including its artifact hash */ type ContractArtifactWithHash = ContractArtifact & { artifactHash: Fr }; diff --git a/yarn-project/circuits.js/src/contract/contract_class_id.test.ts b/yarn-project/circuits.js/src/contract/contract_class_id.test.ts index c9b607c28c6..919211008d2 100644 --- a/yarn-project/circuits.js/src/contract/contract_class_id.test.ts +++ b/yarn-project/circuits.js/src/contract/contract_class_id.test.ts @@ -1,7 +1,7 @@ import { Fr } from '@aztec/foundation/fields'; -import { type ContractClass } from '@aztec/types/contracts'; import { FunctionSelector, computeContractClassId } from '../index.js'; +import { type ContractClass } from './interfaces/contract_class.js'; describe('ContractClass', () => { describe('getContractClassId', () => { diff --git a/yarn-project/circuits.js/src/contract/contract_class_id.ts b/yarn-project/circuits.js/src/contract/contract_class_id.ts index c2ad0f75e93..07d812c8af4 100644 --- a/yarn-project/circuits.js/src/contract/contract_class_id.ts +++ b/yarn-project/circuits.js/src/contract/contract_class_id.ts @@ -1,8 +1,8 @@ import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; -import { type ContractClass } from '@aztec/types/contracts'; import { GeneratorIndex } from '../constants.gen.js'; +import { type ContractClass } from './interfaces/contract_class.js'; import { computePrivateFunctionsRoot } from './private_function.js'; /** diff --git a/yarn-project/types/src/contracts/contract_instance.test.ts b/yarn-project/circuits.js/src/contract/contract_instance.test.ts similarity index 100% rename from yarn-project/types/src/contracts/contract_instance.test.ts rename to yarn-project/circuits.js/src/contract/contract_instance.test.ts diff --git a/yarn-project/circuits.js/src/contract/contract_instance.ts b/yarn-project/circuits.js/src/contract/contract_instance.ts index 3168be0ce0c..df56cb18d40 100644 --- a/yarn-project/circuits.js/src/contract/contract_instance.ts +++ b/yarn-project/circuits.js/src/contract/contract_instance.ts @@ -6,7 +6,8 @@ import { } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; -import { type ContractInstance, type ContractInstanceWithAddress } from '@aztec/types/contracts'; +import { BufferReader, numToUInt8, serializeToBuffer } from '@aztec/foundation/serialize'; +import { type FieldsOf } from '@aztec/foundation/types'; import { getContractClassFromArtifact } from '../contract/contract_class.js'; import { computeContractClassId } from '../contract/contract_class_id.js'; @@ -15,6 +16,80 @@ import { computeInitializationHash, computeInitializationHashFromEncodedArgs, } from './contract_address.js'; +import { type ContractInstance, type ContractInstanceWithAddress } from './interfaces/contract_instance.js'; + +const VERSION = 1 as const; + +export class SerializableContractInstance { + public readonly version = VERSION; + public readonly salt: Fr; + public readonly deployer: AztecAddress; + public readonly contractClassId: Fr; + public readonly initializationHash: Fr; + public readonly publicKeysHash: Fr; + + constructor(instance: ContractInstance) { + if (instance.version !== VERSION) { + throw new Error(`Unexpected contract class version ${instance.version}`); + } + this.salt = instance.salt; + this.deployer = instance.deployer; + this.contractClassId = instance.contractClassId; + this.initializationHash = instance.initializationHash; + this.publicKeysHash = instance.publicKeysHash; + } + + public toBuffer() { + return serializeToBuffer( + numToUInt8(this.version), + this.salt, + this.deployer, + this.contractClassId, + this.initializationHash, + this.publicKeysHash, + ); + } + + /** Returns a copy of this object with its address included. */ + withAddress(address: AztecAddress): ContractInstanceWithAddress { + return { ...this, address }; + } + + static fromBuffer(bufferOrReader: Buffer | BufferReader) { + const reader = BufferReader.asReader(bufferOrReader); + return new SerializableContractInstance({ + version: reader.readUInt8() as typeof VERSION, + salt: reader.readObject(Fr), + deployer: reader.readObject(AztecAddress), + contractClassId: reader.readObject(Fr), + initializationHash: reader.readObject(Fr), + publicKeysHash: reader.readObject(Fr), + }); + } + + static random(opts: Partial> = {}) { + return new SerializableContractInstance({ + version: VERSION, + salt: Fr.random(), + deployer: AztecAddress.random(), + contractClassId: Fr.random(), + initializationHash: Fr.random(), + publicKeysHash: Fr.random(), + ...opts, + }); + } + + static empty() { + return new SerializableContractInstance({ + version: VERSION, + salt: Fr.zero(), + deployer: AztecAddress.zero(), + contractClassId: Fr.zero(), + initializationHash: Fr.zero(), + publicKeysHash: Fr.zero(), + }); + } +} /** * Generates a Contract Instance from the deployment params. diff --git a/yarn-project/circuits.js/src/contract/events/contract_class_registered_event.ts b/yarn-project/circuits.js/src/contract/events/contract_class_registered_event.ts index 8b31a525929..bc88b985759 100644 --- a/yarn-project/circuits.js/src/contract/events/contract_class_registered_event.ts +++ b/yarn-project/circuits.js/src/contract/events/contract_class_registered_event.ts @@ -3,12 +3,12 @@ import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader } from '@aztec/foundation/serialize'; -import { type ContractClassPublic, type PublicFunction } from '@aztec/types/contracts'; import chunk from 'lodash.chunk'; import { PUBLIC_DISPATCH_SELECTOR, REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE } from '../../constants.gen.js'; import { computeContractClassId, computePublicBytecodeCommitment } from '../contract_class_id.js'; +import { type ContractClassPublic, type PublicFunction } from '../interfaces/index.js'; /** Event emitted from the ContractClassRegisterer. */ export class ContractClassRegisteredEvent { diff --git a/yarn-project/circuits.js/src/contract/events/contract_instance_deployed_event.ts b/yarn-project/circuits.js/src/contract/events/contract_instance_deployed_event.ts index af330414710..2694bdb7f2d 100644 --- a/yarn-project/circuits.js/src/contract/events/contract_instance_deployed_event.ts +++ b/yarn-project/circuits.js/src/contract/events/contract_instance_deployed_event.ts @@ -2,9 +2,9 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader } from '@aztec/foundation/serialize'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { DEPLOYER_CONTRACT_ADDRESS, DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE } from '../../constants.gen.js'; +import { type ContractInstanceWithAddress } from '../interfaces/contract_instance.js'; /** Event emitted from the ContractInstanceDeployer. */ export class ContractInstanceDeployedEvent { diff --git a/yarn-project/circuits.js/src/contract/events/private_function_broadcasted_event.ts b/yarn-project/circuits.js/src/contract/events/private_function_broadcasted_event.ts index ae579a2fac2..595a3b6dd9c 100644 --- a/yarn-project/circuits.js/src/contract/events/private_function_broadcasted_event.ts +++ b/yarn-project/circuits.js/src/contract/events/private_function_broadcasted_event.ts @@ -3,7 +3,6 @@ import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, type Tuple } from '@aztec/foundation/serialize'; -import { type ExecutablePrivateFunctionWithMembershipProof, type PrivateFunction } from '@aztec/types/contracts'; import chunk from 'lodash.chunk'; @@ -15,6 +14,7 @@ import { REGISTERER_PRIVATE_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS, REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE, } from '../../constants.gen.js'; +import { type ExecutablePrivateFunctionWithMembershipProof, type PrivateFunction } from '../interfaces/index.js'; /** Event emitted from the ContractClassRegisterer. */ export class PrivateFunctionBroadcastedEvent { diff --git a/yarn-project/circuits.js/src/contract/events/unconstrained_function_broadcasted_event.ts b/yarn-project/circuits.js/src/contract/events/unconstrained_function_broadcasted_event.ts index 32556036e77..4948319bebf 100644 --- a/yarn-project/circuits.js/src/contract/events/unconstrained_function_broadcasted_event.ts +++ b/yarn-project/circuits.js/src/contract/events/unconstrained_function_broadcasted_event.ts @@ -4,7 +4,6 @@ import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { removeArrayPaddingEnd } from '@aztec/foundation/collection'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, type Tuple } from '@aztec/foundation/serialize'; -import { type UnconstrainedFunction, type UnconstrainedFunctionWithMembershipProof } from '@aztec/types/contracts'; import chunk from 'lodash.chunk'; @@ -15,6 +14,7 @@ import { REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS, REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE, } from '../../constants.gen.js'; +import { type UnconstrainedFunction, type UnconstrainedFunctionWithMembershipProof } from '../interfaces/index.js'; /** Event emitted from the ContractClassRegisterer. */ export class UnconstrainedFunctionBroadcastedEvent { diff --git a/yarn-project/circuits.js/src/contract/index.ts b/yarn-project/circuits.js/src/contract/index.ts index d5a383d8068..98449797223 100644 --- a/yarn-project/circuits.js/src/contract/index.ts +++ b/yarn-project/circuits.js/src/contract/index.ts @@ -10,3 +10,4 @@ export * from './events/unconstrained_function_broadcasted_event.js'; export * from './private_function.js'; export * from './private_function_membership_proof.js'; export * from './unconstrained_function_membership_proof.js'; +export * from './interfaces/index.js'; diff --git a/yarn-project/types/src/contracts/contract_class.ts b/yarn-project/circuits.js/src/contract/interfaces/contract_class.ts similarity index 100% rename from yarn-project/types/src/contracts/contract_class.ts rename to yarn-project/circuits.js/src/contract/interfaces/contract_class.ts diff --git a/yarn-project/types/src/contracts/contract_data_source.ts b/yarn-project/circuits.js/src/contract/interfaces/contract_data_source.ts similarity index 100% rename from yarn-project/types/src/contracts/contract_data_source.ts rename to yarn-project/circuits.js/src/contract/interfaces/contract_data_source.ts diff --git a/yarn-project/circuits.js/src/contract/interfaces/contract_instance.ts b/yarn-project/circuits.js/src/contract/interfaces/contract_instance.ts new file mode 100644 index 00000000000..3c3a9923a0f --- /dev/null +++ b/yarn-project/circuits.js/src/contract/interfaces/contract_instance.ts @@ -0,0 +1,22 @@ +import { type AztecAddress } from '@aztec/foundation/aztec-address'; +import { type Fr } from '@aztec/foundation/fields'; + +const VERSION = 1 as const; + +/** A contract instance is a concrete deployment of a contract class. A contract instance always references a contract class, which dictates what code it executes when called. A contract instance has state (both private and public), as well as an address that acts as its identifier. A contract instance can be called into. */ +export interface ContractInstance { + /** Version identifier. Initially one, bumped for any changes to the contract instance struct. */ + version: typeof VERSION; + /** User-generated pseudorandom value for uniqueness. */ + salt: Fr; + /** Optional deployer address or zero if this was a universal deploy. */ + deployer: AztecAddress; + /** Identifier of the contract class for this instance. */ + contractClassId: Fr; + /** Hash of the selector and arguments to the constructor. */ + initializationHash: Fr; + /** Optional hash of the struct of public keys used for encryption and nullifying by this contract. */ + publicKeysHash: Fr; +} + +export type ContractInstanceWithAddress = ContractInstance & { address: AztecAddress }; diff --git a/yarn-project/types/src/contracts/index.ts b/yarn-project/circuits.js/src/contract/interfaces/index.ts similarity index 84% rename from yarn-project/types/src/contracts/index.ts rename to yarn-project/circuits.js/src/contract/interfaces/index.ts index b611911b5c3..e3b0d5ebf86 100644 --- a/yarn-project/types/src/contracts/index.ts +++ b/yarn-project/circuits.js/src/contract/interfaces/index.ts @@ -1,4 +1,5 @@ export * from './contract_class.js'; -export * from './contract_instance.js'; export * from './contract_data_source.js'; +export * from './contract_instance.js'; +export * from './node-info.js'; export * from './protocol_contract_addresses.js'; diff --git a/yarn-project/types/src/interfaces/node-info.ts b/yarn-project/circuits.js/src/contract/interfaces/node-info.ts similarity index 86% rename from yarn-project/types/src/interfaces/node-info.ts rename to yarn-project/circuits.js/src/contract/interfaces/node-info.ts index fd10048f5f3..3813025aa61 100644 --- a/yarn-project/types/src/interfaces/node-info.ts +++ b/yarn-project/circuits.js/src/contract/interfaces/node-info.ts @@ -1,6 +1,6 @@ import { type L1ContractAddresses } from '@aztec/ethereum'; -import { type ProtocolContractAddresses } from '../contracts/protocol_contract_addresses.js'; +import { type ProtocolContractAddresses } from './protocol_contract_addresses.js'; /** * Provides basic information about the running node. diff --git a/yarn-project/types/src/contracts/protocol_contract_addresses.ts b/yarn-project/circuits.js/src/contract/interfaces/protocol_contract_addresses.ts similarity index 100% rename from yarn-project/types/src/contracts/protocol_contract_addresses.ts rename to yarn-project/circuits.js/src/contract/interfaces/protocol_contract_addresses.ts diff --git a/yarn-project/circuits.js/src/contract/private_function.test.ts b/yarn-project/circuits.js/src/contract/private_function.test.ts index c4bbb377b01..e3c72db9bfc 100644 --- a/yarn-project/circuits.js/src/contract/private_function.test.ts +++ b/yarn-project/circuits.js/src/contract/private_function.test.ts @@ -1,8 +1,8 @@ import { Fr } from '@aztec/foundation/fields'; import { setupCustomSnapshotSerializers } from '@aztec/foundation/testing'; -import { type PrivateFunction } from '@aztec/types/contracts'; import { fr, makeSelector } from '../tests/factories.js'; +import { type PrivateFunction } from './interfaces/contract_class.js'; import { computePrivateFunctionsRoot, computePrivateFunctionsTree } from './private_function.js'; describe('PrivateFunction', () => { diff --git a/yarn-project/circuits.js/src/contract/private_function.ts b/yarn-project/circuits.js/src/contract/private_function.ts index 79ea6b61403..16fa61a36b9 100644 --- a/yarn-project/circuits.js/src/contract/private_function.ts +++ b/yarn-project/circuits.js/src/contract/private_function.ts @@ -1,9 +1,9 @@ import { pedersenHash, poseidon2Hash, poseidon2HashWithSeparator } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; -import { type PrivateFunction } from '@aztec/types/contracts'; import { FUNCTION_TREE_HEIGHT, GeneratorIndex } from '../constants.gen.js'; import { type MerkleTree, MerkleTreeCalculator } from '../merkle/index.js'; +import { type PrivateFunction } from './interfaces/contract_class.js'; // Memoize the merkle tree calculators to avoid re-computing the zero-hash for each level in each call let privateFunctionTreeCalculator: MerkleTreeCalculator | undefined; diff --git a/yarn-project/circuits.js/src/contract/private_function_membership_proof.test.ts b/yarn-project/circuits.js/src/contract/private_function_membership_proof.test.ts index 958af440bf9..c63a517957d 100644 --- a/yarn-project/circuits.js/src/contract/private_function_membership_proof.test.ts +++ b/yarn-project/circuits.js/src/contract/private_function_membership_proof.test.ts @@ -1,10 +1,10 @@ import { type ContractArtifact, type FunctionArtifact, FunctionSelector, FunctionType } from '@aztec/foundation/abi'; import { Fr } from '@aztec/foundation/fields'; -import { type ContractClass } from '@aztec/types/contracts'; import { getBenchmarkContractArtifact } from '../tests/fixtures.js'; import { computeVerificationKeyHash, getContractClassFromArtifact } from './contract_class.js'; import { type ContractClassIdPreimage } from './contract_class_id.js'; +import { type ContractClass } from './interfaces/contract_class.js'; import { createPrivateFunctionMembershipProof, isValidPrivateFunctionMembershipProof, diff --git a/yarn-project/circuits.js/src/contract/private_function_membership_proof.ts b/yarn-project/circuits.js/src/contract/private_function_membership_proof.ts index 6ed5b4bcd6a..0d46fc62f5f 100644 --- a/yarn-project/circuits.js/src/contract/private_function_membership_proof.ts +++ b/yarn-project/circuits.js/src/contract/private_function_membership_proof.ts @@ -2,11 +2,6 @@ import { type ContractArtifact, type FunctionSelector, FunctionType } from '@azt import { poseidon2Hash } from '@aztec/foundation/crypto'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; -import { - type ContractClassPublic, - type ExecutablePrivateFunctionWithMembershipProof, - type PrivateFunctionMembershipProof, -} from '@aztec/types/contracts'; import { computeRootFromSiblingPath } from '../merkle/index.js'; import { @@ -18,6 +13,11 @@ import { getArtifactMerkleTreeHasher, } from './artifact_hash.js'; import { getContractClassPrivateFunctionFromArtifact } from './contract_class.js'; +import { + type ContractClassPublic, + type ExecutablePrivateFunctionWithMembershipProof, + type PrivateFunctionMembershipProof, +} from './interfaces/index.js'; import { computePrivateFunctionLeaf, computePrivateFunctionsTree } from './private_function.js'; /** diff --git a/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts b/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts index e128aa7abb0..03ee47322c3 100644 --- a/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts +++ b/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.test.ts @@ -1,10 +1,10 @@ import { type ContractArtifact, type FunctionArtifact, FunctionSelector, FunctionType } from '@aztec/foundation/abi'; import { Fr } from '@aztec/foundation/fields'; -import { type ContractClass } from '@aztec/types/contracts'; import { getTestContractArtifact } from '../tests/fixtures.js'; import { getContractClassFromArtifact } from './contract_class.js'; import { type ContractClassIdPreimage } from './contract_class_id.js'; +import { type ContractClass } from './interfaces/contract_class.js'; import { createUnconstrainedFunctionMembershipProof, isValidUnconstrainedFunctionMembershipProof, diff --git a/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.ts b/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.ts index a6b368c6d5e..309078338f7 100644 --- a/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.ts +++ b/yarn-project/circuits.js/src/contract/unconstrained_function_membership_proof.ts @@ -1,11 +1,6 @@ import { type ContractArtifact, type FunctionSelector, FunctionType } from '@aztec/foundation/abi'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; -import { - type ContractClassPublic, - type UnconstrainedFunctionMembershipProof, - type UnconstrainedFunctionWithMembershipProof, -} from '@aztec/types/contracts'; import { computeRootFromSiblingPath } from '../merkle/index.js'; import { @@ -16,6 +11,11 @@ import { computeFunctionMetadataHash, getArtifactMerkleTreeHasher, } from './artifact_hash.js'; +import { + type ContractClassPublic, + type UnconstrainedFunctionMembershipProof, + type UnconstrainedFunctionWithMembershipProof, +} from './interfaces/index.js'; /** * Creates a membership proof for an unconstrained function in a contract class, to be verified via `isValidUnconstrainedFunctionMembershipProof`. diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 9b39e39720b..d8fbdb791fb 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -4,15 +4,15 @@ import { toBufferBE } from '@aztec/foundation/bigint-buffer'; import { compact } from '@aztec/foundation/collection'; import { EthAddress } from '@aztec/foundation/eth-address'; import { type Bufferable } from '@aztec/foundation/serialize'; + +import { SchnorrSignature } from '../barretenberg/index.js'; import { type ContractClassPublic, type ExecutablePrivateFunctionWithMembershipProof, type PrivateFunction, type PublicFunction, type UnconstrainedFunctionWithMembershipProof, -} from '@aztec/types/contracts'; - -import { SchnorrSignature } from '../barretenberg/index.js'; +} from '../contract/index.js'; import { ARCHIVE_HEIGHT, AZTEC_EPOCH_DURATION, diff --git a/yarn-project/ivc-integration/src/avm_integration.test.ts b/yarn-project/ivc-integration/src/avm_integration.test.ts index e3d0872b0df..424d91212b5 100644 --- a/yarn-project/ivc-integration/src/avm_integration.test.ts +++ b/yarn-project/ivc-integration/src/avm_integration.test.ts @@ -6,7 +6,13 @@ import { getPublicInputs, verifyProof, } from '@aztec/bb-prover'; -import { AvmCircuitInputs, FunctionSelector, Gas, GlobalVariables } from '@aztec/circuits.js'; +import { + AvmCircuitInputs, + FunctionSelector, + Gas, + GlobalVariables, + SerializableContractInstance, +} from '@aztec/circuits.js'; import { AVM_PROOF_LENGTH_IN_FIELDS, AVM_PUBLIC_COLUMN_MAX_SIZE, @@ -26,7 +32,6 @@ import { initPersistableStateManager, resolveAvmTestContractAssertionMessage, } from '@aztec/simulator/avm/fixtures'; -import { SerializableContractInstance } from '@aztec/types/contracts'; import { jest } from '@jest/globals'; import fs from 'fs/promises'; diff --git a/yarn-project/noir-protocol-circuits-types/src/noir_test_gen.test.ts b/yarn-project/noir-protocol-circuits-types/src/noir_test_gen.test.ts index d4c7d2ee6d2..e9411e3d587 100644 --- a/yarn-project/noir-protocol-circuits-types/src/noir_test_gen.test.ts +++ b/yarn-project/noir-protocol-circuits-types/src/noir_test_gen.test.ts @@ -1,5 +1,7 @@ import { AztecAddress, + type ContractClass, + type ContractInstance, FunctionSelector, computeContractAddressFromInstance, computeContractClassId, @@ -11,7 +13,6 @@ import { } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; import { setupCustomSnapshotSerializers } from '@aztec/foundation/testing'; -import { type ContractClass, type ContractInstance } from '@aztec/types/contracts'; describe('Data generation for noir tests', () => { setupCustomSnapshotSerializers(expect); diff --git a/yarn-project/protocol-contracts/src/protocol_contract.ts b/yarn-project/protocol-contracts/src/protocol_contract.ts index 3b470b62748..bf3f2dbd805 100644 --- a/yarn-project/protocol-contracts/src/protocol_contract.ts +++ b/yarn-project/protocol-contracts/src/protocol_contract.ts @@ -1,11 +1,12 @@ import { type AztecAddress, type ContractClassIdPreimage, + type ContractClassWithId, + type ContractInstanceWithAddress, getContractClassFromArtifact, getContractInstanceFromDeployParams, } from '@aztec/circuits.js'; import { type ContractArtifact } from '@aztec/foundation/abi'; -import { type ContractClassWithId, type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { ProtocolContractAddress, diff --git a/yarn-project/prover-node/src/prover-node.test.ts b/yarn-project/prover-node/src/prover-node.test.ts index a32668f3877..be800b17766 100644 --- a/yarn-project/prover-node/src/prover-node.test.ts +++ b/yarn-project/prover-node/src/prover-node.test.ts @@ -11,14 +11,13 @@ import { WorldStateRunningState, type WorldStateSynchronizer, } from '@aztec/circuit-types'; -import { EthAddress } from '@aztec/circuits.js'; +import { type ContractDataSource, EthAddress } from '@aztec/circuits.js'; import { times } from '@aztec/foundation/collection'; import { Signature } from '@aztec/foundation/eth-signature'; import { sleep } from '@aztec/foundation/sleep'; import { type L1Publisher } from '@aztec/sequencer-client'; import { type PublicProcessorFactory, type SimulationProvider } from '@aztec/simulator'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; -import { type ContractDataSource } from '@aztec/types/contracts'; import { type MockProxy, mock } from 'jest-mock-extended'; diff --git a/yarn-project/prover-node/src/prover-node.ts b/yarn-project/prover-node/src/prover-node.ts index 02513db5219..33d669e5e3d 100644 --- a/yarn-project/prover-node/src/prover-node.ts +++ b/yarn-project/prover-node/src/prover-node.ts @@ -10,12 +10,12 @@ import { type ProverCoordination, type WorldStateSynchronizer, } from '@aztec/circuit-types'; +import { type ContractDataSource } from '@aztec/circuits.js'; import { compact } from '@aztec/foundation/collection'; import { createDebugLogger } from '@aztec/foundation/log'; import { type L1Publisher } from '@aztec/sequencer-client'; import { PublicProcessorFactory, type SimulationProvider } from '@aztec/simulator'; import { type TelemetryClient } from '@aztec/telemetry-client'; -import { type ContractDataSource } from '@aztec/types/contracts'; import { type BondManager } from './bond/bond-manager.js'; import { EpochProvingJob, type EpochProvingJobState } from './job/epoch-proving-job.js'; diff --git a/yarn-project/pxe/src/contract_data_oracle/index.ts b/yarn-project/pxe/src/contract_data_oracle/index.ts index ed2217589f7..e29c95675cd 100644 --- a/yarn-project/pxe/src/contract_data_oracle/index.ts +++ b/yarn-project/pxe/src/contract_data_oracle/index.ts @@ -1,4 +1,4 @@ -import { type AztecAddress } from '@aztec/circuits.js'; +import { type AztecAddress, type ContractClass, type ContractInstance } from '@aztec/circuits.js'; import { type ContractArtifact, type FunctionArtifact, @@ -8,7 +8,6 @@ import { } from '@aztec/foundation/abi'; import { type Fr } from '@aztec/foundation/fields'; import { ContractClassNotFoundError, ContractNotFoundError } from '@aztec/simulator'; -import { type ContractClass, type ContractInstance } from '@aztec/types/contracts'; import { type ContractArtifactDatabase } from '../database/contracts/contract_artifact_db.js'; import { type ContractInstanceDatabase } from '../database/contracts/contract_instance_db.js'; diff --git a/yarn-project/pxe/src/contract_data_oracle/private_functions_tree.ts b/yarn-project/pxe/src/contract_data_oracle/private_functions_tree.ts index 5e1964729e7..dabd6cc0b9e 100644 --- a/yarn-project/pxe/src/contract_data_oracle/private_functions_tree.ts +++ b/yarn-project/pxe/src/contract_data_oracle/private_functions_tree.ts @@ -1,4 +1,5 @@ import { + type ContractClassWithId, FUNCTION_TREE_HEIGHT, MembershipWitness, computePrivateFunctionLeaf, @@ -9,7 +10,6 @@ import { type MerkleTree } from '@aztec/circuits.js/merkle'; import { type ContractArtifact, type FunctionSelector } from '@aztec/foundation/abi'; import { Fr } from '@aztec/foundation/fields'; import { assertLength } from '@aztec/foundation/serialize'; -import { type ContractClassWithId } from '@aztec/types/contracts'; /** * Represents a Merkle tree of functions for a particular Contract Class. diff --git a/yarn-project/pxe/src/database/contracts/contract_instance_db.ts b/yarn-project/pxe/src/database/contracts/contract_instance_db.ts index 77abb2f1641..d4952d7f4b8 100644 --- a/yarn-project/pxe/src/database/contracts/contract_instance_db.ts +++ b/yarn-project/pxe/src/database/contracts/contract_instance_db.ts @@ -1,5 +1,4 @@ -import { type AztecAddress } from '@aztec/circuits.js'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; +import { type AztecAddress, type ContractInstanceWithAddress } from '@aztec/circuits.js'; /** * PXE database for managing contract instances. diff --git a/yarn-project/pxe/src/database/kv_pxe_database.ts b/yarn-project/pxe/src/database/kv_pxe_database.ts index cac62d05cfa..280bc679fd7 100644 --- a/yarn-project/pxe/src/database/kv_pxe_database.ts +++ b/yarn-project/pxe/src/database/kv_pxe_database.ts @@ -5,7 +5,13 @@ import { type OutgoingNotesFilter, type PublicKey, } from '@aztec/circuit-types'; -import { AztecAddress, CompleteAddress, Header } from '@aztec/circuits.js'; +import { + AztecAddress, + CompleteAddress, + type ContractInstanceWithAddress, + Header, + SerializableContractInstance, +} from '@aztec/circuits.js'; import { type ContractArtifact } from '@aztec/foundation/abi'; import { toBufferBE } from '@aztec/foundation/bigint-buffer'; import { Fr, type Point } from '@aztec/foundation/fields'; @@ -18,7 +24,6 @@ import { type AztecSingleton, } from '@aztec/kv-store'; import { contractArtifactFromBuffer, contractArtifactToBuffer } from '@aztec/types/abi'; -import { type ContractInstanceWithAddress, SerializableContractInstance } from '@aztec/types/contracts'; import { DeferredNoteDao } from './deferred_note_dao.js'; import { IncomingNoteDao } from './incoming_note_dao.js'; diff --git a/yarn-project/pxe/src/database/pxe_database.ts b/yarn-project/pxe/src/database/pxe_database.ts index cbc43008980..0562f79bd6d 100644 --- a/yarn-project/pxe/src/database/pxe_database.ts +++ b/yarn-project/pxe/src/database/pxe_database.ts @@ -1,9 +1,13 @@ import { type IncomingNotesFilter, type OutgoingNotesFilter } from '@aztec/circuit-types'; -import { type CompleteAddress, type Header, type PublicKey } from '@aztec/circuits.js'; +import { + type CompleteAddress, + type ContractInstanceWithAddress, + type Header, + type PublicKey, +} from '@aztec/circuits.js'; import { type ContractArtifact } from '@aztec/foundation/abi'; import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { type Fr } from '@aztec/foundation/fields'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { type ContractArtifactDatabase } from './contracts/contract_artifact_db.js'; import { type ContractInstanceDatabase } from './contracts/contract_instance_db.js'; diff --git a/yarn-project/pxe/src/database/pxe_database_test_suite.ts b/yarn-project/pxe/src/database/pxe_database_test_suite.ts index 2c8966a4a87..8981df245fb 100644 --- a/yarn-project/pxe/src/database/pxe_database_test_suite.ts +++ b/yarn-project/pxe/src/database/pxe_database_test_suite.ts @@ -1,10 +1,15 @@ import { type IncomingNotesFilter, NoteStatus, type OutgoingNotesFilter, randomTxHash } from '@aztec/circuit-types'; -import { AztecAddress, CompleteAddress, INITIAL_L2_BLOCK_NUM, PublicKeys } from '@aztec/circuits.js'; +import { + AztecAddress, + CompleteAddress, + INITIAL_L2_BLOCK_NUM, + PublicKeys, + SerializableContractInstance, +} from '@aztec/circuits.js'; import { makeHeader } from '@aztec/circuits.js/testing'; import { randomInt } from '@aztec/foundation/crypto'; import { Fr, Point } from '@aztec/foundation/fields'; import { BenchmarkingContractArtifact } from '@aztec/noir-contracts.js/Benchmarking'; -import { SerializableContractInstance } from '@aztec/types/contracts'; import { type IncomingNoteDao } from './incoming_note_dao.js'; import { randomIncomingNoteDao } from './incoming_note_dao.test.js'; diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index 656cba4570b..140f3d57459 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -36,7 +36,10 @@ import { type NoteProcessorStats } from '@aztec/circuit-types/stats'; import { AztecAddress, type CompleteAddress, + type ContractClassWithId, + type ContractInstanceWithAddress, type L1_TO_L2_MSG_TREE_HEIGHT, + type NodeInfo, PUBLIC_DISPATCH_SELECTOR, type PartialAddress, type PrivateKernelTailCircuitPublicInputs, @@ -62,8 +65,6 @@ import { protocolContractNames, } from '@aztec/protocol-contracts'; import { type AcirSimulator, resolveAssertionMessage, resolveOpcodeLocations } from '@aztec/simulator'; -import { type ContractClassWithId, type ContractInstanceWithAddress } from '@aztec/types/contracts'; -import { type NodeInfo } from '@aztec/types/interfaces'; import { type PXEServiceConfig, getPackageInfo } from '../config/index.js'; import { ContractDataOracle } from '../contract_data_oracle/index.js'; diff --git a/yarn-project/pxe/src/simulator_oracle/index.ts b/yarn-project/pxe/src/simulator_oracle/index.ts index 3e906aff1b6..fac1a6a43ec 100644 --- a/yarn-project/pxe/src/simulator_oracle/index.ts +++ b/yarn-project/pxe/src/simulator_oracle/index.ts @@ -10,6 +10,7 @@ import { import { type AztecAddress, type CompleteAddress, + type ContractInstance, type Fr, type FunctionSelector, type Header, @@ -20,7 +21,6 @@ import { type FunctionArtifact, getFunctionArtifact } from '@aztec/foundation/ab import { createDebugLogger } from '@aztec/foundation/log'; import { type KeyStore } from '@aztec/key-store'; import { type DBOracle, MessageLoadOracleInputs } from '@aztec/simulator'; -import { type ContractInstance } from '@aztec/types/contracts'; import { type ContractDataOracle } from '../contract_data_oracle/index.js'; import { type PxeDatabase } from '../database/index.js'; diff --git a/yarn-project/sequencer-client/src/client/sequencer-client.ts b/yarn-project/sequencer-client/src/client/sequencer-client.ts index 9fd451f8a51..b3332bed4b6 100644 --- a/yarn-project/sequencer-client/src/client/sequencer-client.ts +++ b/yarn-project/sequencer-client/src/client/sequencer-client.ts @@ -1,9 +1,9 @@ import { type L1ToL2MessageSource, type L2BlockSource, type WorldStateSynchronizer } from '@aztec/circuit-types'; +import { type ContractDataSource } from '@aztec/circuits.js'; import { type EthAddress } from '@aztec/foundation/eth-address'; import { type P2P } from '@aztec/p2p'; import { PublicProcessorFactory, type SimulationProvider } from '@aztec/simulator'; import { type TelemetryClient } from '@aztec/telemetry-client'; -import { type ContractDataSource } from '@aztec/types/contracts'; import { type ValidatorClient } from '@aztec/validator-client'; import { LightweightBlockBuilderFactory } from '../block_builder/index.js'; diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts index 7493c01cb33..7b711b25723 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts @@ -22,6 +22,7 @@ import { import { AZTEC_EPOCH_DURATION, AztecAddress, + type ContractDataSource, EthAddress, Fr, GasFees, @@ -36,7 +37,6 @@ import { type Writeable } from '@aztec/foundation/types'; import { type P2P, P2PClientState } from '@aztec/p2p'; import { type PublicProcessor, type PublicProcessorFactory } from '@aztec/simulator'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; -import { type ContractDataSource } from '@aztec/types/contracts'; import { type ValidatorClient } from '@aztec/validator-client'; import { type MockProxy, mock, mockFn } from 'jest-mock-extended'; diff --git a/yarn-project/sequencer-client/src/tx_validator/phases_validator.test.ts b/yarn-project/sequencer-client/src/tx_validator/phases_validator.test.ts index 0b0ac76f845..55a1d0ecb79 100644 --- a/yarn-project/sequencer-client/src/tx_validator/phases_validator.test.ts +++ b/yarn-project/sequencer-client/src/tx_validator/phases_validator.test.ts @@ -1,7 +1,6 @@ import { mockTx } from '@aztec/circuit-types'; -import { type AztecAddress, Fr, type FunctionSelector } from '@aztec/circuits.js'; +import { type AztecAddress, type ContractDataSource, Fr, type FunctionSelector } from '@aztec/circuits.js'; import { makeAztecAddress, makeSelector } from '@aztec/circuits.js/testing'; -import { type ContractDataSource } from '@aztec/types/contracts'; import { type MockProxy, mock, mockFn } from 'jest-mock-extended'; diff --git a/yarn-project/sequencer-client/src/tx_validator/phases_validator.ts b/yarn-project/sequencer-client/src/tx_validator/phases_validator.ts index 053a4a8d333..57d42d5213b 100644 --- a/yarn-project/sequencer-client/src/tx_validator/phases_validator.ts +++ b/yarn-project/sequencer-client/src/tx_validator/phases_validator.ts @@ -5,9 +5,9 @@ import { Tx, type TxValidator, } from '@aztec/circuit-types'; +import { type ContractDataSource } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { ContractsDataSourcePublicDB, EnqueuedCallsProcessor } from '@aztec/simulator'; -import { type ContractDataSource } from '@aztec/types/contracts'; export class PhasesTxValidator implements TxValidator { #log = createDebugLogger('aztec:sequencer:tx_validator:tx_phases'); diff --git a/yarn-project/sequencer-client/src/tx_validator/tx_validator_factory.ts b/yarn-project/sequencer-client/src/tx_validator/tx_validator_factory.ts index 38403daffc2..d0bab6af43e 100644 --- a/yarn-project/sequencer-client/src/tx_validator/tx_validator_factory.ts +++ b/yarn-project/sequencer-client/src/tx_validator/tx_validator_factory.ts @@ -6,7 +6,7 @@ import { type Tx, type TxValidator, } from '@aztec/circuit-types'; -import { type GlobalVariables } from '@aztec/circuits.js'; +import { type ContractDataSource, type GlobalVariables } from '@aztec/circuits.js'; import { AggregateTxValidator, DataTxValidator, @@ -16,7 +16,6 @@ import { } from '@aztec/p2p'; import { ProtocolContractAddress } from '@aztec/protocol-contracts'; import { readPublicState } from '@aztec/simulator'; -import { type ContractDataSource } from '@aztec/types/contracts'; import { GasTxValidator, type PublicStateSource } from './gas_validator.js'; import { PhasesTxValidator } from './phases_validator.js'; diff --git a/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts b/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts index a4531373cc6..f8b25629a83 100644 --- a/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts +++ b/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts @@ -8,11 +8,15 @@ import { type SiblingPath, type UnencryptedL2Log, } from '@aztec/circuit-types'; -import { type Header, type KeyValidationRequest, type L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/circuits.js'; +import { + type ContractInstance, + type Header, + type KeyValidationRequest, + type L1_TO_L2_MSG_TREE_HEIGHT, +} from '@aztec/circuits.js'; import { type FunctionSelector, type NoteSelector } from '@aztec/foundation/abi'; import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; -import { type ContractInstance } from '@aztec/types/contracts'; /** * Information about a note needed during execution. diff --git a/yarn-project/simulator/src/avm/journal/journal.test.ts b/yarn-project/simulator/src/avm/journal/journal.test.ts index 09e368f0100..e0306adb81f 100644 --- a/yarn-project/simulator/src/avm/journal/journal.test.ts +++ b/yarn-project/simulator/src/avm/journal/journal.test.ts @@ -1,6 +1,6 @@ import { randomContractInstanceWithAddress } from '@aztec/circuit-types'; +import { SerializableContractInstance } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; -import { SerializableContractInstance } from '@aztec/types/contracts'; import { mock } from 'jest-mock-extended'; diff --git a/yarn-project/simulator/src/avm/journal/journal.ts b/yarn-project/simulator/src/avm/journal/journal.ts index c00150d0344..81ea9759ac3 100644 --- a/yarn-project/simulator/src/avm/journal/journal.ts +++ b/yarn-project/simulator/src/avm/journal/journal.ts @@ -1,7 +1,6 @@ -import { AztecAddress, type FunctionSelector, type Gas } from '@aztec/circuits.js'; +import { AztecAddress, type FunctionSelector, type Gas, SerializableContractInstance } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; -import { SerializableContractInstance } from '@aztec/types/contracts'; import { getPublicFunctionDebugName } from '../../common/debug_fn_name.js'; import { type WorldStateDB } from '../../public/public_db_sources.js'; diff --git a/yarn-project/simulator/src/avm/opcodes/contract.test.ts b/yarn-project/simulator/src/avm/opcodes/contract.test.ts index 6ce6eefac99..0beaf45e886 100644 --- a/yarn-project/simulator/src/avm/opcodes/contract.test.ts +++ b/yarn-project/simulator/src/avm/opcodes/contract.test.ts @@ -1,6 +1,5 @@ import { randomContractInstanceWithAddress } from '@aztec/circuit-types'; -import { AztecAddress } from '@aztec/circuits.js'; -import { SerializableContractInstance } from '@aztec/types/contracts'; +import { AztecAddress, SerializableContractInstance } from '@aztec/circuits.js'; import { mock } from 'jest-mock-extended'; diff --git a/yarn-project/simulator/src/avm/test_utils.ts b/yarn-project/simulator/src/avm/test_utils.ts index 65862759fb5..9364de143d5 100644 --- a/yarn-project/simulator/src/avm/test_utils.ts +++ b/yarn-project/simulator/src/avm/test_utils.ts @@ -1,5 +1,4 @@ -import { Fr } from '@aztec/circuits.js'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; +import { type ContractInstanceWithAddress, Fr } from '@aztec/circuits.js'; import { type jest } from '@jest/globals'; import { mock } from 'jest-mock-extended'; diff --git a/yarn-project/simulator/src/client/db_oracle.ts b/yarn-project/simulator/src/client/db_oracle.ts index 7dc81d71d0a..6d44cfe39c9 100644 --- a/yarn-project/simulator/src/client/db_oracle.ts +++ b/yarn-project/simulator/src/client/db_oracle.ts @@ -5,11 +5,15 @@ import { type NullifierMembershipWitness, type PublicDataWitness, } from '@aztec/circuit-types'; -import { type CompleteAddress, type Header, type KeyValidationRequest } from '@aztec/circuits.js'; +import { + type CompleteAddress, + type ContractInstance, + type Header, + type KeyValidationRequest, +} from '@aztec/circuits.js'; import { type FunctionArtifact, type FunctionSelector } from '@aztec/foundation/abi'; import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { type Fr } from '@aztec/foundation/fields'; -import { type ContractInstance } from '@aztec/types/contracts'; import { type NoteData } from '../acvm/index.js'; import { type CommitmentsDB } from '../public/db_interfaces.js'; diff --git a/yarn-project/simulator/src/client/view_data_oracle.ts b/yarn-project/simulator/src/client/view_data_oracle.ts index 6a90a3efccf..d4d1f7364e8 100644 --- a/yarn-project/simulator/src/client/view_data_oracle.ts +++ b/yarn-project/simulator/src/client/view_data_oracle.ts @@ -7,12 +7,11 @@ import { type NullifierMembershipWitness, type PublicDataWitness, } from '@aztec/circuit-types'; -import { type Header, type KeyValidationRequest } from '@aztec/circuits.js'; +import { type ContractInstance, type Header, type KeyValidationRequest } from '@aztec/circuits.js'; import { siloNullifier } from '@aztec/circuits.js/hash'; import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log'; -import { type ContractInstance } from '@aztec/types/contracts'; import { type NoteData, TypedOracle } from '../acvm/index.js'; import { type DBOracle } from './db_oracle.js'; diff --git a/yarn-project/simulator/src/public/db_interfaces.ts b/yarn-project/simulator/src/public/db_interfaces.ts index dfa168b66bb..b8d022080cc 100644 --- a/yarn-project/simulator/src/public/db_interfaces.ts +++ b/yarn-project/simulator/src/public/db_interfaces.ts @@ -1,8 +1,11 @@ import { type NullifierMembershipWitness } from '@aztec/circuit-types'; -import { type FunctionSelector, type L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/circuits.js'; +import { + type ContractInstanceWithAddress, + type FunctionSelector, + type L1_TO_L2_MSG_TREE_HEIGHT, +} from '@aztec/circuits.js'; import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { type Fr } from '@aztec/foundation/fields'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { type MessageLoadOracleInputs } from '../acvm/index.js'; diff --git a/yarn-project/simulator/src/public/dual_side_effect_trace.ts b/yarn-project/simulator/src/public/dual_side_effect_trace.ts index 1146feb6e6a..483f0f188ff 100644 --- a/yarn-project/simulator/src/public/dual_side_effect_trace.ts +++ b/yarn-project/simulator/src/public/dual_side_effect_trace.ts @@ -1,6 +1,10 @@ -import { type CombinedConstantData, type Gas, type VMCircuitPublicInputs } from '@aztec/circuits.js'; +import { + type CombinedConstantData, + type ContractInstanceWithAddress, + type Gas, + type VMCircuitPublicInputs, +} from '@aztec/circuits.js'; import { type Fr } from '@aztec/foundation/fields'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { assert } from 'console'; diff --git a/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts b/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts index 950b4411c31..877543e77c8 100644 --- a/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts +++ b/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.test.ts @@ -25,10 +25,10 @@ import { PublicValidationRequestArrayLengths, PublicValidationRequests, ReadRequest, + SerializableContractInstance, TreeLeafReadRequest, } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; -import { SerializableContractInstance } from '@aztec/types/contracts'; import { randomBytes, randomInt } from 'crypto'; diff --git a/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.ts b/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.ts index fb09b3122b7..5b2ec340990 100644 --- a/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.ts +++ b/yarn-project/simulator/src/public/enqueued_call_side_effect_trace.ts @@ -7,6 +7,7 @@ import { AztecAddress, CallContext, type CombinedConstantData, + type ContractInstanceWithAddress, ContractStorageRead, ContractStorageUpdateRequest, EthAddress, @@ -51,7 +52,6 @@ import { makeTuple } from '@aztec/foundation/array'; import { padArrayEnd } from '@aztec/foundation/collection'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { type AvmContractCallResult } from '../avm/avm_contract_call_result.js'; import { type AvmExecutionEnvironment } from '../avm/avm_execution_environment.js'; diff --git a/yarn-project/simulator/src/public/public_db_sources.test.ts b/yarn-project/simulator/src/public/public_db_sources.test.ts index 8ac90faca38..3fa901bb9e4 100644 --- a/yarn-project/simulator/src/public/public_db_sources.test.ts +++ b/yarn-project/simulator/src/public/public_db_sources.test.ts @@ -1,8 +1,7 @@ import { MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/circuit-types'; -import { AztecAddress, Fr, PublicDataTreeLeafPreimage } from '@aztec/circuits.js'; +import { AztecAddress, type ContractDataSource, Fr, PublicDataTreeLeafPreimage } from '@aztec/circuits.js'; import { computePublicDataTreeLeafSlot } from '@aztec/circuits.js/hash'; import { type IndexedTreeLeafPreimage } from '@aztec/foundation/trees'; -import { type ContractDataSource } from '@aztec/types/contracts'; import { type MockProxy, mock } from 'jest-mock-extended'; diff --git a/yarn-project/simulator/src/public/public_db_sources.ts b/yarn-project/simulator/src/public/public_db_sources.ts index 27e7ae4a755..0b3864d2ae7 100644 --- a/yarn-project/simulator/src/public/public_db_sources.ts +++ b/yarn-project/simulator/src/public/public_db_sources.ts @@ -8,8 +8,11 @@ import { import { type PublicDBAccessStats } from '@aztec/circuit-types/stats'; import { type AztecAddress, + type ContractClassPublic, ContractClassRegisteredEvent, + type ContractDataSource, ContractInstanceDeployedEvent, + type ContractInstanceWithAddress, Fr, FunctionSelector, type L1_TO_L2_MSG_TREE_HEIGHT, @@ -27,11 +30,6 @@ import { type PublicContractsDB, type PublicStateDB, } from '@aztec/simulator'; -import { - type ContractClassPublic, - type ContractDataSource, - type ContractInstanceWithAddress, -} from '@aztec/types/contracts'; /** * Implements the PublicContractsDB using a ContractDataSource. diff --git a/yarn-project/simulator/src/public/public_processor.ts b/yarn-project/simulator/src/public/public_processor.ts index 7d12d13c032..1d6523af65a 100644 --- a/yarn-project/simulator/src/public/public_processor.ts +++ b/yarn-project/simulator/src/public/public_processor.ts @@ -11,6 +11,7 @@ import { } from '@aztec/circuit-types'; import { ContractClassRegisteredEvent, + type ContractDataSource, type GlobalVariables, type Header, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, @@ -22,7 +23,6 @@ import { createDebugLogger } from '@aztec/foundation/log'; import { Timer } from '@aztec/foundation/timer'; import { ProtocolContractAddress } from '@aztec/protocol-contracts'; import { Attributes, type TelemetryClient, type Tracer, trackSpan } from '@aztec/telemetry-client'; -import { type ContractDataSource } from '@aztec/types/contracts'; import { type SimulationProvider } from '../providers/index.js'; import { EnqueuedCallsProcessor } from './enqueued_calls_processor.js'; diff --git a/yarn-project/simulator/src/public/side_effect_trace.test.ts b/yarn-project/simulator/src/public/side_effect_trace.test.ts index a0b4f16f709..4afd862e698 100644 --- a/yarn-project/simulator/src/public/side_effect_trace.test.ts +++ b/yarn-project/simulator/src/public/side_effect_trace.test.ts @@ -14,9 +14,9 @@ import { MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, + SerializableContractInstance, } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; -import { SerializableContractInstance } from '@aztec/types/contracts'; import { randomBytes, randomInt } from 'crypto'; diff --git a/yarn-project/simulator/src/public/side_effect_trace.ts b/yarn-project/simulator/src/public/side_effect_trace.ts index 5e0f8d51cf7..f3a47dde6b4 100644 --- a/yarn-project/simulator/src/public/side_effect_trace.ts +++ b/yarn-project/simulator/src/public/side_effect_trace.ts @@ -6,6 +6,7 @@ import { AvmKeyValueHint, AztecAddress, CallContext, + type ContractInstanceWithAddress, ContractStorageRead, ContractStorageUpdateRequest, EthAddress, @@ -30,7 +31,6 @@ import { } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; -import { type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { type AvmContractCallResult } from '../avm/avm_contract_call_result.js'; import { type AvmExecutionEnvironment } from '../avm/avm_execution_environment.js'; diff --git a/yarn-project/txe/src/oracle/txe_oracle.ts b/yarn-project/txe/src/oracle/txe_oracle.ts index 2b73c7cc025..592be1c617b 100644 --- a/yarn-project/txe/src/oracle/txe_oracle.ts +++ b/yarn-project/txe/src/oracle/txe_oracle.ts @@ -13,6 +13,8 @@ import { type CircuitWitnessGenerationStats } from '@aztec/circuit-types/stats'; import { CallContext, CombinedConstantData, + type ContractInstance, + type ContractInstanceWithAddress, Gas, Header, type KeyValidationRequest, @@ -63,7 +65,6 @@ import { witnessMapToFields, } from '@aztec/simulator'; import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; -import { type ContractInstance, type ContractInstanceWithAddress } from '@aztec/types/contracts'; import { MerkleTreeSnapshotOperationsFacade, type MerkleTrees } from '@aztec/world-state'; import { type TXEDatabase } from '../util/txe_database.js'; diff --git a/yarn-project/txe/src/util/txe_public_contract_data_source.ts b/yarn-project/txe/src/util/txe_public_contract_data_source.ts index fda952ae2e7..437bed249cf 100644 --- a/yarn-project/txe/src/util/txe_public_contract_data_source.ts +++ b/yarn-project/txe/src/util/txe_public_contract_data_source.ts @@ -1,12 +1,15 @@ -import { type AztecAddress, Fr, FunctionSelector, PUBLIC_DISPATCH_SELECTOR } from '@aztec/circuits.js'; -import { type ContractArtifact } from '@aztec/foundation/abi'; -import { PrivateFunctionsTree } from '@aztec/pxe'; import { + type AztecAddress, type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress, + Fr, + FunctionSelector, + PUBLIC_DISPATCH_SELECTOR, type PublicFunction, -} from '@aztec/types/contracts'; +} from '@aztec/circuits.js'; +import { type ContractArtifact } from '@aztec/foundation/abi'; +import { PrivateFunctionsTree } from '@aztec/pxe'; import { type TXE } from '../oracle/txe_oracle.js'; diff --git a/yarn-project/txe/src/util/txe_world_state_db.ts b/yarn-project/txe/src/util/txe_world_state_db.ts index 63ef83b9775..f5545c6f8ba 100644 --- a/yarn-project/txe/src/util/txe_world_state_db.ts +++ b/yarn-project/txe/src/util/txe_world_state_db.ts @@ -1,6 +1,7 @@ import { MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/circuit-types'; import { type AztecAddress, + type ContractDataSource, Fr, PUBLIC_DATA_SUBTREE_HEIGHT, PublicDataTreeLeaf, @@ -8,7 +9,6 @@ import { } from '@aztec/circuits.js'; import { computePublicDataTreeLeafSlot } from '@aztec/circuits.js/hash'; import { WorldStateDB } from '@aztec/simulator'; -import { type ContractDataSource } from '@aztec/types/contracts'; export class TXEWorldStateDB extends WorldStateDB { constructor(private merkleDb: MerkleTreeWriteOperations, dataSource: ContractDataSource) { diff --git a/yarn-project/types/src/contracts/contract_instance.ts b/yarn-project/types/src/contracts/contract_instance.ts deleted file mode 100644 index aa12e8aff2e..00000000000 --- a/yarn-project/types/src/contracts/contract_instance.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { Fr } from '@aztec/foundation/fields'; -import { BufferReader, numToUInt8, serializeToBuffer } from '@aztec/foundation/serialize'; -import { type FieldsOf } from '@aztec/foundation/types'; - -const VERSION = 1 as const; - -/** A contract instance is a concrete deployment of a contract class. A contract instance always references a contract class, which dictates what code it executes when called. A contract instance has state (both private and public), as well as an address that acts as its identifier. A contract instance can be called into. */ -export interface ContractInstance { - /** Version identifier. Initially one, bumped for any changes to the contract instance struct. */ - version: typeof VERSION; - /** User-generated pseudorandom value for uniqueness. */ - salt: Fr; - /** Optional deployer address or zero if this was a universal deploy. */ - deployer: AztecAddress; - /** Identifier of the contract class for this instance. */ - contractClassId: Fr; - /** Hash of the selector and arguments to the constructor. */ - initializationHash: Fr; - /** Optional hash of the struct of public keys used for encryption and nullifying by this contract. */ - publicKeysHash: Fr; -} - -export type ContractInstanceWithAddress = ContractInstance & { address: AztecAddress }; - -export class SerializableContractInstance { - public readonly version = VERSION; - public readonly salt: Fr; - public readonly deployer: AztecAddress; - public readonly contractClassId: Fr; - public readonly initializationHash: Fr; - public readonly publicKeysHash: Fr; - - constructor(instance: ContractInstance) { - if (instance.version !== VERSION) { - throw new Error(`Unexpected contract class version ${instance.version}`); - } - this.salt = instance.salt; - this.deployer = instance.deployer; - this.contractClassId = instance.contractClassId; - this.initializationHash = instance.initializationHash; - this.publicKeysHash = instance.publicKeysHash; - } - - public toBuffer() { - return serializeToBuffer( - numToUInt8(this.version), - this.salt, - this.deployer, - this.contractClassId, - this.initializationHash, - this.publicKeysHash, - ); - } - - /** Returns a copy of this object with its address included. */ - withAddress(address: AztecAddress): ContractInstanceWithAddress { - return { ...this, address }; - } - - static fromBuffer(bufferOrReader: Buffer | BufferReader) { - const reader = BufferReader.asReader(bufferOrReader); - return new SerializableContractInstance({ - version: reader.readUInt8() as typeof VERSION, - salt: reader.readObject(Fr), - deployer: reader.readObject(AztecAddress), - contractClassId: reader.readObject(Fr), - initializationHash: reader.readObject(Fr), - publicKeysHash: reader.readObject(Fr), - }); - } - - static random(opts: Partial> = {}) { - return new SerializableContractInstance({ - version: VERSION, - salt: Fr.random(), - deployer: AztecAddress.random(), - contractClassId: Fr.random(), - initializationHash: Fr.random(), - publicKeysHash: Fr.random(), - ...opts, - }); - } - - static empty() { - return new SerializableContractInstance({ - version: VERSION, - salt: Fr.zero(), - deployer: AztecAddress.zero(), - contractClassId: Fr.zero(), - initializationHash: Fr.zero(), - publicKeysHash: Fr.zero(), - }); - } -} diff --git a/yarn-project/types/src/interfaces/index.ts b/yarn-project/types/src/interfaces/index.ts index 1aab588e99b..d1775c443be 100644 --- a/yarn-project/types/src/interfaces/index.ts +++ b/yarn-project/types/src/interfaces/index.ts @@ -1,2 +1 @@ -export * from './node-info.js'; export * from './hasher.js';