Skip to content

Commit

Permalink
fix contract deployment tx parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Geo25rey committed Jul 31, 2024
1 parent 961e21a commit eacccf9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
29 changes: 13 additions & 16 deletions src/services/new/contractEngineV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ export class ContractEngineV2 {
if (proofRequired) {
// validate proof
if (
typeof json !== 'object' ||
json === null ||
typeof json.storage_proof !== 'object' ||
typeof json.storage_proof?.hash !== 'string' ||
typeof json.storage_proof?.signature !== 'object' ||
typeof json.storage_proof?.signature?.sig !=='string' ||
Expand All @@ -199,16 +202,7 @@ export class ContractEngineV2 {
continue;
}
try {
const sigCid = await this.self.ipfs.dag.put(
{
type: 'data-availablity',
cid: json.code,
},
{ onlyHash: true },
);
if (!CID.parse(json.storage_proof.hash).equals(sigCid)) {
continue;
}
const sigCid = CID.parse(json.storage_proof.hash)
members ??= (await this.self.electionManager.getMembersOfBlock(blkHeight))
.map((m) => m.key);
const isValid = await BlsCircuit.deserialize({hash: sigCid.bytes, signature: json.storage_proof.signature}, members)
Expand All @@ -219,13 +213,16 @@ export class ContractEngineV2 {
)
continue
}
await this.self.ipfs.dag.put(
{
type: 'data-availablity',
cid: json.code,
},
{ pin: true },
const {value} = await this.self.ipfs.dag.get(
sigCid
);
if (value?.type !== 'data-availability' || value?.cid !== json.code) {
this.self.logger.info(
`contract storage proof data is invalid for op ${index} tx ${tx.transaction_id}`,
)
continue;
}
await this.self.ipfs.pin.add(sigCid);
} catch (e) {
this.self.logger.error(`failed to verify contract storage proof for op ${index} tx ${tx.transaction_id}: ${e}`)
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/services/new/witness/versionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { TransactionDbStatus } from "../types";


export const VersionConfig = {
index_reset_id: 22,
index_reset_id: 23,

/**
* should only be increased, but it can be decremented when trying a previous block reset
Expand Down

0 comments on commit eacccf9

Please sign in to comment.