Skip to content

Commit

Permalink
Merge pull request #5055 from Algo-devops-service/relbeta3.14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
algojohnlee authored Jan 25, 2023
2 parents afe5b36 + 8dd7feb commit 39ea2c6
Show file tree
Hide file tree
Showing 40 changed files with 1,230 additions and 267 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ jobs:
-c .golangci-warnings.yml \
--issues-exit-code 0 \
--allow-parallel-runners > temp_golangci-lint-cgo.txt
cat temp_golangci-lint-cgo.txt
cat temp_golangci-lint-cgo.txt | reviewdog \
-f=golangci-lint \
Expand All @@ -102,4 +101,4 @@ jobs:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
run: |
curl -X POST --data-urlencode "payload={\"text\": \"Reviewdog failed. ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} \"}" $SLACK_WEBHOOK
if: ${{ failure() && (contains(github.ref_name, 'rel/nightly') || contains(github.ref_name, 'rel/beta') || contains(github.ref_name, 'rel/stable') || contains(github.ref_name, 'master')) }}
if: ${{ failure() && (contains(github.ref_name, 'rel/nightly') || contains(github.ref_name, 'rel/beta') || contains(github.ref_name, 'rel/stable') || contains(github.ref_name, 'master')) }}
4 changes: 0 additions & 4 deletions .golangci-warnings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ linters:
- partitiontest
- structcheck
- varcheck
- unconvert
- unused


