-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accept multiple signature requests in single transaction #880
Comments
@mattlockyer I agree that we should add this feature. Ideally, it should be incorporated into the contract API: pub fn sign(&mut self, requests: Vec<SignRequest>) -> Result<near_sdk::Promise, Error> I'm unsure whether we can make it synchronous with the current yield/resume design, but an asynchronous version should be feasible, though it may require more effort than it initially seems. |
@volovyks I was just experimenting calling the MPC contract with multiple functionCall actions per transaction. It behaves a bit oddly. Basically Then things get weird. See the following result: https://testnet.nearblocks.io/txns/6Y3sWjnrytHuTXL3ELkQkdbzbnyeBEQzJpZn2q5B4pAj#enhanced If there is a way to process all 3 actions independently and return the array of promise results to the client, that would be ideal. |
@mattlockyer are you making a batch transaction with 3 function_call I will add this issue to our board for better visibility. |
will take a look |
@mattlockyer if you open the enhanced plan of that transaction: https://testnet.nearblocks.io/txns/6Y3sWjnrytHuTXL3ELkQkdbzbnyeBEQzJpZn2q5B4pAj#enhanced
Can you try attaching more gas to it? |
Yes I am, thanks for clarifying. I would be interested in this flow being adopted, since it would open a lot of use cases for handling multiple signatures. Thanks! |
@mattlockyer does it work with increased gas? |
The transaction is eventually successful with gas at 95 Tgas per action (smaller gas amounts like 50 and 75 Tgas failed). But the issue is only 1 signature is returned to the client. |
Yes I see... This is unfortunate as I attached 95 Tgas per action. |
@mattlockyer May I know how you sent the transaction? Any script or commands? So i could reproduce and look into it |
This is a hacky implementation of a batch action call to MPC sign with 3 actions, each slightly modifies the payload. Currently does not work with MPC contract: // finalArgs are just your args to sign call
const finalArgs = args;
const actions = [];
for (let i = 0; i < 3; i++) {
// DEBUGGING copy args and modify payload slightly
const args = JSON.parse(JSON.stringify(finalArgs));
if (i > 0) {
args.request.payload.pop();
args.request.payload.push(i);
}
// import functionCall from nearApi.transactions.functionCall
actions.push(
functionCall(
'sign',
args,
new BN('95000000000000'),
new BN(attachedDeposit),
),
);
}
let res: nearAPI.providers.FinalExecutionOutcome;
try {
// receiverId is the NEAR MPC CONTRACT
// account is a nearApi Account instance
res = await account.signAndSendTransaction({
receiverId: contractId,
actions,
});
} catch (e) {
throw new Error(`error signing ${JSON.stringify(e)}`);
}
console.log('NEAR RESPONSE', res); |
I was mistaken: They both had their promise yields timeout at 201 blocks after sign_helper was called at block, Despite the other 2 calls to @EdsonAlcala and myself looked at the code and wondered the following: In the transaction: https://testnet.nearblocks.io/txns/6Y3sWjnrytHuTXL3ELkQkdbzbnyeBEQzJpZn2q5B4pAj#execution
One of the responses is successful, and at block 176,903,489 The other 2 calls to Question: When the 3 yield promises are created, the Is it possible that the yield promise data ID being written to and read from the register is returning the same value for all 3 calls? This could manifest into a number of different runtime errors, but would essentially leave the other 2 calls to We're unclear on how the yield promise resume logic works, but found this portion of code to be troublesome if executed in the same block, same transaction, same predecessor. mpc/chain-signatures/contract/src/lib.rs Lines 682 to 696 in ecc6fd3
Another, possibly related issue of multiple async calls to |
Checking with near protocol on the workings of yield resume |
Seems like there is nothing special for multiple yield resume in the same block. What happens when you tried attaching more gas? @mattlockyer |
I was only ever able to get the 1/3 signature result in the transaction https://testnet.nearblocks.io/txns/6Y3sWjnrytHuTXL3ELkQkdbzbnyeBEQzJpZn2q5B4pAj#execution I used 95 Tgas per function call. |
I will reproduce it on my end and I'll check our backend and see. Will let you know |
I used near rust cli to send a batch transaction of 3 signs:
I'm getting https://testnet.nearblocks.io/txns/EioG9uiYEe64eyMYR8KcVmcvP7TVGWNTZWHiMAANbZkc#enhanced I have figured out why they fail with time out, and working on a fix. I am not able to reproduce the error you had |
Hey I'm mostly done with the implementation just trying to make an integration test of this use case, which is taking a bit of time. ETA to dev network is next Monday or Tuesday. |
PR in review. Since our team is distributed, might need to take another 2-3 days. |
Hey @mattlockyer , the fix is merged and I just tried a batch tx on dev contract: https://testnet.nearblocks.io/txns/B2vuBu1afDRj1ouVnpPYCGYQd9smSH9a9nc6U68bhcxh# |
Excited to see this go live. Ready to use it! |
I am looking through #909 and I can't see that the following interface was added to the contract: pub fn sign(&mut self, requests: Vec<SignRequest>) -> Result<near_sdk::Promise, Error> Is this part of the plan or can we expect that sending multiple Actions as functionCalls to "sign" method will become the standard approach? |
@bh2smith for now, we will only support batched sign calls if you want to get multiple signatures at once |
MPC system should accept multiple payloads for signing. Obviously we can accept a longer TX time, and pay more, but it seems like most teams working with Bitcoin UTXOs are scratching their heads trying to come up with solutions for how to spend multiple UTXOs.
Each UTXO to spend requires it's own signature. So with the current configuration of MPC we can really only spend from one UTXO.
Possible solutions outside of the MPC accepting multiple payloads would be:
Seeing as how everyone is going to want to do this sooner than later, for Bitcoin UTXOs and other applications, I think it should be a priority.
(requested by @mattlockyer)
The text was updated successfully, but these errors were encountered: