[General] Sending type 113 transactions is failing in foundry #501
-
EnvironmentTestnet Provide a brief description of the functionality you're trying to implement.I am working on creating some sample native account abstraction accounts in foundry to compare the EVM's edition against zkSync's, and I'm running into an issue. The error I'm getting looks like such:
It's a bit cryptic, function testZkNonOwnerCanExecuteCommand() public {
// Arrange
address dest = address(mockERC20);
uint256 value = 0;
bytes memory func = abi.encodeWithSelector(MockERC20.mint.selector);
Transaction memory transaction = _getUnsignedTransaction(user, ZKSYNC_AA_TX_TYPE, dest, value, func);
transaction = _signTransaction(transaction, userKey);
// Act
vm.prank(randomUser);
minimalAccount.executeTransactionFromOutside(transaction);
// Assert
assertEq(mockERC20.balanceOf(address(minimalAccount)), mockERC20.AMOUNT());
}
function _getUnsignedTransaction(
address from,
uint8 transactionType,
address to,
uint256 value,
bytes memory data
)
internal
pure
returns (Transaction memory)
{
bytes32[] memory emptyArray = new bytes32[](0);
return Transaction({
txType: transactionType,
from: uint256(uint160(from)),
to: uint256(uint160(to)),
gasLimit: 1 << 24,
gasPerPubdataByteLimit: 1 << 24,
maxFeePerGas: 1 << 24,
maxPriorityFeePerGas: 1 << 24,
paymaster: 0,
nonce: 0, // hard coded for 0 for now
value: value,
reserved: [uint256(0), uint256(0), uint256(0), uint256(0)],
data: data,
signature: hex"",
factoryDeps: emptyArray,
paymasterInput: hex"",
reservedDynamic: hex""
});
}
function _signTransaction(
Transaction memory transaction,
uint256 privateKey
)
public
view
returns (Transaction memory)
{
// This method returns the hash of the struct WITHOUT the signature.
bytes32 unsignedTransactionHash = MemoryTransactionHelper.encodeHash(transaction);
// I have no idea if this is correct to do this
bytes32 digest = unsignedTransactionHash.toEthSignedMessageHash();
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
Transaction memory signedTransaction = transaction;
signedTransaction.signature = abi.encodePacked(r, s, v); // Note the order!
return signedTransaction;
} I know this is a bit of a "debug me" question, but it would seem this should work? And if not, I'd get a revert error from the zkSync contracts? I'm running the test like so: forge test --zksync --via-ir --mt testZkNonOwnerCanExecuteCommand What is the specific issue or error you're encountering?see above Can you share the error messages or logs you're receiving, if any?see above Have you made any recent changes to the contract before encountering this issue?see above Are there any external libraries or contracts that your contract interacts with?see above Can you provide the relevant portions of your contract code where the issue is occurring?see above Have you tried to isolate the problem, and if so, what were the results?see above What steps have you already taken to try to resolve the issue?see above Repo Link (Optional)No response Additional DetailsNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@PatrickAlphaC thanks for posting! I will need to investigate this but one thing that will be required if you haven't included it is to make use of the |
Beta Was this translation helpful? Give feedback.
@PatrickAlphaC thanks for posting!
I will need to investigate this but one thing that will be required if you haven't included it is to make use of the
is-system
flag either in the command line or included in thefoundry.toml
file.