summaryrefslogtreecommitdiff
path: root/ledger/cow.go
diff options
context:
space:
mode:
Diffstat (limited to 'ledger/cow.go')
-rw-r--r--ledger/cow.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/ledger/cow.go b/ledger/cow.go
index c5595169b..1234c191b 100644
--- a/ledger/cow.go
+++ b/ledger/cow.go
@@ -57,15 +57,16 @@ type roundCowState struct {
proto config.ConsensusParams
mods ledgercore.StateDelta
+ // count of transactions. Formerly, we used len(cb.mods), but that
+ // does not count inner transactions.
+ txnCount uint64
+
// storage deltas populated as side effects of AppCall transaction
// 1. Opt-in/Close actions (see Allocate/Deallocate)
// 2. Stateful TEAL evaluation (see SetKey/DelKey)
// must be incorporated into mods.accts before passing deltas forward
sdeltas map[basics.Address]map[storagePtr]*storageDelta
- // logs populated in AppCall transaction
- logs []basics.LogItem
-
// either or not maintain compatibility with original app refactoring behavior
// this is needed for generating old eval delta in new code
compatibilityMode bool
@@ -78,15 +79,14 @@ type roundCowState struct {
trackedCreatables map[int]basics.CreatableIndex
}
-func makeRoundCowState(b roundCowParent, hdr bookkeeping.BlockHeader, prevTimestamp int64, hint int) *roundCowState {
+func makeRoundCowState(b roundCowParent, hdr bookkeeping.BlockHeader, proto config.ConsensusParams, prevTimestamp int64, hint int) *roundCowState {
cb := roundCowState{
lookupParent: b,
commitParent: nil,
- proto: config.Consensus[hdr.CurrentProtocol],
+ proto: proto,
mods: ledgercore.MakeStateDelta(&hdr, prevTimestamp, hint, 0),
sdeltas: make(map[basics.Address]map[storagePtr]*storageDelta),
trackedCreatables: make(map[int]basics.CreatableIndex),
- logs: make([]basics.LogItem, 0),
}
// compatibilityMode retains producing application' eval deltas under the following rule:
@@ -184,7 +184,7 @@ func (cb *roundCowState) checkDup(firstValid, lastValid basics.Round, txid trans
}
func (cb *roundCowState) txnCounter() uint64 {
- return cb.lookupParent.txnCounter() + uint64(len(cb.mods.Txids))
+ return cb.lookupParent.txnCounter() + cb.txnCount
}
func (cb *roundCowState) compactCertNext() basics.Round {
@@ -202,8 +202,13 @@ func (cb *roundCowState) trackCreatable(creatableIndex basics.CreatableIndex) {
cb.trackedCreatables[cb.groupIdx] = creatableIndex
}
+func (cb *roundCowState) incTxnCount() {
+ cb.txnCount++
+}
+
func (cb *roundCowState) addTx(txn transactions.Transaction, txid transactions.Txid) {
cb.mods.Txids[txid] = txn.LastValid
+ cb.incTxnCount()
if txn.Lease != [32]byte{} {
cb.mods.Txleases[ledgercore.Txlease{Sender: txn.Sender, Lease: txn.Lease}] = txn.LastValid
}
@@ -246,6 +251,8 @@ func (cb *roundCowState) commitToParent() {
for txid, lv := range cb.mods.Txids {
cb.commitParent.mods.Txids[txid] = lv
}
+ cb.commitParent.txnCount += cb.txnCount
+
for txl, expires := range cb.mods.Txleases {
cb.commitParent.mods.Txleases[txl] = expires
}