Skip to content
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
1 change: 1 addition & 0 deletions cmd/goal/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ var infoAppCmd = &cobra.Command{
epp := params.ExtraProgramPages

fmt.Printf("Application ID: %d\n", appIdx)
fmt.Printf("Application account: %v\n", basics.AppIndex(appIdx).Address())
fmt.Printf("Creator: %v\n", params.Creator)
fmt.Printf("Approval hash: %v\n", basics.Address(logic.HashProgram(params.ApprovalProgram)))
fmt.Printf("Clear hash: %v\n", basics.Address(logic.HashProgram(params.ClearStateProgram)))
Expand Down
6 changes: 4 additions & 2 deletions daemon/algod/api/algod.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,8 @@
"logs": {
"type": "array",
"items": {
"type": "string"
"type": "string",
"format": "byte"
}
},
"cost": {
Expand Down Expand Up @@ -1983,7 +1984,8 @@
"description": "\\[lg\\] Logs for the application being executed by this transaction.",
"type": "array",
"items": {
"type": "string"
"type": "string",
"format": "byte"
}
},
"inner-txns": {
Expand Down
4 changes: 4 additions & 0 deletions daemon/algod/api/algod.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,8 @@
},
"logs": {
"items": {
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
},
"type": "array"
Expand Down Expand Up @@ -1315,6 +1317,8 @@
"logs": {
"description": "\\[lg\\] Logs for the application being executed by this transaction.",
"items": {
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
},
"type": "array"
Expand Down
8 changes: 4 additions & 4 deletions daemon/algod/api/server/v2/dryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,15 +604,15 @@ func StateDeltaToStateDelta(sd basics.StateDelta) *generated.StateDelta {
}

// DeltaLogToLog base64 encode the logs
func DeltaLogToLog(logs []string) (*[]string, error) {
func DeltaLogToLog(logs []string) (*[][]byte, error) {
if len(logs) == 0 {
return nil, nil
}
encodedLogs := make([]string, len(logs))
logsAsBytes := make([][]byte, len(logs))
for i, log := range logs {
encodedLogs[i] = base64.StdEncoding.EncodeToString([]byte(log))
logsAsBytes[i] = []byte(log)
}
return &encodedLogs, nil
return &logsAsBytes, nil
}

// MergeAppParams merges values, existing in "base" take priority over new in "update"
Expand Down
2 changes: 1 addition & 1 deletion daemon/algod/api/server/v2/dryrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ return
logs := *response.Txns[0].Logs
assert.Equal(t, 32, len(logs))
for i, m := range logs {
assert.Equal(t, base64.StdEncoding.EncodeToString([]byte(string(rune('B'+i)))), m)
assert.Equal(t, []byte(string(rune('B'+i))), m)
}
encoded := string(protocol.EncodeJSON(response.Txns[0]))
assert.Contains(t, encoded, "logs")
Expand Down
259 changes: 130 additions & 129 deletions daemon/algod/api/server/v2/generated/private/routes.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions daemon/algod/api/server/v2/generated/private/types.go

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

330 changes: 165 additions & 165 deletions daemon/algod/api/server/v2/generated/routes.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions daemon/algod/api/server/v2/generated/types.go

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

2 changes: 1 addition & 1 deletion daemon/algod/api/server/v2/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ type preEncodedTxInfo struct {
ReceiverRewards *uint64 `codec:"receiver-rewards,omitempty"`
SenderRewards *uint64 `codec:"sender-rewards,omitempty"`
Txn transactions.SignedTxn `codec:"txn"`
Logs *[]string `codec:"logs,omitempty"`
Logs *[][]byte `codec:"logs,omitempty"`
Inners *[]preEncodedTxInfo `codec:"inner-txns,omitempty"`
}

Expand Down
39 changes: 39 additions & 0 deletions daemon/algod/api/server/v2/test/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ import (
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/node"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/execpool"
"github.com/algorand/go-codec/codec"
)

func setupTestForMethodGet(t *testing.T) (v2.Handlers, echo.Context, *httptest.ResponseRecorder, []account.Root, []transactions.SignedTxn, func()) {
Expand Down Expand Up @@ -316,6 +318,43 @@ func getPendingTransactionsTest(t *testing.T, format string, max uint64, expecte
}
}

func TestPendingTransactionLogsEncoding(t *testing.T) {
partitiontest.PartitionTest(t)

response := generated.PendingTransactionResponse{
Logs: &[][]byte{
{},
[]byte(string("a")),
[]byte(string("test")),
{0},
{0, 1, 2},
},
}

// log messages should be base64 encoded
expected := `{
"logs": [
"",
"YQ==",
"dGVzdA==",
"AA==",
"AAEC"
],
"pool-error": "",
"txn": null
}`

for _, handle := range []codec.Handle{protocol.JSONHandle, protocol.JSONStrictHandle} {
var output []byte
enc := codec.NewEncoderBytes(&output, handle)

err := enc.Encode(response)
require.NoError(t, err)

require.Equal(t, expected, string(output))
}
}

func TestPendingTransactions(t *testing.T) {
t.Parallel()

Expand Down
8 changes: 4 additions & 4 deletions daemon/algod/api/server/v2/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ func convertToDeltas(txn node.TxnWithStatus) (*[]generated.AccountStateDelta, *g
return localStateDelta, stateDeltaToStateDelta(txn.ApplyData.EvalDelta.GlobalDelta)
}

func convertLogs(txn node.TxnWithStatus) *[]string {
var logItems *[]string
func convertLogs(txn node.TxnWithStatus) *[][]byte {
var logItems *[][]byte
if len(txn.ApplyData.EvalDelta.Logs) > 0 {
l := make([]string, len(txn.ApplyData.EvalDelta.Logs))
l := make([][]byte, len(txn.ApplyData.EvalDelta.Logs))

for i, log := range txn.ApplyData.EvalDelta.Logs {
l[i] = base64.StdEncoding.EncodeToString([]byte(log))
l[i] = []byte(log)
}

logItems = &l
Expand Down
5 changes: 2 additions & 3 deletions test/e2e-go/restAPI/restClient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package restapi

import (
"context"
"encoding/base64"
"errors"
"flag"
"math"
Expand Down Expand Up @@ -990,7 +989,7 @@ return
a.NotNil(txn.Logs)
a.Equal(32, len(*txn.Logs))
for i, l := range *txn.Logs {
assert.Equal(t, base64.StdEncoding.EncodeToString([]byte(string(rune('B'+i)))), l)
assert.Equal(t, []byte(string(rune('B'+i))), l)
}

//check non-create app call
Expand Down Expand Up @@ -1027,7 +1026,7 @@ return
a.NotNil(txn.Logs)
a.Equal(32, len(*txn.Logs))
for i, l := range *txn.Logs {
assert.Equal(t, base64.StdEncoding.EncodeToString([]byte(string(rune('B'+i)))), l)
assert.Equal(t, []byte(string(rune('B'+i))), l)
}

}