Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Quick Large Native Asset Transfer #803

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

bh2smith
Copy link
Contributor

@bh2smith bh2smith commented Jan 29, 2022

This bundles together any number of batch transfers by partitioning the transfer file into batchSize.

Note: I let a few proposed transactions from the first run of this script in the team safe Queue

Screenshot 2022-01-29 at 3 50 11 PM

Test Plan

Put these in .env

NETWORK_NAME=rinkeby
FUND_ACCOUNT=0xd9395aeE9141a3Efeb6d16057c8f67fBE296734c   <---- This is our team Rinkeby Safe
TRANSFER_FILE=examples/large-native-transfer-file.csv
PK=<This must be an owner of the Fund Account>

and run

source .env
npx truffle exec scripts/large-native-transfer.js \
    --fundAccount=$FUND_ACCOUNT \
    --transferFile=$TRANSFER_FILE \
    --network=$NETWORK_NAME

There is a command prompt asking if you want to continue (you MUST type y or yes to proceed).

If the safe in question has a signature threshold > 1 you should expect to see these transactions appear in the safe interface:

Screenshot 2022-01-29 at 3 24 57 PM

Executing one will look like this in etherscan (https://rinkeby.etherscan.io/tx/0xb709585cd72b2f44874270cf2ca29b31c4d9aa318b66798240a88a42bd460271)

Screenshot 2022-01-29 at 3 35 39 PM

Real Run

Fill these in your .env file

FUND_ACCOUNT=<TEAM SAFE>
TRANSFER_FILE=<PATH_TO/gchain-transfer-file.csv>
PK=<Proposer Account>
NETWORK_NAME=xdai
BATCH_SIZE=800

Note the block gas limit on xdai is 17M and a native asset transfer takes 21K gas. Factoring in some safe contract gas overhead I estimate that we could probably do 800 per batch (leave room for 189K gas over head). However this would consume an entire block. We may want to go with 700.

Run

npx truffle exec scripts/large-native-transfer.js \
    --fundAccount=$FUND_ACCOUNT \
    --transferFile=$TRANSFER_FILE \
    --network=$NETWORK_NAME \
    --batchSize=700

Visit the Gnosis Safe interface and manually execute 53751 / 700 = 77 proposed batch transfers!

@bh2smith bh2smith requested review from fedgiac and josojo January 29, 2022 15:41
Copy link
Contributor

@fedgiac fedgiac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Context: xDAI distribution to pay for redeeming COW airdrop.) I don't like the approach of creating transactions on the interface because it would be a large overhead to manually sign/execute each transaction from the interface, and would provide no security benefits as we wouldn't really want to check all the created transactions from the interface manually.
Even saying that it takes 10 seconds to sign a transaction with Metamask, with 30k users and 500 batch size it would take 60 transactions, that is 10 minutes of mindlessly signing and executing transaction non-stop before all funds are sent (likely much more if we include lag in the interface, time for transactions to be confirmed onchain, recovering from failed transactions (e.g. sending to contracts that don't accept xDAI payments)).
The funds involved are limited (<4k$), which is why we don't mind too much about verification. To my understanding, we plan to use a fresh safe to sends the funds from because it's cheap to create one on GC and in this way we have less need to check that no transaction breaks the safe. At this point, I think we should make it single owner and have the transaction executed immediately in the script.

I also think it's not great to write this code in this repo, as it's an unmaintained repo with outdated dependencies (e.g., this is likely why the frontend currently complains about "Unexpected Delegate Call", the multisend we use here is too old; also, we can't update it safely without possibly breaking other old features of this repo). It's fine to reuse the code in here, but I think the changes we want to make should not be part of this repo but belong to a new one, or even to a one-off script file. If we believe the tooling in this repo is tightly linked with the features we want to provide (which I don't think so) we could fork it and add the new code to the fork.

@@ -1,2 +1,4 @@
FUND_ACCOUNT=0xd9395aeE9141a3Efeb6d16057c8f67fBE296734c
TRANSFER_FILE=examples/sampleTransferFile.json
NETWORK=rinkeby
BATCH_SIZE=700
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter appears to be unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used below.

const masterSafe = await GnosisSafe.at(argv.fundAccount)

console.log("Preparing transaction data...")
const partition = partitionedTransfers(transfers, argv.batchSize)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used right here @fedgiac!

@@ -1,2 +1,4 @@
FUND_ACCOUNT=0xd9395aeE9141a3Efeb6d16057c8f67fBE296734c
TRANSFER_FILE=examples/sampleTransferFile.json
NETWORK=rinkeby
BATCH_SIZE=700
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used below.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants