Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContractInstanceDeployed implements Serialize twice #11081

Open
TomAFrench opened this issue Jan 6, 2025 · 1 comment
Open

ContractInstanceDeployed implements Serialize twice #11081

TomAFrench opened this issue Jan 6, 2025 · 1 comment
Assignees

Comments

@TomAFrench
Copy link
Member

Noir team is making some changes to tighten up trait resolution in noir-lang/noir#6895 but contract_instance_deployer_contract is throwing errors. This is because it implements Serialize twice.

#[derive(Serialize)]
#[event]
struct ContractInstanceDeployed {
DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE: Field,
address: AztecAddress,
version: u8,
salt: Field,
contract_class_id: ContractClassId,
initialization_hash: Field,
public_keys: PublicKeys,
deployer: AztecAddress,
}
// We need to impl this separately because ts deserializes a point as two fields only.
// We had issues that:
// Notice how the 'is_infinite' field is deserialized as the next point.
// {
// masterNullifierPublicKey: Point {
// x: Fr<0x0000000000000000000000000000000000000000000000000000000000000012>,
// y: Fr<0x0000000000000000000000000000000000000000000000000000000000000034>,
// isInfinite: false,
// kind: 'point'
// },
// masterIncomingViewingPublicKey: Point {
// x: Fr<0x0000000000000000000000000000000000000000000000000000000000000000>,
// y: Fr<0x0000000000000000000000000000000000000000000000000000000000000056>,
// isInfinite: false,
// kind: 'point'
// },
// masterOutgoingViewingPublicKey: Point {
// x: Fr<0x0000000000000000000000000000000000000000000000000000000000000078>,
// y: Fr<0x0000000000000000000000000000000000000000000000000000000000000000>,
// isInfinite: false,
// kind: 'point'
// },
// masterTaggingPublicKey: Point {
// x: Fr<0x0000000000000000000000000000000000000000000000000000000000000910>,
// y: Fr<0x0000000000000000000000000000000000000000000000000000000000001112>,
// isInfinite: false,
// kind: 'point'
// }
impl Serialize<15> for ContractInstanceDeployed {
fn serialize(self) -> [Field; 15] {
[
self.DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE,
self.address.to_field(),
self.version.to_field(),
self.salt,
self.contract_class_id.to_field(),
self.initialization_hash,
self.public_keys.npk_m.serialize()[0],
self.public_keys.npk_m.serialize()[1],
self.public_keys.ivpk_m.serialize()[0],
self.public_keys.ivpk_m.serialize()[1],
self.public_keys.ovpk_m.serialize()[0],
self.public_keys.ovpk_m.serialize()[1],
self.public_keys.tpk_m.serialize()[0],
self.public_keys.tpk_m.serialize()[1],
self.deployer.to_field(),
]
}
}

The #[derive] was added in #10483 but there was a pre-existing custom implementation which serializes to 15 fields rather than 19. I would remove the derived implementation but this results in #[event] erroring out and I don't want to remove the original without flagging it up to the fairies.

cc @sklppy88 as you wrote the original Serialize impl. cc @nventuro

@nventuro nventuro self-assigned this Jan 7, 2025
@nventuro
Copy link
Contributor

nventuro commented Jan 7, 2025

Thanks for reporting this, I'll look into it. We're also in the process of migrating Serialize to use associated constants instead of generics, which will prevent this in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants