Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ian/max-message-size
Browse files Browse the repository at this point in the history
  • Loading branch information
iansuvak committed Jun 20, 2023
2 parents 74ce8f1 + ae02370 commit 1e57b2b
Show file tree
Hide file tree
Showing 56 changed files with 1,255 additions and 1,080 deletions.
14 changes: 6 additions & 8 deletions cmd/goal/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,17 @@ type boxRef struct {
// newBoxRef parses a command-line box ref, which is an optional appId, a comma,
// and then the same format as an app call arg.
func newBoxRef(arg string) boxRef {
parts := strings.SplitN(arg, ":", 2)
if len(parts) != 2 {
encoding, value, found := strings.Cut(arg, ":")
if !found {
reportErrorf("box refs should be of the form '[<app>,]encoding:value'")
}
encoding := parts[0] // tentative, may be <app>,<encoding>
value := parts[1]
parts = strings.SplitN(encoding, ",", 2)
appID := uint64(0)
if len(parts) == 2 {

if appStr, enc, found := strings.Cut(encoding, ","); found {
// There was a comma in the part before the ":"
encoding = parts[1]
encoding = enc
var err error
appID, err = strconv.ParseUint(parts[0], 10, 64)
appID, err = strconv.ParseUint(appStr, 10, 64)
if err != nil {
reportErrorf("Could not parse app id in box ref: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/netgoal/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ func runBuildNetwork() error {
return fmt.Errorf("error loading Build Config file: %v", err)
}
for _, kev := range miscStringStringTokens {
ab := strings.SplitN(kev, "=", 2)
buildConfig.MiscStringString = append(buildConfig.MiscStringString, "{{"+ab[0]+"}}", ab[1])
k, v, _ := strings.Cut(kev, "=")
buildConfig.MiscStringString = append(buildConfig.MiscStringString, "{{"+k+"}}", v)
}

networkTemplateFile := resolveFile(r.NetworkFile, templateBaseDir)
Expand Down
6 changes: 3 additions & 3 deletions daemon/algod/api/server/lib/middlewares/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ func (auth *AuthMiddleware) handler(next echo.HandlerFunc) echo.HandlerFunc {
providedToken := []byte(ctx.Request().Header.Get(auth.header))
if len(providedToken) == 0 {
// Accept tokens provided in a bearer token format.
authentication := strings.SplitN(ctx.Request().Header.Get("Authorization"), " ", 2)
if len(authentication) == 2 && strings.EqualFold("Bearer", authentication[0]) {
providedToken = []byte(authentication[1])
bearer, token, found := strings.Cut(ctx.Request().Header.Get("Authorization"), " ")
if found && strings.EqualFold("Bearer", bearer) {
providedToken = []byte(token)
}
}

Expand Down
7 changes: 2 additions & 5 deletions daemon/kmd/session/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,12 @@ func validateHandleSecret(handleSecret []byte) error {
}

func splitHandle(walletHandle []byte) ([]byte, []byte, error) {
split := bytes.SplitN(walletHandle, wHandleTokenSplitChar, 2)
handleID, handleSecret, found := bytes.Cut(walletHandle, wHandleTokenSplitChar)

if len(split) != 2 {
if !found {
return nil, nil, fmt.Errorf("wrong number of token parts")
}

handleID := split[0]
handleSecret := split[1]

err := validateHandleID(handleID)
if err != nil {
return nil, nil, err
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/DataDog/zstd v1.5.2
github.com/algorand/avm-abi v0.2.0
github.com/algorand/falcon v0.1.0
github.com/algorand/go-codec/codec v1.1.9
github.com/algorand/go-codec/codec v1.1.10
github.com/algorand/go-deadlock v0.2.2
github.com/algorand/go-sumhash v0.1.0
github.com/algorand/graphtrace v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ github.com/algorand/avm-abi v0.2.0 h1:bkjsG+BOEcxUcnGSALLosmltE0JZdg+ZisXKx0UDX2
github.com/algorand/avm-abi v0.2.0/go.mod h1:+CgwM46dithy850bpTeHh9MC99zpn2Snirb3QTl2O/g=
github.com/algorand/falcon v0.1.0 h1:xl832kfZ7hHG6B4p90DQynjfKFGbIUgUOnsRiMZXfAo=
github.com/algorand/falcon v0.1.0/go.mod h1:OkQyHlGvS0kLNcIWbC21/uQcnbfwSOQm+wiqWwBG9pQ=
github.com/algorand/go-codec/codec v1.1.9 h1:el4HFSPZhP+YCgOZxeFGB/BqlNkaUIs55xcALulUTCM=
github.com/algorand/go-codec/codec v1.1.9/go.mod h1:YkEx5nmr/zuCeaDYOIhlDg92Lxju8tj2d2NrYqP7g7k=
github.com/algorand/go-codec/codec v1.1.10 h1:zmWYU1cp64jQVTOG8Tw8wa+k0VfwgXIPbnDfiVa+5QA=
github.com/algorand/go-codec/codec v1.1.10/go.mod h1:YkEx5nmr/zuCeaDYOIhlDg92Lxju8tj2d2NrYqP7g7k=
github.com/algorand/go-deadlock v0.2.2 h1:L7AKATSUCzoeVuOgpTipfCEjdUu5ECmlje8R7lP9DOY=
github.com/algorand/go-deadlock v0.2.2/go.mod h1:Hat1OXKqKNUcN/iv74FjGhF4hsOE2l7gOgQ9ZVIq6Fk=
github.com/algorand/go-sumhash v0.1.0 h1:b/QRhyLuF//vOcicBIxBXYW8bERNoeLxieht/dUYpVg=
Expand Down
20 changes: 14 additions & 6 deletions ledger/acctdeltas.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (a *compactResourcesDeltas) resourcesLoadOld(tx trackerdb.TransactionScope,
if len(a.misses) == 0 {
return nil
}
arw, err := tx.MakeAccountsReaderWriter()
ar, err := tx.MakeAccountsReader()
if err != nil {
return err
}
Expand All @@ -317,9 +317,9 @@ func (a *compactResourcesDeltas) resourcesLoadOld(tx trackerdb.TransactionScope,
if delta.oldResource.AcctRef != nil {
acctRef = delta.oldResource.AcctRef
} else if acctRef, ok = knownAddresses[addr]; !ok {
acctRef, err = arw.LookupAccountRowID(addr)
acctRef, err = ar.LookupAccountRowID(addr)
if err != nil {
if err != sql.ErrNoRows {
if err != sql.ErrNoRows || err != trackerdb.ErrNotFound {
err = fmt.Errorf("base account cannot be read while processing resource for addr=%s, aidx=%d: %w", addr.String(), aidx, err)
return err

Expand All @@ -330,7 +330,7 @@ func (a *compactResourcesDeltas) resourcesLoadOld(tx trackerdb.TransactionScope,
continue
}
}
resDataBuf, err = arw.LookupResourceDataByAddrID(acctRef, aidx)
resDataBuf, err = ar.LookupResourceDataByAddrID(acctRef, aidx)
switch err {
case nil:
if len(resDataBuf) > 0 {
Expand All @@ -344,6 +344,10 @@ func (a *compactResourcesDeltas) resourcesLoadOld(tx trackerdb.TransactionScope,
err = fmt.Errorf("empty resource record: addrid=%d, aidx=%d", acctRef, aidx)
return err
}
case trackerdb.ErrNotFound:
// we don't have that account, just return an empty record.
a.updateOld(missIdx, trackerdb.PersistedResourcesData{AcctRef: acctRef, Aidx: aidx})
err = nil
case sql.ErrNoRows:
// we don't have that account, just return an empty record.
a.updateOld(missIdx, trackerdb.PersistedResourcesData{AcctRef: acctRef, Aidx: aidx})
Expand Down Expand Up @@ -591,7 +595,7 @@ func (a *compactOnlineAccountDeltas) accountsLoadOld(tx trackerdb.TransactionSco
if len(a.misses) == 0 {
return nil
}
arw, err := tx.MakeAccountsReaderWriter()
ar, err := tx.MakeAccountsReader()
if err != nil {
return err
}
Expand All @@ -600,7 +604,7 @@ func (a *compactOnlineAccountDeltas) accountsLoadOld(tx trackerdb.TransactionSco
}()
for _, idx := range a.misses {
addr := a.deltas[idx].address
ref, acctDataBuf, err := arw.LookupOnlineAccountDataByAddress(addr)
ref, acctDataBuf, err := ar.LookupOnlineAccountDataByAddress(addr)
switch err {
case nil:
if len(acctDataBuf) > 0 {
Expand All @@ -614,6 +618,10 @@ func (a *compactOnlineAccountDeltas) accountsLoadOld(tx trackerdb.TransactionSco
// empty data means offline account
a.updateOld(idx, trackerdb.PersistedOnlineAccountData{Addr: addr, Ref: ref})
}
case trackerdb.ErrNotFound:
// we don't have that account, just return an empty record.
a.updateOld(idx, trackerdb.PersistedOnlineAccountData{Addr: addr})
// TODO: phase out sql.ErrNoRows
case sql.ErrNoRows:
// we don't have that account, just return an empty record.
a.updateOld(idx, trackerdb.PersistedOnlineAccountData{Addr: addr})
Expand Down
Loading

0 comments on commit 1e57b2b

Please sign in to comment.