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

Minimum Account Balance in Algod #3287

Merged
merged 39 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c8e17b7
initial commit
Dec 8, 2021
f247cbe
Merge branch 'master' of https://github.com/algorand/go-algorand into…
Dec 8, 2021
f8edde8
don't run the debugger on circle
Dec 8, 2021
ee5451c
can query TEAL for stateful min_balance. Next up: get algod to do the…
Dec 9, 2021
7e4daef
adding facade, but no content
Dec 9, 2021
5dafabb
revert
Dec 9, 2021
4ed0617
remote debugging
Dec 9, 2021
88544cf
add get_endpoint_info to e2e python Goal
Dec 9, 2021
d0cacfe
add get_endpoint_info to e2e python Goal
Dec 9, 2021
1f1fc88
testing
Dec 9, 2021
bd90ea6
tests basically passing
Dec 10, 2021
035432d
simple goal e2e test is passing
Dec 10, 2021
85de603
test passing -knock on wood-
Dec 10, 2021
d6034e5
Update daemon/algod/api/algod.oas2.json
tzaffi Dec 10, 2021
3bcb8bc
better wording
Dec 10, 2021
2139807
Merge branch 'master' of https://github.com/algorand/go-algorand into…
Dec 10, 2021
2b7a8b5
comment on its own line
Dec 11, 2021
9edf2e0
improvments in python abi e2e test wrapper
Dec 13, 2021
aa2196b
Merge branch 'master' of https://github.com/algorand/go-algorand into…
Dec 13, 2021
4894d95
per reviewer suggestions - use block header instead of block + add co…
Dec 13, 2021
42adb53
longer if clearer name for execute_singleton()
Dec 13, 2021
7dd6db4
Pass one .exp test and update the README
Dec 14, 2021
9c71612
Merge branch 'master' of https://github.com/algorand/go-algorand into…
Dec 14, 2021
5ecd5b0
Less TEAL, more python testing comments.
Dec 14, 2021
277c6ce
notFound --> internalError
Dec 15, 2021
395a6e4
Merge branch 'master' of https://github.com/algorand/go-algorand into…
Dec 15, 2021
992609b
removing ABI dependency
Dec 16, 2021
d15fc97
Merge branch 'master' of https://github.com/algorand/go-algorand into…
Dec 16, 2021
5d20acb
remove the teal file
Dec 16, 2021
c12a0ed
Merge branch 'master' of https://github.com/algorand/go-algorand into…
Dec 16, 2021
19ed866
revert
Dec 16, 2021
19e2a40
reorder functions
Dec 16, 2021
084adf0
better endpoint description
Dec 16, 2021
125bfbf
INTERACTIVE switch at the top
Dec 16, 2021
ae82da2
revert formatting changes
Dec 16, 2021
5efca2c
more realistic consensus params
Dec 16, 2021
bb5d4a9
Per reviewer suggestions
Dec 17, 2021
c50f1f8
Update test/scripts/e2e_subs/min_balance.py
tzaffi Dec 17, 2021
af2acec
Update test/scripts/e2e_subs/min_balance.py
tzaffi Dec 17, 2021
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
2 changes: 2 additions & 0 deletions cmd/goal/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ func printAccountInfo(client libgoal.Client, address string, account generatedV2
fmt.Fprintf(report, "\tID %d, local state used %d/%d uints, %d/%d byte slices\n", localState.Id, usedInts, allocatedInts, usedBytes, allocatedBytes)
}

fmt.Fprintf(report, "Minimum Balance:\t%v microAlgos\n", account.MinBalance)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a line to goal account info's output


if hasError {
fmt.Fprint(os.Stderr, errorReport.String())
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/tealdbg/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"strings"
"testing"

"github.com/algorand/go-algorand/config"
v2 "github.com/algorand/go-algorand/daemon/algod/api/server/v2"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/transactions"
Expand Down Expand Up @@ -984,7 +985,7 @@ func TestLocalBalanceAdapterIndexer(t *testing.T) {
case strings.HasPrefix(r.URL.Path, accountPath):
w.WriteHeader(200)
if r.URL.Path[len(accountPath):] == brs.Addr.String() {
account, err := v2.AccountDataToAccount(brs.Addr.String(), &brs.AccountData, map[basics.AssetIndex]string{}, 100, basics.MicroAlgos{Raw: 0})
account, err := v2.AccountDataToAccount(brs.Addr.String(), &brs.AccountData, map[basics.AssetIndex]string{}, 100, &config.ConsensusParams{MinBalance: 100000}, basics.MicroAlgos{Raw: 0})
a.NoError(err)
accountResponse := AccountIndexerResponse{Account: account, CurrentRound: 100}
response, err := json.Marshal(accountResponse)
Expand Down
7 changes: 6 additions & 1 deletion daemon/algod/api/algod.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,8 @@
"pending-rewards",
"amount-without-pending-rewards",
"rewards",
"status"
"status",
"min-balance"
],
"properties": {
"address": {
Expand All @@ -1365,6 +1366,10 @@
"description": "\\[algo\\] total number of MicroAlgos in the account",
"type": "integer"
},
"min-balance": {
"description": "MicroAlgo balance required by the account.\n\nThe requirement starts at 100,000 and grows based on asset and application usage.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to drop off the numeric constants from the description. These values are consensus protocol dependent and can be modified in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"type": "integer"
},
"amount-without-pending-rewards": {
"description": "specifies the amount of MicroAlgos in the account, without the pending rewards.",
"type": "integer"
Expand Down
5 changes: 5 additions & 0 deletions daemon/algod/api/algod.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,10 @@
},
"type": "array"
},
"min-balance": {
"description": "MicroAlgo balance required by the account.\n\nThe requirement starts at 100,000 and grows based on asset and application usage.",
"type": "integer"
},
"participation": {
"$ref": "#/components/schemas/AccountParticipation"
},
Expand Down Expand Up @@ -763,6 +767,7 @@
"address",
"amount",
"amount-without-pending-rewards",
"min-balance",
"pending-rewards",
"rewards",
"round",
Expand Down
7 changes: 6 additions & 1 deletion daemon/algod/api/server/v2/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"math"
"sort"

"github.com/algorand/go-algorand/config"
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated"
"github.com/algorand/go-algorand/data/basics"
Expand All @@ -30,7 +31,8 @@ import (
// AccountDataToAccount converts basics.AccountData to v2.generated.Account
func AccountDataToAccount(
address string, record *basics.AccountData, assetsCreators map[basics.AssetIndex]string,
lastRound basics.Round, amountWithoutPendingRewards basics.MicroAlgos,
lastRound basics.Round, consensus *config.ConsensusParams,
amountWithoutPendingRewards basics.MicroAlgos,
) (generated.Account, error) {

assets := make([]generated.AssetHolding, 0, len(record.Assets))
Expand Down Expand Up @@ -108,6 +110,8 @@ func AccountDataToAccount(
return generated.Account{}, errors.New("overflow on pending reward calculation")
}

minBalance := record.MinBalance(consensus)

return generated.Account{
SigType: nil,
Round: uint64(lastRound),
Expand All @@ -126,6 +130,7 @@ func AccountDataToAccount(
AppsLocalState: &appsLocalState,
AppsTotalSchema: &totalAppSchema,
AppsTotalExtraPages: numOrNil(totalExtraPages),
MinBalance: minBalance.Raw,
}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions daemon/algod/api/server/v2/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestAccount(t *testing.T) {
b := a.WithUpdatedRewards(proto, 100)

addr := basics.Address{}.String()
conv, err := AccountDataToAccount(addr, &b, map[basics.AssetIndex]string{}, round, a.MicroAlgos)
conv, err := AccountDataToAccount(addr, &b, map[basics.AssetIndex]string{}, round, &config.ConsensusParams{MinBalance: 100000}, a.MicroAlgos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minimum balance depends of a multiple fields from config.ConsensusParams. It would be wrong to initialize just a single field ( MinBalance ), since the function record.MinBalance might change over time.
I would suggest you'll grab a specific consensus protocol and use it. i.e. the current protocol sounds like a safe choice here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

require.NoError(t, err)
require.Equal(t, addr, conv.Address)
require.Equal(t, b.MicroAlgos.Raw, conv.Amount)
Expand Down Expand Up @@ -196,7 +196,7 @@ func TestAccount(t *testing.T) {
// convert the same account a few more times to make sure we always
// produce the same generated.Account
for i := 0; i < 10; i++ {
anotherConv, err := AccountDataToAccount(addr, &b, map[basics.AssetIndex]string{}, round, a.MicroAlgos)
anotherConv, err := AccountDataToAccount(addr, &b, map[basics.AssetIndex]string{}, round, &config.ConsensusParams{MinBalance: 100000}, a.MicroAlgos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

require.NoError(t, err)

require.Equal(t, protocol.EncodeJSON(conv), protocol.EncodeJSON(anotherConv))
Expand Down
Loading