Skip to content

Commit

Permalink
fix reallocation error due to changes in SignUp and publishMessage ch…
Browse files Browse the repository at this point in the history
…anges
  • Loading branch information
yuetloo committed Mar 13, 2024
1 parent b7c06f3 commit 1ad99cc
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 172 deletions.
4 changes: 3 additions & 1 deletion docs/tally-verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,6 @@ Also, lack of memory can also cause `core dump`, try to work around it by settin
export NODE_OPTIONS=--max-old-space-size=4096
```

If you notice `Error at message index 0 - failed decryption due to either wrong encryption public key or corrupted ciphertext` while running the tally script, don't worry, it's just a warning. This issue is tracked [here](https://github.com/privacy-scaling-explorations/maci/issues/1134)
If you notice `Error at message index 0 - failed decryption due to either wrong encryption public key or corrupted ciphertext` while running the tally script, don't worry, it's just a warning. This issue is tracked [here](https://github.com/privacy-scaling-explorations/maci/issues/1134)

`Error at message index n - invalid nonce` is also a warning, not an error. This error occurs when users reallocated their contribution.
89 changes: 38 additions & 51 deletions subgraph/abis/MACI.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@
"name": "PreviousPollNotCompleted",
"type": "error"
},
{
"inputs": [],
"name": "SignupTemporaryBlocked",
"type": "error"
},
{
"inputs": [],
"name": "TooManySignups",
Expand All @@ -108,22 +113,16 @@
"type": "uint256"
},
{
"components": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"indexed": false,
"internalType": "struct DomainObjs.PubKey",
"name": "_pubKey",
"type": "tuple"
"indexed": true,
"internalType": "uint256",
"name": "_coordinatorPubKeyX",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "_coordinatorPubKeyY",
"type": "uint256"
},
{
"components": [
Expand Down Expand Up @@ -186,22 +185,16 @@
"type": "uint256"
},
{
"components": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "y",
"type": "uint256"
}
],
"indexed": false,
"internalType": "struct DomainObjs.PubKey",
"name": "_userPubKey",
"type": "tuple"
"indexed": true,
"internalType": "uint256",
"name": "_userPubKeyX",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "_userPubKeyY",
"type": "uint256"
},
{
"indexed": false,
Expand Down Expand Up @@ -649,25 +642,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "numStateLeaves",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
Expand Down Expand Up @@ -884,6 +858,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "subtreesMerged",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tallyFactory",
Expand Down
6 changes: 3 additions & 3 deletions subgraph/config/arbitrum-sepolia.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"network": "arbitrum-sepolia",
"address": "0x9E43d48513FDe2701288bDCEd1057109E592f048",
"clrFundStartBlock": 20200250,
"recipientRegistryStartBlock": 20200250
"address": "0xEd7dD059294dE1B053B2B50Fb6A73a559219F678",
"clrFundStartBlock": 22697290,
"recipientRegistryStartBlock": 22697290
}
80 changes: 28 additions & 52 deletions subgraph/generated/ClrFund/MACI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,21 @@ export class DeployPoll__Params {
return this._event.parameters[0].value.toBigInt();
}

get _pubKey(): DeployPoll_pubKeyStruct {
return changetype<DeployPoll_pubKeyStruct>(
this._event.parameters[1].value.toTuple(),
);
get _coordinatorPubKeyX(): BigInt {
return this._event.parameters[1].value.toBigInt();
}

get _coordinatorPubKeyY(): BigInt {
return this._event.parameters[2].value.toBigInt();
}

get pollAddr(): DeployPollPollAddrStruct {
return changetype<DeployPollPollAddrStruct>(
this._event.parameters[2].value.toTuple(),
this._event.parameters[3].value.toTuple(),
);
}
}

export class DeployPoll_pubKeyStruct extends ethereum.Tuple {
get x(): BigInt {
return this[0].toBigInt();
}

get y(): BigInt {
return this[1].toBigInt();
}
}

export class DeployPollPollAddrStruct extends ethereum.Tuple {
get poll(): Address {
return this[0].toAddress();
Expand Down Expand Up @@ -107,28 +99,20 @@ export class SignUp__Params {
return this._event.parameters[0].value.toBigInt();
}

get _userPubKey(): SignUp_userPubKeyStruct {
return changetype<SignUp_userPubKeyStruct>(
this._event.parameters[1].value.toTuple(),
);
get _userPubKeyX(): BigInt {
return this._event.parameters[1].value.toBigInt();
}

get _voiceCreditBalance(): BigInt {
get _userPubKeyY(): BigInt {
return this._event.parameters[2].value.toBigInt();
}

get _timestamp(): BigInt {
get _voiceCreditBalance(): BigInt {
return this._event.parameters[3].value.toBigInt();
}
}

export class SignUp_userPubKeyStruct extends ethereum.Tuple {
get x(): BigInt {
return this[0].toBigInt();
}

get y(): BigInt {
return this[1].toBigInt();
get _timestamp(): BigInt {
return this._event.parameters[4].value.toBigInt();
}
}

Expand Down Expand Up @@ -663,29 +647,6 @@ export class MACI extends ethereum.SmartContract {
return ethereum.CallResult.fromValue(value[0].toBigInt());
}

numStateLeaves(param0: BigInt): BigInt {
let result = super.call(
"numStateLeaves",
"numStateLeaves(uint256):(uint256)",
[ethereum.Value.fromUnsignedBigInt(param0)],
);

return result[0].toBigInt();
}

try_numStateLeaves(param0: BigInt): ethereum.CallResult<BigInt> {
let result = super.tryCall(
"numStateLeaves",
"numStateLeaves(uint256):(uint256)",
[ethereum.Value.fromUnsignedBigInt(param0)],
);
if (result.reverted) {
return new ethereum.CallResult();
}
let value = result.value;
return ethereum.CallResult.fromValue(value[0].toBigInt());
}

owner(): Address {
let result = super.call("owner", "owner():(address)", []);

Expand Down Expand Up @@ -889,6 +850,21 @@ export class MACI extends ethereum.SmartContract {
return ethereum.CallResult.fromValue(value[0].toAddress());
}

subtreesMerged(): boolean {
let result = super.call("subtreesMerged", "subtreesMerged():(bool)", []);

return result[0].toBoolean();
}

try_subtreesMerged(): ethereum.CallResult<boolean> {
let result = super.tryCall("subtreesMerged", "subtreesMerged():(bool)", []);
if (result.reverted) {
return new ethereum.CallResult();
}
let value = result.value;
return ethereum.CallResult.fromValue(value[0].toBoolean());
}

tallyFactory(): Address {
let result = super.call("tallyFactory", "tallyFactory():(address)", []);

Expand Down
74 changes: 74 additions & 0 deletions subgraph/generated/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,23 @@ export class Message extends Entity {
}
}

get poll(): string | null {
let value = this.get("poll");
if (!value || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toString();
}
}

set poll(value: string | null) {
if (!value) {
this.unset("poll");
} else {
this.set("poll", Value.fromString(<string>value));
}
}

get submittedBy(): Bytes | null {
let value = this.get("submittedBy");
if (!value || value.kind == ValueKind.NULL) {
Expand Down Expand Up @@ -620,6 +637,63 @@ export class PublicKey extends Entity {
}
}

export class Poll extends Entity {
constructor(id: string) {
super();
this.set("id", Value.fromString(id));
}

save(): void {
let id = this.get("id");
assert(id != null, "Cannot save Poll entity without an ID");
if (id) {
assert(
id.kind == ValueKind.STRING,
`Entities of type Poll must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}`,
);
store.set("Poll", id.toString(), this);
}
}

static loadInBlock(id: string): Poll | null {
return changetype<Poll | null>(store.get_in_block("Poll", id));
}

static load(id: string): Poll | null {
return changetype<Poll | null>(store.get("Poll", id));
}

get id(): string {
let value = this.get("id");
if (!value || value.kind == ValueKind.NULL) {
throw new Error("Cannot return null for a required field.");
} else {
return value.toString();
}
}

set id(value: string) {
this.set("id", Value.fromString(value));
}

get fundingRound(): string {
let value = this.get("fundingRound");
if (!value || value.kind == ValueKind.NULL) {
throw new Error("Cannot return null for a required field.");
} else {
return value.toString();
}
}

set fundingRound(value: string) {
this.set("fundingRound", Value.fromString(value));
}

get messages(): MessageLoader {
return new MessageLoader("Poll", this.get("id")!.toString(), "messages");
}
}

export class FundingRound extends Entity {
constructor(id: string) {
super();
Expand Down
Loading

0 comments on commit 1ad99cc

Please sign in to comment.