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

Goal: Introduce new flags to make creating apps without state easier #4946

Closed

Conversation

jasonpaulos
Copy link
Contributor

Summary

With the recent introduction of boxes, now more than ever it makes sense for some apps to not use global/local state.

This PR introduces some new convenience flags for goal app create and goal method --create which makes it easier to create an app without global, local, or neither states. They are:

  • --no-global-state: shorthand for --global-ints=0 and --global-byteslices=0
  • --no-local-state: shorthand for --local-ints=0 and --local-byteslices=0
  • --no-state: shorthand for --no-local-state and --no-global-state

For example, this simplifies usage from goal app create --creator ${ACCOUNT} --approval-prog ${TEALDIR}/boxes.teal --clear-prog ${TEALDIR}/clear.teal --global-byteslices 0 --global-ints 0 --local-byteslices 0 --local-ints 0 to goal app create --creator ${ACCOUNT} --approval-prog ${TEALDIR}/boxes.teal --clear-prog ${TEALDIR}/clear.teal --no-state

Test Plan

New test added in test/scripts/e2e_subs/goal-app-create-state.sh, and I modified some existing e2e tests to take advantage of the new flags where appropriate.

@codecov
Copy link

codecov bot commented Jan 3, 2023

Codecov Report

Merging #4946 (f9b8162) into master (eddf773) will decrease coverage by 0.03%.
The diff coverage is 23.72%.

@@            Coverage Diff             @@
##           master    #4946      +/-   ##
==========================================
- Coverage   53.63%   53.60%   -0.04%     
==========================================
  Files         432      432              
  Lines       54057    54088      +31     
==========================================
- Hits        28996    28992       -4     
- Misses      22812    22849      +37     
+ Partials     2249     2247       -2     
Impacted Files Coverage Δ
cmd/goal/application.go 17.35% <23.72%> (-0.43%) ⬇️
crypto/merkletrie/trie.go 66.42% <0.00%> (-2.19%) ⬇️
crypto/merkletrie/node.go 91.62% <0.00%> (-1.87%) ⬇️
catchup/service.go 69.32% <0.00%> (-0.49%) ⬇️
ledger/acctupdates.go 68.99% <0.00%> (-0.49%) ⬇️
network/wsNetwork.go 64.74% <0.00%> (ø)
ledger/testing/randomAccounts.go 56.88% <0.00%> (+0.61%) ⬆️
catchup/peerSelector.go 100.00% <0.00%> (+1.04%) ⬆️
ledger/roundlru.go 96.22% <0.00%> (+5.66%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jasonpaulos jasonpaulos requested a review from jannotti January 11, 2023 17:39
Copy link
Contributor

@jannotti jannotti left a comment

Choose a reason for hiding this comment

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

I've hated the requirement on these switches for these for some time, so I like the idea.

I assume you considered simply not making them required, thus defaulting to 0? That's what I would have pushed for if we were starting from scratch, but maybe you don't feel we should make that change?

The advantage of that is that it lets you conveniently specify only what you care about, rather than needing to specify that the other stuff is 0 as soon as you want to set any.

I'm putting in approval, because this is fine with me if you want to go this way, but I think I'd prefer making them optional instead, even now. After all, since they were required, it can't break any existing scripts/code.

@jasonpaulos
Copy link
Contributor Author

Making the schema flags optional would certainly solve the same problem as this PR (and maybe be simpler overall).

I guess the question comes down to whether we'd be ok with changing a flag from required to optional. At the moment I don't feel strongly either way.

}
}

func getStateSchema(cmd *cobra.Command) basics.StateSchemas {
Copy link
Contributor

Choose a reason for hiding this comment

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

checks look good

printf '#pragma version 2\nint 1' > "${TEMPDIR}/simple.teal"

# Check goal flags --no-state, --no-local-state, --no-global-state

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe a few extra words here about the methodology

@bbroder-algo
Copy link
Contributor

This is definitely better in every way. But maybe not better than defaulting them to zero?

@jasonpaulos
Copy link
Contributor Author

After more thought I think I agree it would be better to allow the existing arguments to be optional. If I have time in the next few days, I'll modify this PR to do that instead.

@bbroder-algo
Copy link
Contributor

how u doin

@jasonpaulos
Copy link
Contributor Author

Closing this in favor of a future PR which makes the existing arguments optional

@jasonpaulos jasonpaulos deleted the goal-app-create-state branch May 5, 2023 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants