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

Algod: Simulation run with extra budget per transaction group #5354

Merged
merged 20 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
67 changes: 42 additions & 25 deletions cmd/goal/clerk.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,42 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/data/transactions/verify"
"github.com/algorand/go-algorand/ledger/simulation"
"github.com/algorand/go-algorand/libgoal"
"github.com/algorand/go-algorand/protocol"

"github.com/spf13/cobra"
)

var (
toAddress string
account string
amount uint64
txFilename string
rejectsFilename string
closeToAddress string
noProgramOutput bool
writeSourceMap bool
signProgram bool
programSource string
argB64Strings []string
disassemble bool
verbose bool
progByteFile string
msigParams string
logicSigFile string
timeStamp int64
protoVersion string
rekeyToAddress string
signerAddress string
rawOutput bool
requestFilename string
requestOutFilename string
simulateAllowEmptySignatures bool
simulateAllowMoreLogging bool
toAddress string
account string
amount uint64
txFilename string
rejectsFilename string
closeToAddress string
noProgramOutput bool
writeSourceMap bool
signProgram bool
programSource string
argB64Strings []string
disassemble bool
verbose bool
progByteFile string
msigParams string
logicSigFile string
timeStamp int64
protoVersion string
rekeyToAddress string
signerAddress string
rawOutput bool
requestFilename string
requestOutFilename string

simulateAllowEmptySignatures bool
simulateAllowMoreLogging bool
simulateAllowExtraOpcodeBudget bool
simulateExtraOpcodeBudget uint64
)

func init() {
Expand Down Expand Up @@ -155,6 +159,8 @@ func init() {
simulateCmd.Flags().StringVarP(&outFilename, "result-out", "o", "", "Filename for writing simulation result")
simulateCmd.Flags().BoolVar(&simulateAllowEmptySignatures, "allow-empty-signatures", false, "Allow transactions without signatures to be simulated as if they had correct signatures")
simulateCmd.Flags().BoolVar(&simulateAllowMoreLogging, "allow-more-logging", false, "Lift the limits on log opcode during simulation")
simulateCmd.Flags().BoolVar(&simulateAllowExtraOpcodeBudget, "allow-extra-opcode-budget", false, "Apply max extra opcode budget for apps per transaction group (default 320000) during simulation")
simulateCmd.Flags().Uint64Var(&simulateExtraOpcodeBudget, "extra-opcode-budget", 0, "Apply extra opcode budget for apps per transaction group during simulation")
}

var clerkCmd = &cobra.Command{
Expand Down Expand Up @@ -1240,6 +1246,15 @@ var simulateCmd = &cobra.Command{
reportErrorf("exactly one of --txfile or --request must be provided")
}

allowExtraBudgetProvided := cmd.Flags().Changed("allow-extra-opcode-budget")
extraBudgetProvided := cmd.Flags().Changed("extra-opcode-budget")
if allowExtraBudgetProvided && extraBudgetProvided {
reportErrorf("--allow-extra-opcode-budget and --extra-opcode-budget are mutually exclusive")
}
if allowExtraBudgetProvided {
simulateExtraOpcodeBudget = simulation.MaxExtraOpcodeBudget
}

requestOutProvided := cmd.Flags().Changed("request-only-out")
resultOutProvided := cmd.Flags().Changed("result-out")
if requestOutProvided && resultOutProvided {
Expand All @@ -1261,6 +1276,7 @@ var simulateCmd = &cobra.Command{
},
AllowEmptySignatures: simulateAllowEmptySignatures,
AllowMoreLogging: simulateAllowMoreLogging,
ExtraOpcodeBudget: simulateExtraOpcodeBudget,
}
err := writeFile(requestOutFilename, protocol.EncodeJSON(simulateRequest), 0600)
if err != nil {
Expand All @@ -1283,6 +1299,7 @@ var simulateCmd = &cobra.Command{
},
AllowEmptySignatures: simulateAllowEmptySignatures,
AllowMoreLogging: simulateAllowMoreLogging,
ExtraOpcodeBudget: simulateExtraOpcodeBudget,
}
simulateResponse, responseErr = client.SimulateTransactions(simulateRequest)
} else {
Expand Down
14 changes: 10 additions & 4 deletions daemon/algod/api/algod.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3293,6 +3293,10 @@
"allow-more-logging": {
"description": "Lifts limits on log opcode usage during simulation.",
"type": "boolean"
},
"extra-opcode-budget": {
"description": "Applies extra opcode budget during simulation for each transaction group.",
"type": "integer"
}
}
},
Expand Down Expand Up @@ -3659,13 +3663,15 @@
},
"max-log-calls": {
"description": "The maximum log calls one can make during simulation",
"type": "integer",
"x-algorand-format": "uint64"
"type": "integer"
},
"max-log-size": {
"description": "The maximum byte number to log during simulation",
"type": "integer",
"x-algorand-format": "uint64"
"type": "integer"
},
"extra-opcode-budget": {
"description": "The extra opcode budget added to each transaction group during simulation",
"type": "integer"
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions daemon/algod/api/algod.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,10 @@
"description": "Lifts limits on log opcode usage during simulation.",
"type": "boolean"
},
"extra-opcode-budget": {
"description": "Applies extra opcode budget during simulation for each transaction group.",
"type": "integer"
},
"txn-groups": {
"description": "The transaction groups to simulate.",
"items": {
Expand Down Expand Up @@ -1962,15 +1966,17 @@
"description": "If true, transactions without signatures are allowed and simulated as if they were properly signed.",
"type": "boolean"
},
"extra-opcode-budget": {
"description": "The extra opcode budget added to each transaction group during simulation",
"type": "integer"
},
"max-log-calls": {
"description": "The maximum log calls one can make during simulation",
"type": "integer",
"x-algorand-format": "uint64"
"type": "integer"
},
"max-log-size": {
"description": "The maximum byte number to log during simulation",
"type": "integer",
"x-algorand-format": "uint64"
"type": "integer"
}
},
"type": "object"
Expand Down
74 changes: 37 additions & 37 deletions daemon/algod/api/server/v2/generated/data/routes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 29 additions & 29 deletions daemon/algod/api/server/v2/generated/experimental/routes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions daemon/algod/api/server/v2/generated/model/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading