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
3 changes: 3 additions & 0 deletions config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,9 @@ func initConsensusProtocols() {
// Enable App calls to pool budget in grouped transactions
vFuture.EnableAppCostPooling = true

// Allow 50 app opt ins
vFuture.MaxAppsOptedIn = 50

Consensus[protocol.ConsensusFuture] = vFuture
}

Expand Down
2 changes: 1 addition & 1 deletion data/basics/userBalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (

// MaxEncodedAccountDataSize is a rough estimate for the worst-case scenario we're going to have of the account data and address serialized.
// this number is verified by the TestEncodedAccountDataSize function.
MaxEncodedAccountDataSize = 750000
MaxEncodedAccountDataSize = 850000
Copy link
Contributor

Choose a reason for hiding this comment

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

We talked about this earlier, but I'm wondering if this takes into account worst case asa creation. I think that can be very big.


// encodedMaxAssetsPerAccount is the decoder limit of number of assets stored per account.
// it's being verified by the unit test TestEncodedAccountAllocationBounds to align
Expand Down
6 changes: 6 additions & 0 deletions ledger/accountdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func randomAddress() basics.Address {
return addr
}

func randomNote() []byte {
var note [16]byte
crypto.RandBytes(note[:])
return note[:]
}

func randomAccountData(rewardsLevel uint64) basics.AccountData {
var data basics.AccountData

Expand Down
56 changes: 47 additions & 9 deletions ledger/apply/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ const appIdxError basics.AppIndex = 0x11223344
const appIdxOk basics.AppIndex = 1

func (b *testBalances) Get(addr basics.Address, withPendingRewards bool) (basics.AccountData, error) {
if b.putBalances != nil {
ad, ok := b.putBalances[addr]
if ok {
return ad, nil
}
}
ad, ok := b.balances[addr]
if !ok {
return basics.AccountData{}, fmt.Errorf("mock balance not found")
Expand Down Expand Up @@ -515,15 +521,6 @@ func TestAppCallApplyCreate(t *testing.T) {

b.ResetWrites()

// now looking up the creator will succeed, but we reset writes, so
// they won't have the app params
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.Error(err)
a.Contains(err.Error(), fmt.Sprintf("app %d not found in account", appIdx))
a.Equal(1, b.put)

b.ResetWrites()

// now we give the creator the app params again
cp := basics.AccountData{}
cp.AppParams = cloneAppParams(saved.AppParams)
Expand Down Expand Up @@ -690,6 +687,42 @@ func TestAppCallOptIn(t *testing.T) {
},
br,
)

// check max optins

var optInCountTest = []struct {
proto protocol.ConsensusVersion
}{
{protocol.ConsensusV29},
{protocol.ConsensusFuture},
}

prevMaxAppsOptedIn := 0
for _, test := range optInCountTest {
cparams, ok := config.Consensus[test.proto]
a.True(ok)
a.Less(prevMaxAppsOptedIn, cparams.MaxAppsOptedIn)
prevMaxAppsOptedIn = cparams.MaxAppsOptedIn

b.SetParams(cparams)
aparams := basics.AppParams{
StateSchemas: basics.StateSchemas{
LocalStateSchema: basics.StateSchema{NumUint: 1},
},
}
sender = getRandomAddress(a)
b.balances = map[basics.Address]basics.AccountData{sender: {}}
var appIdx basics.AppIndex = appIdx
for i := 0; i < cparams.MaxAppsOptedIn; i++ {
appIdx = appIdx + basics.AppIndex(i)
err = optInApplication(&b, sender, appIdx, aparams)
a.NoError(err)
}
appIdx++
err = optInApplication(&b, sender, appIdx, aparams)
a.Error(err)
a.Contains(err.Error(), "max opted-in apps per acct")
}
}

func TestAppCallClearState(t *testing.T) {
Expand Down Expand Up @@ -931,8 +964,12 @@ func TestAppCallApplyCloseOut(t *testing.T) {
a.Equal(basics.EvalDelta{GlobalDelta: gd}, ad.EvalDelta)
a.Equal(basics.StateSchema{NumUint: 0}, br.TotalAppSchema)

b.ResetWrites()
logs := []basics.LogItem{{ID: 0, Message: "a"}}
b.delta = basics.EvalDelta{Logs: []basics.LogItem{{ID: 0, Message: "a"}}}
b.balances[sender] = basics.AccountData{
AppLocalStates: map[basics.AppIndex]basics.AppLocalState{appIdx: {}},
}
err = ApplicationCall(ac, h, &b, ad, &ep, txnCounter)
a.NoError(err)
a.Equal(basics.EvalDelta{Logs: logs}, ad.EvalDelta)
Expand Down Expand Up @@ -1062,6 +1099,7 @@ func TestAppCallApplyUpdate(t *testing.T) {
a.Contains(err.Error(), fmt.Sprintf("updateApplication %s program too long", test.name))
}

b.ResetWrites()
// check extraProgramPages allows length of proto.MaxAppProgramLen + 1
appr = make([]byte, proto.MaxAppProgramLen+1)
appr[0] = 4
Expand Down
Loading