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

"Rent" larger program size #2157

Merged
merged 30 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8edfeee
rent extra program len
shiqizng May 14, 2021
bc0f841
add extra app pages param
shiqizng May 14, 2021
c0fcf11
add extra program len cost
shiqizng May 17, 2021
d410cc6
update allocbound for programs
shiqizng May 17, 2021
68ccac2
update var descriptions
shiqizng May 17, 2021
6213452
refactoring as per reviews
shiqizng May 18, 2021
9f49f00
added unit tests
shiqizng May 18, 2021
57f98e5
added more unit tests
shiqizng May 19, 2021
9201285
added extra-page option to goal and tests
shiqizng May 20, 2021
cd9b54e
Merge remote-tracking branch 'upstream/master' into feature/largerProg
shiqizng May 20, 2021
a2d7e9b
error fix
shiqizng May 21, 2021
3dccdad
Merge branch 'master' into feature/largerProg
shiqizng May 21, 2021
8b049ce
Merge remote-tracking branch 'upstream/master' into feature/largerProg
shiqizng May 21, 2021
8a0ab36
fixed msgp encoding problems
shiqizng May 21, 2021
f7d9763
fix make buildsrc failure
shiqizng May 21, 2021
6d3e2bf
expose extra pages in teal
shiqizng May 21, 2021
3ba9e20
update test
shiqizng May 21, 2021
a0ff16c
test fix
shiqizng May 21, 2021
e62cb84
revert go.sum changes
shiqizng May 24, 2021
2ee1deb
Merge remote-tracking branch 'upstream/master' into feature/largerProg
shiqizng May 25, 2021
f96aaa6
changes as per requested
shiqizng May 25, 2021
71f4732
bug fix
shiqizng May 25, 2021
e19d53d
Merge remote-tracking branch 'upstream/master' into feature/largerProg
shiqizng May 26, 2021
9fcad69
add an expect test
shiqizng May 26, 2021
e4810ab
update formatting
shiqizng May 27, 2021
20d4ecf
test large app program
shiqizng May 27, 2021
8d3d340
minor refactoring
shiqizng May 27, 2021
0b60ee8
add a test for teal v4
shiqizng May 27, 2021
3bd58f1
reorder lines
shiqizng May 27, 2021
ba0fef9
reorder lines
shiqizng May 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/goal/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ var (
approvalProgRawFile string
clearProgRawFile string

extraPages uint32

createOnCompletion string

localSchemaUints uint64
Expand Down Expand Up @@ -98,6 +100,7 @@ func init() {
createAppCmd.Flags().Uint64Var(&localSchemaByteSlices, "local-byteslices", 0, "Maximum number of byte slices that may be stored in local (per-account) key/value stores for this app. Immutable.")
createAppCmd.Flags().StringVar(&appCreator, "creator", "", "Account to create the application")
createAppCmd.Flags().StringVar(&createOnCompletion, "on-completion", "NoOp", "OnCompletion action for application transaction")
createAppCmd.Flags().Uint32Var(&extraPages, "extra-pages", 0, "Additional program space for supporting larger TEAL assembly program. A maximum of 3 extra pages is allowed. A page is 1024 bytes.")

callAppCmd.Flags().StringVarP(&account, "from", "f", "", "Account to call app from")
optInAppCmd.Flags().StringVarP(&account, "from", "f", "", "Account to opt in")
Expand Down Expand Up @@ -355,6 +358,7 @@ var createAppCmd = &cobra.Command{
Long: `Issue a transaction that creates an application`,
Args: validateNoPosArgsFn,
Run: func(cmd *cobra.Command, _ []string) {

dataDir := ensureSingleDataDir()
client := ensureFullClient(dataDir)

Expand All @@ -379,7 +383,7 @@ var createAppCmd = &cobra.Command{
reportWarnf("'--on-completion %s' may be ill-formed for 'goal app create'", createOnCompletion)
}

tx, err := client.MakeUnsignedAppCreateTx(onCompletion, approvalProg, clearProg, globalSchema, localSchema, appArgs, appAccounts, foreignApps, foreignAssets)
tx, err := client.MakeUnsignedAppCreateTx(onCompletion, approvalProg, clearProg, globalSchema, localSchema, appArgs, appAccounts, foreignApps, foreignAssets, extraPages)
if err != nil {
reportErrorf("Cannot create application txn: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/goal/clerk.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,8 @@ func assembleFile(fname string) (program []byte) {
}
_, params := getProto(protoVersion)
if ops.HasStatefulOps {
if len(ops.Program) > params.MaxAppProgramLen {
reportErrorf(tealAppSize, fname, len(ops.Program), params.MaxAppProgramLen)
if len(ops.Program) > config.MaxAvailableAppProgramLen {
reportErrorf(tealAppSize, fname, len(ops.Program), config.MaxAvailableAppProgramLen)
}
} else {
if uint64(len(ops.Program)) > params.LogicSigMaxSize {
Expand Down
2 changes: 1 addition & 1 deletion cmd/goal/interact.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ var appExecuteCmd = &cobra.Command{
localSchema = header.Query.Local.ToStateSchema()
globalSchema = header.Query.Global.ToStateSchema()
}
tx, err := client.MakeUnsignedApplicationCallTx(appIdx, appArgs, appAccounts, foreignApps, foreignAssets, onCompletion, approvalProg, clearProg, globalSchema, localSchema)
tx, err := client.MakeUnsignedApplicationCallTx(appIdx, appArgs, appAccounts, foreignApps, foreignAssets, onCompletion, approvalProg, clearProg, globalSchema, localSchema, 0)
if err != nil {
reportErrorf("Cannot create application txn: %v", err)
}
Expand Down
17 changes: 17 additions & 0 deletions config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ type ConsensusParams struct {
// program in bytes
MaxAppProgramLen int

// extra length for application program in pages. A page is MaxAppProgramLen bytes
MaxExtraAppProgramPages int

// maximum number of accounts in the ApplicationCall Accounts field.
// this determines, in part, the maximum number of balance records
// accessed by a single transaction
Expand Down Expand Up @@ -419,6 +422,14 @@ var MaxAppProgramLen int
// used for decoding purposes.
var MaxBytesKeyValueLen int

// MaxExtraAppProgramLen is the maximum extra app program length supported by any
// of the consensus protocols. used for decoding purposes.
var MaxExtraAppProgramLen int

// MaxAvailableAppProgramLen is the largest supported app program size include the extra pages
//supported supported by any of the consensus protocols. used for decoding purposes.
var MaxAvailableAppProgramLen int

func checkSetMax(value int, curMax *int) {
if value > *curMax {
*curMax = value
Expand Down Expand Up @@ -448,6 +459,9 @@ func checkSetAllocBounds(p ConsensusParams) {
// MaxBytesKeyValueLen is max of MaxAppKeyLen and MaxAppBytesValueLen
checkSetMax(p.MaxAppKeyLen, &MaxBytesKeyValueLen)
checkSetMax(p.MaxAppBytesValueLen, &MaxBytesKeyValueLen)
checkSetMax(p.MaxExtraAppProgramPages, &MaxExtraAppProgramLen)
// MaxAvailableAppProgramLen is the max of supported app program size
MaxAvailableAppProgramLen = MaxAppProgramLen * (1 + MaxExtraAppProgramLen)
}

// SaveConfigurableConsensus saves the configurable protocols file to the provided data directory.
Expand Down Expand Up @@ -916,6 +930,9 @@ func initConsensusProtocols() {

vFuture.EnableKeyregCoherencyCheck = true

// Enable support for larger app program size
vFuture.MaxExtraAppProgramPages = 3

// enable the InitialRewardsRateCalculation fix
vFuture.InitialRewardsRateCalculation = true
// Enable transaction Merkle tree.
Expand Down
Loading