WIP AI6 - test fail

This commit is contained in:
James Zaki
2023-04-05 16:49:46 +01:00
parent 54227a57b0
commit 50b957ad4f
5 changed files with 72 additions and 18 deletions

View File

@@ -10,6 +10,8 @@ import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.so
import "./interfaces/IWallet.sol";
import "./BLSWallet.sol";
import "hardhat/console.sol";
/**
A non-upgradable gateway used to create BLSWallets and call them with
verified Operations that have been respectively signed.
@@ -50,6 +52,13 @@ contract VerificationGateway
bytes[] results
);
event WalletOperationFailed(
bytes32 indexed walletHash,
address indexed wallet,
uint256 nonce,
bytes returnData
);
event PendingBLSKeySet(
bytes32 previousHash,
uint256[BLS_KEY_LEN] newBLSKey
@@ -317,8 +326,8 @@ contract VerificationGateway
Can be called with a single operation with no actions.
*/
function processBundle(
IWallet.Bundle memory bundle
) external returns (
IWallet.Bundle calldata bundle
) external payable returns (
bool[] memory successes,
bytes[][] memory results
) {
@@ -329,25 +338,65 @@ contract VerificationGateway
successes = new bool[](opLength);
results = new bytes[][](opLength);
for (uint256 i = 0; i<opLength; i++) {
IWallet wallet = getOrCreateWallet(bundle.senderPublicKeys[i]);
// check nonce then perform action
if (bundle.operations[i].nonce == wallet.nonce{gas:20000}()) {
// request wallet perform operation
(
bool success,
bytes[] memory resultSet
) = wallet.performOperation{gas:bundle.operations[i].gas}(bundle.operations[i]);
bytes32 publicKeyHash = keccak256(abi.encodePacked(bundle.senderPublicKeys[i]));
address walletAddress = address(walletFromHash[publicKeyHash]);
// try wallet calls, catching if they throw
try this._processWalletOperation(
bundle.senderPublicKeys[i],
bundle.operations[i]
) returns (
bool success,
bytes[] memory resultSet
) {
walletAddress = address(walletFromHash[publicKeyHash]);
console.log(" vg: pass"); //TODO remove log event without creating errors
successes[i] = success;
results[i] = resultSet;
emit WalletOperationProcessed(
address(wallet),
walletAddress,
bundle.operations[i].nonce,
bundle.operations[i].actions,
successes[i],
results[i]
);
address(0).staticcall(""); //TODO remove this line without creating more errors
}
catch (bytes memory returnData) { //TODO add tests for wallet implementations that throw
console.log(" vg: fail");
successes[i] = false;
results[i] = new bytes[](1);
results[i][0] = returnData;
emit WalletOperationFailed(
publicKeyHash,
walletAddress,
bundle.operations[i].nonce,
returnData
);
}
}
}
/**
Perform wallet related functions that could throw.
@dev Restricted to only be called by this contract, but needs to be public
so that it can be used in a try/catch block.
*/
function _processWalletOperation(
uint256[4] calldata senderPublicKey,
IWallet.Operation calldata operation
) public payable onlyThis returns (
bool success,
bytes[] memory resultSet
)
{
IWallet wallet = getOrCreateWallet(senderPublicKey);
// check nonce then perform action
if (operation.nonce == wallet.nonce{gas:20000}()) {
(success, resultSet) = wallet.performOperation{gas:operation.gas}(operation);
}
}
@@ -462,6 +511,11 @@ contract VerificationGateway
_;
}
modifier onlyThis() {
require(msg.sender == address(this), "VG: not called from VG");
_;
}
function messagePoint(
address walletAddress,
IWallet.Operation memory op

View File

@@ -85,7 +85,7 @@ const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.15",
version: "0.8.19",
settings: {
optimizer: {
enabled: true,

View File

@@ -23,7 +23,7 @@
"@openzeppelin/contracts": "^4.7.3",
"dotenv": "^16.0.3",
"ethers": "^5.7.2",
"hardhat": "^2.12.1"
"hardhat": "^2.13.0"
},
"peerDependencies": {
"ethers": "^5.0.0"

View File

@@ -9,7 +9,7 @@ import { BigNumber, ContractReceipt } from "ethers";
import { parseEther, solidityPack } from "ethers/lib/utils";
import { getOperationResults } from "../clients/src";
describe("WalletActions", async function () {
describe.only("WalletActions", async function () {
if (`${process.env.DEPLOYER_DEPLOYMENT}` === "true") {
console.log("Skipping non-deployer tests.");
return;

View File

@@ -5574,10 +5574,10 @@ hardhat-gas-reporter@^1.0.9:
eth-gas-reporter "^0.2.25"
sha1 "^1.1.1"
hardhat@^2.12.1:
version "2.12.6"
resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.12.6.tgz#ea3c058bbd81850867389d10f76037cfa52a0019"
integrity sha512-0Ent1O5DsPgvaVb5sxEgsQ3bJRt/Ex92tsoO+xjoNH2Qc4bFmhI5/CHVlFikulalxOPjNmw5XQ2vJFuVQFESAA==
hardhat@^2.13.0:
version "2.13.0"
resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.13.0.tgz#d52a0ec9b733a651687e5b1c1b0ee9a11a30f3d0"
integrity sha512-ZlzBOLML1QGlm6JWyVAG8lVTEAoOaVm1in/RU2zoGAnYEoD1Rp4T+ZMvrLNhHaaeS9hfjJ1gJUBfiDr4cx+htQ==
dependencies:
"@ethersproject/abi" "^5.1.2"
"@metamask/eth-sig-util" "^4.0.0"