Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions clients/contracts/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ export class BridgeContract extends DelphinusContract {
return this.getWeb3Contract().methods.addToken(tokenid).send();
}

private _verify(calldata: number[], verifydata: BN[], vid: number, rid: BN) {
private _verify(calldata: number[], verifydata: BN[], rid: BN) {
const tx = this.getWeb3Contract().methods.verify(
calldata,
verifydata,
vid,
rid
);
return tx.send();
Expand All @@ -98,13 +97,13 @@ export class BridgeContract extends DelphinusContract {
.send();
}

verify(calldata: number[], verifydata: BN[], vid: number, rid: BN) {
verify(calldata: number[], verifydata: BN[], rid: BN) {
const pbinder = new PromiseBinder();

return pbinder.return(async () => {
return await pbinder.bind(
"Verify",
this._verify(calldata, verifydata, vid, rid)
this._verify(calldata, verifydata, rid)
);
});
}
Expand Down
12 changes: 5 additions & 7 deletions contracts/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contract Bridge is DelphinusBridge {
mapping(uint256 => bool) private hasSideEffiect;
uint256 merkle_root;
uint256 rid;
uint256 verifierID;
uint16 verifierID;

constructor(uint32 chain_id) {
_bridge_info.chain_id = chain_id;
Expand Down Expand Up @@ -105,9 +105,9 @@ contract Bridge is DelphinusBridge {
function addVerifier(address vaddr) public returns (uint256) {
ensure_admin();
uint256 cursor = verifiers.length;
verifierID = verifiers.length;
require(verifiers.length < 255, "Verifier index out of bound");
require(verifiers.length < 65535, "Verifier index out of bound");
verifiers.push(DelphinusVerifier(vaddr));
verifierID = uint16(verifiers.length - 1);
return cursor;
}

Expand All @@ -116,7 +116,7 @@ contract Bridge is DelphinusBridge {
return transactions[tid];
}

function _get_verifier(uint8 vid) private view returns (DelphinusVerifier) {
function _get_verifier(uint16 vid) private view returns (DelphinusVerifier) {
require(verifiers.length > vid, "Verifier index out of bound");
return verifiers[vid];
}
Expand Down Expand Up @@ -182,7 +182,6 @@ contract Bridge is DelphinusBridge {
function verify(
bytes calldata tx_data,
uint256[] calldata verify_data, // [8]: old root, [9]: new root, [10]: sha_low, [11]: sha_high
uint8 _vid,
uint256 _rid
) public {
require(rid == _rid, "Verify: Unexpected Request Id");
Expand All @@ -202,8 +201,7 @@ contract Bridge is DelphinusBridge {
merkle_root == verify_data[10],
"Inconstant: Merkle root dismatch"
);

DelphinusVerifier verifier = _get_verifier(_vid);
DelphinusVerifier verifier = _get_verifier(verifierID);
bool v = verifier.verifyDelphinusTx(verify_data);
require(v == true, "ZKVerify: zksnark check failed");

Expand Down
1 change: 0 additions & 1 deletion contracts/DelphinusBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ interface DelphinusBridge {
function verify(
bytes calldata tx_data,
uint256[] calldata verify_data, // [8]: old root, [9]: new root, [10]: sha_low, [11]: sha_high
uint8 _vid,
uint256 _rid
) external;
}
2 changes: 1 addition & 1 deletion contracts/MKT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ struct BridgeInfo {
address owner;
uint256 merkle_root;
uint256 rid;
uint256 verifierID;
uint16 verifierID;
}