Skip to content
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

feat: batch deposit&withdraw workflow #190

Merged
merged 4 commits into from
Nov 11, 2022
Merged

feat: batch deposit&withdraw workflow #190

merged 4 commits into from
Nov 11, 2022

Conversation

ShookLyngs
Copy link
Contributor

@ShookLyngs ShookLyngs commented Sep 19, 2022

Description

This PR provides a workflow to run on GitHub Actions (triggered manually).
The workflow is about Batch deposit & withdraw, in which we will try to make several rounds of deposit and withdraw for a group of accounts in a short period of time, to see if there will be problems with Godwoken on alphanet_v1.

Changes

  • Account-Faucet (the CLI tool to claim faucet)
    • Refactor account-faucet with clearer commands
    • Add batch relevant commands
  • Light-Godwoken-CLI
    • Provide clearer console messages
    • Add batch deposit&withdraw relevant commands
  • GitHub Workflows
    • Add batch-prepare workflow to claim faucet for derived accounts in batch actions
    • Add batch-deposit-withdraw for long-running testing on alphanet_v1

Details

How to get started:

  1. Run the batch-prepare workflow and it should automatically claim L1&L2 capacity for the derived accounts, and transfer test sUDT from a default issuer account to the derived accounts
  2. Run the batch-deposit-withdraw workflow and it should keep sending batch deposit and withdrawal transactions whenever the Godwoken block number changes (For now the workflow will run for 180 minutes, later we shall make it run for 240 minutes, and start a new workflow every 240 minutes)

Terms:

  • Derived accounts - Derived accounts are generated from the main account we provided, for now the main account is secrets.GODWOKEN_TEST_PRIVATE_KEY

TODO:

batch-prepare

  • Make it claim L1&L2 capacity for the derived accounts
  • Transfer sUDT to L1&L2 of the derived accounts
  • Generate and upload artifacts with action records for the workflow

batch-deposit-withdraw

  • Send a batch of deposit&withdraw requests for each Godwoken blockNumber
  • Generate and upload artifacts with action records for the workflow
  • There are some Uncaught Exceptions keep crashing the Node process, trying to fix it
  • Schedule the workflow to run every 4 hours (because there will be delay for each workflow, it can be hard to make each workflow end before the 6 hour limit)

@ShookLyngs ShookLyngs requested a review from Flouse September 19, 2022 04:52
@Flouse Flouse marked this pull request as draft September 19, 2022 06:07
@Flouse Flouse requested a review from classicalliu September 19, 2022 07:10
Copy link
Collaborator

@Flouse Flouse left a comment

Choose a reason for hiding this comment

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

lgc get-balance 0x***** -n testnet_v1

(node:20215) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
l1-address: ckb1qz0n46hjl3pe2jwtepcvv5ehf9p6l94qvk9addgmarvfsvvrum6j7qgpje4npetk5nt8xxvkwj953ht8e9809yr8qq0h6x88
l1-balance: 0.0
l2-address: 0x966B30e576A4d6731996748B48Dd67C94eF29067
l2-balance: 592231.102233887316314413

I got a wrong l1-address. ckb... is mainnet address.
Not urgent, maybe we can check and fix it later.

scripts/account-faucet/src/commands/batch-accounts-l2.ts Outdated Show resolved Hide resolved
.github/workflows/account-faucet.yml Outdated Show resolved Hide resolved
scripts/light-godwoken-cli/package.json Outdated Show resolved Hide resolved
@ShookLyngs
Copy link
Contributor Author

I got a wrong l1-address. ckb... is mainnet address. Not urgent, maybe we can check and fix it later.

This is a bug in branch ref-custom-tokens of light-godwoken repo due to incorrectly swapping the mainnet and testnet configs. I have fixed it locally, and maybe I will push it to remote tomorrow, along with other fixes.

scripts/account-faucet/src/faucet/address.ts Outdated Show resolved Hide resolved
export function privateKeyToDerivedAccounts(privateKey: HexString, count: number): DerivedAccount[] {
const keys: HexString[] = [privateKey];
for (let i = 0; i < count; i++) {
const newKey = '0x' + keccak256(keys[keys.length - 1]).toString('hex');
Copy link
Contributor

Choose a reason for hiding this comment

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

secp256k1 private key has a max value, not sure the key generated here is always a valid key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, is it enough to set the max count to 64?

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems not related to max try count, a new key is a hash of previous key, so the key looks not incrementing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added TODOs to derived accounts relevant methods, this part of content will be refactored with hd-wallet.

scripts/light-godwoken-cli/package.json Outdated Show resolved Hide resolved
@ShookLyngs
Copy link
Contributor Author

After running in my repo for a long time, the workflow is now stable.
Although the derived account generation part still has a problem, but for now the whole workflow should work, so I thinnk we can fix the derived account generation issue later.

@ShookLyngs ShookLyngs marked this pull request as ready for review November 11, 2022 07:08
@ShookLyngs ShookLyngs changed the title [DRAFT] feat: batch deposit&withdraw workflow feat: batch deposit&withdraw workflow Nov 11, 2022
@Flouse Flouse merged commit b04e943 into develop Nov 11, 2022
@Flouse Flouse deleted the feat-batch-workflows branch November 11, 2022 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants