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

add pull-funds to autopilot #100

Merged
merged 7 commits into from
Aug 9, 2023
Merged

Conversation

lanzafame
Copy link
Contributor

No description provided.

@lanzafame lanzafame marked this pull request as ready for review July 12, 2023 23:28
Copy link
Contributor

@Schwartz10 Schwartz10 left a comment

Choose a reason for hiding this comment

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

  • Line 100 in agent_autopilot.go - if account == (abigen.Account{}) { - this should be if account.epochsPaid.Cmp(big.NewInt(0)) < 1 (if epochsPaid is 0 then their account is reset)
  • In the pay func in agent_pay.go, the 4th argument is daemon, which seems to just determine if the journal should be closed at the end of the func - why not just close and reopen the journal on each payment instead of passing this argument and determining whether or not the journal should close? Seems like within each cron tick of running the event loop, we should close connections to various things closed to avoid mem leaks?

Good work on this - it's close. Also, lets make sure before we merge this, we adequately test all the payment commands on testnet to make sure things are working how we'd expect

Then we'll get Jim to test it on mainnet to ensure it's working over a few days worth of epochs

@@ -65,19 +71,21 @@ var agentAutopilotCmd = &cobra.Command{
payargs = append(payargs, fmt.Sprintf("%d", amount))
Copy link
Contributor

Choose a reason for hiding this comment

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

Safer to not use string values to pass around a single amount value, and I don't think we have another pay command that ends up using random arguments - you either pass an amount for Principal or Custom or otherwise no amount. Can we simplify this logic to just pass an amount var thats a *big.Int - in the case of to-current, this will just be nil and ignored

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 am going to leave this as is for now and add an issue to resolve this as this is a fairly large change beyond just pull-funds.

cmd/agent_autopilot.go Outdated Show resolved Hide resolved
cmd/agent_autopilot.go Outdated Show resolved Hide resolved
cmd/agent_autopilot.go Outdated Show resolved Hide resolved
@@ -151,6 +168,122 @@ var agentAutopilotCmd = &cobra.Command{
},
}

func paymentDue(frequency float64, chainHeadHeight uint64, epochsPaid *big.Int) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to get a few test cases in here to make sure logic is correct, especially with frequencies less than 1 day

cmd/agent_autopilot.go Outdated Show resolved Hide resolved
cmd/agent_autopilot.go Show resolved Hide resolved
cmd/agent_autopilot.go Outdated Show resolved Hide resolved
cmd/agent_autopilot.go Show resolved Hide resolved
config.toml Show resolved Hide resolved
cmd/agent_autopilot.go Outdated Show resolved Hide resolved
calibnet-config.toml Outdated Show resolved Hide resolved
Also, some extra logging on the transactions, and quoting fixes
for the config files.
@jimpick jimpick changed the base branch from main to wallet-staging August 9, 2023 02:41
@jimpick
Copy link
Collaborator

jimpick commented Aug 9, 2023

I've done some testing against the localnet ... private testing repo is here: https://github.com/glif-confidential/pools-cli/tree/jim/autopilot-testing

I was able to configure it and observe it pull funds when it needed to (with the pull-amount-factor set to 3). I also tried draining all the funds from the miner. If you request to pull more than the available funds from the miner, it will pull the maximum available instead of failing, leaving the miner with zero available funds. This seems like a reasonable behaviour. If users desire a different behaviour, we could implement additional settings.

I'll merge this to the wallet-staging branch, and we can test it together with the new wallet changes before shipping it in the next big release.

@jimpick jimpick merged commit 7c5ae87 into wallet-staging Aug 9, 2023
1 check passed
@jimpick jimpick deleted the feat/autopilot-pull-funds branch August 9, 2023 02:59
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