linters-settings:
custom:
partitiontest:
Expand Down Expand Up @@ -55,15 +53,13 @@ issues:
- deadcode
- structcheck
- varcheck
- unconvert
- unused
# Add all linters here -- Comment this block out for testing linters
- path: test/linttest/lintissues\.go
linters:
- deadcode
- structcheck
- varcheck
- unconvert
- unused
- path: crypto/secp256k1/secp256_test\.go
linters:
Expand Down
2 changes: 2 additions & 0 deletions agreement/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ import (
"testing"

"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)

// TestSerializableErrorBackwardCompatible ensures Err field of type serializableError can be
// properly decoded from ConsensusVersionView.
// This test is only needed for agreement state serialization switch from reflection to msgp.
func TestSerializableErrorBackwardCompatibility(t *testing.T) {
partitiontest.PartitionTest(t)

encodedEmpty, err := base64.StdEncoding.DecodeString("gqNFcnLAp1ZlcnNpb26jdjEw")
require.NoError(t, err)
Expand Down
1 change: 1 addition & 0 deletions agreement/persistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func TestEmptyMapDeserialization(t *testing.T) {
}

func TestDecodeFailures(t *testing.T) {
partitiontest.PartitionTest(t)
clock := timers.MakeMonotonicClock(time.Date(2015, 1, 2, 5, 6, 7, 8, time.UTC))
ce := clock.Encode()
log := makeServiceLogger(logging.Base())
Expand Down
2 changes: 1 addition & 1 deletion buildnumber.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0
1
1 change: 1 addition & 0 deletions cmd/goal/formatting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func TestNewBoxRef(t *testing.T) {
}

func TestStringsToBoxRefs(t *testing.T) {
partitiontest.PartitionTest(t)
brs := stringsToBoxRefs([]string{"77,str:hello", "55,int:6", "int:88"})
require.EqualValues(t, 77, brs[0].appID)
require.EqualValues(t, 55, brs[1].appID)
Expand Down
20 changes: 13 additions & 7 deletions cmd/tealdbg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [Protocol](#protocol)
- [Transaction and Transaction Group](#transaction-and-transaction-group)
- [Balance records](#balance-records)
- [Indexer Support](#indexer-support)
- [Execution mode](#execution-mode)
- [Chrome DevTools Frontend Features](#chrome-devtools-frontend-features)
- [Configure the Listener](#configure-the-listener)
Expand Down Expand Up @@ -44,7 +45,7 @@ and balance records (see [Setting Debug Context](#setting-debug-context) for det
Remote debugger might be useful for debugging unit tests for TEAL (currently in Golang only) or for hacking **algod** `eval` and breaking on any TEAL evaluation.
The protocol consist of three REST endpoints and one data structure describing the evaluator state.
See `WebDebuggerHook` and `TestWebDebuggerManual` in [go-algorand sources](https://github.com/algorand/go-algorand/tree/master/data/transactions/logic) for more details.
See `WebDebugger` and `TestWebDebuggerManual` in [go-algorand sources](https://github.com/algorand/go-algorand/tree/master/data/transactions/logic) for more details.
### Frontends
Expand Down Expand Up @@ -206,13 +207,18 @@ Refer to the [Chrome DevTools debugging](https://developers.google.com/web/tools

The evaluator accepts a new `Debugger` parameter described as the interface:
```golang
type DebuggerHook interface {
// Debugger is an interface that supports the first version of AVM debuggers.
// It consists of a set of functions called by eval function during AVM program execution.
//
// Deprecated: This interface does not support non-app call or inner transactions. Use EvalTracer
// instead.
type Debugger interface {
// Register is fired on program creation
Register(state *DebugState) error
Register(state *DebugState)
// Update is fired on every step
Update(state *DebugState) error
Update(state *DebugState)
// Complete is called when the program exits
Complete(state *DebugState) error
Complete(state *DebugState)
}
```
If `Debugger` is set the evaluator calls `Register` on creation, `Update` on every step and `Complete` on exit.
Expand Down Expand Up @@ -251,13 +257,13 @@ The core calls `SessionEnded` on `Complete` call.

If one needs to debug TEAL in as much real environment as possible then do

1. Add `WebDebuggerHook` to `data/transactions/logic/eval.go`:
1. Add `WebDebugger` to `data/transactions/logic/eval.go`:
```golang
cx.program = program

// begin new code
debugURL := os.Getenv("TEAL_DEBUGGER_URL")
cx.Debugger = &WebDebuggerHook{URL: debugURL}
cx.Debugger = &WebDebugger{URL: debugURL}
// end new code

if cx.Debugger != nil {
Expand Down
23 changes: 18 additions & 5 deletions cmd/tealdbg/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/logging"
)

// Notification is sent to the client over their websocket connection
Expand Down Expand Up @@ -528,7 +529,7 @@ func (d *Debugger) SaveProgram(
}

// Register setups new session and notifies frontends if any
func (d *Debugger) Register(state *logic.DebugState) error {
func (d *Debugger) Register(state *logic.DebugState) {
sid := state.ExecID
pcOffset := make(map[int]int, len(state.PCOffset))
for _, pco := range state.PCOffset {
Expand Down Expand Up @@ -556,12 +557,17 @@ func (d *Debugger) Register(state *logic.DebugState) error {

// Wait for acknowledgement
<-s.acknowledged

return nil
}

// Update process state update notifications: pauses or continues as needed
func (d *Debugger) Update(state *logic.DebugState) error {
func (d *Debugger) Update(state *logic.DebugState) {
err := d.update(state)
if err != nil {
logging.Base().Errorf("error in Update hook: %s", err.Error())
}
}

func (d *Debugger) update(state *logic.DebugState) error {
sid := state.ExecID
s, err := d.getSession(sid)
if err != nil {
Expand Down Expand Up @@ -596,7 +602,14 @@ func (d *Debugger) Update(state *logic.DebugState) error {
}

// Complete terminates session and notifies frontends if any
func (d *Debugger) Complete(state *logic.DebugState) error {
func (d *Debugger) Complete(state *logic.DebugState) {
err := d.complete(state)
if err != nil {
logging.Base().Errorf("error in Complete hook: %s", err.Error())
}
}

func (d *Debugger) complete(state *logic.DebugState) error {
sid := state.ExecID
s, err := d.getSession(sid)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tealdbg/debugger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestDebuggerSimple(t *testing.T) {
debugger.AddAdapter(da)

ep := logic.NewEvalParams(make([]transactions.SignedTxnWithAD, 1), &proto, nil)
ep.Debugger = debugger
ep.Tracer = logic.MakeEvalTracerDebuggerAdaptor(debugger)
ep.SigLedger = logic.NoHeaderLedger{}

source := `int 0
Expand Down
17 changes: 0 additions & 17 deletions cmd/tealdbg/dryrunRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,6 @@ func ddrFromParams(dp *DebugParams) (ddr v2.DryrunRequest, err error) {
return
}

func convertAccounts(accounts []model.Account) (records []basics.BalanceRecord, err error) {
for _, a := range accounts {
var addr basics.Address
addr, err = basics.UnmarshalChecksumAddress(a.Address)
if err != nil {
return
}
var ad basics.AccountData
ad, err = v2.AccountToAccountData(&a)
if err != nil {
return
}
records = append(records, basics.BalanceRecord{Addr: addr, AccountData: ad})
}
return
}

func balanceRecordsFromDdr(ddr *v2.DryrunRequest) (records []basics.BalanceRecord, err error) {
accounts := make(map[basics.Address]basics.AccountData)
for _, a := range ddr.Accounts {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tealdbg/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func (r *LocalRunner) RunAll() error {
// ep.Debugger = r.debugger
// if ep.Debugger != nil // FALSE
if r.debugger != nil {
ep.Debugger = r.debugger
ep.Tracer = logic.MakeEvalTracerDebuggerAdaptor(r.debugger)
}
}

Expand Down
14 changes: 5 additions & 9 deletions cmd/tealdbg/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/algorand/go-algorand/protocol"
)

// RemoteHookAdapter provides HTTP transport for WebDebuggerHook
// RemoteHookAdapter provides HTTP transport for WebDebugger
type RemoteHookAdapter struct {
debugger *Debugger
}
Expand All @@ -38,7 +38,7 @@ func MakeRemoteHook(debugger *Debugger) *RemoteHookAdapter {
return r
}

// Setup adds HTTP handlers for remote WebDebuggerHook
// Setup adds HTTP handlers for remote WebDebugger
func (rha *RemoteHookAdapter) Setup(router *mux.Router) {
router.HandleFunc("/exec/register", rha.registerHandler).Methods("POST")
router.HandleFunc("/exec/update", rha.updateHandler).Methods("POST")
Expand All @@ -59,11 +59,7 @@ func (rha *RemoteHookAdapter) registerHandler(w http.ResponseWriter, r *http.Req
}

// Register, and wait for user to acknowledge registration
err = rha.debugger.Register(&state)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
rha.debugger.Register(&state)

// Proceed!
w.WriteHeader(http.StatusOK)
Expand All @@ -78,7 +74,7 @@ func (rha *RemoteHookAdapter) updateHandler(w http.ResponseWriter, r *http.Reque
}

// Ask debugger to process and wait to continue
err = rha.debugger.Update(&state)
err = rha.debugger.update(&state)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
Expand All @@ -96,7 +92,7 @@ func (rha *RemoteHookAdapter) completeHandler(w http.ResponseWriter, r *http.Req
}

// Ask debugger to process and wait to continue
err = rha.debugger.Complete(&state)
err = rha.debugger.complete(&state)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
Expand Down
1 change: 1 addition & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ func TestGetNonDefaultConfigValues(t *testing.T) {
}

func TestLocal_TxFiltering(t *testing.T) {
partitiontest.PartitionTest(t)
cfg := GetDefaultLocal()

// ensure the default
Expand Down
20 changes: 9 additions & 11 deletions daemon/algod/api/server/v2/dryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,22 @@ func (ddr *dryrunDebugReceiver) stateToState(state *logic.DebugState) model.Dryr
return st
}

// Register is fired on program creation (DebuggerHook interface)
func (ddr *dryrunDebugReceiver) Register(state *logic.DebugState) error {
// Register is fired on program creation (logic.Debugger interface)
func (ddr *dryrunDebugReceiver) Register(state *logic.DebugState) {
ddr.disassembly = state.Disassembly
ddr.lines = strings.Split(state.Disassembly, "\n")
return nil
}

// Update is fired on every step (DebuggerHook interface)
func (ddr *dryrunDebugReceiver) Update(state *logic.DebugState) error {
// Update is fired on every step (logic.Debugger interface)
func (ddr *dryrunDebugReceiver) Update(state *logic.DebugState) {
st := ddr.stateToState(state)
ddr.history = append(ddr.history, st)
ddr.updateScratch()
return nil
}

// Complete is called when the program exits (DebuggerHook interface)
func (ddr *dryrunDebugReceiver) Complete(state *logic.DebugState) error {
return ddr.Update(state)
// Complete is called when the program exits (logic.Debugger interface)
func (ddr *dryrunDebugReceiver) Complete(state *logic.DebugState) {
ddr.Update(state)
}

type dryrunLedger struct {
Expand Down Expand Up @@ -421,7 +419,7 @@ func doDryrunRequest(dr *DryrunRequest, response *model.DryrunResponse) {
var result model.DryrunTxnResult
if len(stxn.Lsig.Logic) > 0 {
var debug dryrunDebugReceiver
ep.Debugger = &debug
ep.Tracer = logic.MakeEvalTracerDebuggerAdaptor(&debug)
ep.SigLedger = &dl
pass, err := logic.EvalSignature(ti, ep)
var messages []string
Expand Down Expand Up @@ -505,7 +503,7 @@ func doDryrunRequest(dr *DryrunRequest, response *model.DryrunResponse) {
messages[0] = fmt.Sprintf("uploaded state did not include app id %d referenced in txn[%d]", appIdx, ti)
} else {
var debug dryrunDebugReceiver
ep.Debugger = &debug
ep.Tracer = logic.MakeEvalTracerDebuggerAdaptor(&debug)
var program []byte
messages = make([]string, 1)
if stxn.Txn.OnCompletion == transactions.ClearStateOC {
Expand Down
2 changes: 0 additions & 2 deletions daemon/algod/api/server/v2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ var (
errFailedRetrievingLatestBlockHeaderStatus = "failed retrieving latests block header"
errFailedRetrievingSyncRound = "failed retrieving sync round from ledger"
errFailedSettingSyncRound = "failed to set sync round on the ledger"
errSyncModeNotEnabled = "sync mode must be enabled"
errFailedParsingFormatOption = "failed to parse the format option"
errFailedToParseAddress = "failed to parse the address"
errFailedToParseExclude = "failed to parse exclude"
errFailedToParseTransaction = "failed to parse transaction"
errFailedToParseBlock = "failed to parse block"
errFailedToParseCert = "failed to parse cert"
errFailedToParseSourcemap = "failed to parse sourcemap"
errFailedToEncodeResponse = "failed to encode response"
errInternalFailure = "internal failure"
errNoValidTxnSpecified = "no valid transaction ID was specified"
Expand Down
4 changes: 2 additions & 2 deletions data/transactions/logic/assembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ func (ops *OpStream) assemble(text string) error {
if ok {
ops.trace("%3d: %s\t", ops.sourceLine, opstring)
ops.recordSourceLine()
if spec.Modes == modeApp {
if spec.Modes == ModeApp {
ops.HasStatefulOps = true
}
args, returns := spec.Arg.Types, spec.Return.Types
Expand Down Expand Up @@ -2803,7 +2803,7 @@ func disassembleInstrumented(program []byte, labels map[int]string) (text string
return
}
op := opsByOpcode[version][program[dis.pc]]
if op.Modes == modeApp {
if op.Modes == ModeApp {
ds.hasStatefulOps = true
}
if op.Name == "" {
Expand Down
Loading

0 comments on commit 39ea2c6

Please sign in to comment.