@@ -42,12 +42,13 @@ type cdtState struct {
4242 globals []basics.TealValue
4343
4444 // mutable program state
45- mu deadlock.Mutex
46- stack []basics.TealValue
47- scratch []basics.TealValue
48- pc atomicInt
49- line atomicInt
50- err atomicString
45+ mu deadlock.Mutex
46+ stack []basics.TealValue
47+ scratch []basics.TealValue
48+ pc atomicInt
49+ line atomicInt
50+ err atomicString
51+ opcodeBudget int
5152 AppState
5253
5354 // debugger states
@@ -58,11 +59,12 @@ type cdtState struct {
5859}
5960
6061type cdtStateUpdate struct {
61- stack []basics.TealValue
62- scratch []basics.TealValue
63- pc int
64- line int
65- err string
62+ stack []basics.TealValue
63+ scratch []basics.TealValue
64+ pc int
65+ line int
66+ err string
67+ opcodeBudget int
6668
6769 AppState
6870}
@@ -74,6 +76,8 @@ const (
7476 addressHint
7577)
7678
79+ const opcodeBudgetFieldIdx = 12
80+
7781var txnFileTypeHints = map [logic.TxnField ]typeHint {
7882 logic .Sender : addressHint ,
7983 logic .Receiver : addressHint ,
@@ -107,6 +111,8 @@ func (s *cdtState) Update(state cdtStateUpdate) {
107111 s .stack = state .stack
108112 s .scratch = state .scratch
109113 s .AppState = state .AppState
114+ // We need to dynamically override opcodeBudget with the proper value each step.
115+ s .globals [opcodeBudgetFieldIdx ].Uint = uint64 (state .opcodeBudget )
110116}
111117
112118const localScopeObjID = "localScopeObjId"
@@ -839,10 +845,6 @@ func makeGlobals(s *cdtState, preview bool) (desc []cdt.RuntimePropertyDescripto
839845 fields := prepareGlobals (s .globals )
840846 desc = make ([]cdt.RuntimePropertyDescriptor , len (fields ))
841847 for i , field := range fields {
842- // We need to dynamically override this field with the proper value each step.
843- if field .Name == "OpcodeBudget" {
844- field .Value = strconv .Itoa (s .opcodeBudget )
845- }
846848 desc [i ] = makePrimitive (field )
847849 }
848850 return
0 commit comments