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

ledger: rename "internal" package to "eval" #4272

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions ledger/acctupdates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/ledger/internal"
"github.com/algorand/go-algorand/ledger/eval"
"github.com/algorand/go-algorand/ledger/ledgercore"
ledgertesting "github.com/algorand/go-algorand/ledger/testing"
"github.com/algorand/go-algorand/logging"
Expand Down Expand Up @@ -174,7 +174,7 @@ func (ml *mockLedgerForTracker) addMockBlock(be blockEntry, delta ledgercore.Sta
return nil
}

func (ml *mockLedgerForTracker) trackerEvalVerified(blk bookkeeping.Block, accUpdatesLedger internal.LedgerForEvaluator) (ledgercore.StateDelta, error) {
func (ml *mockLedgerForTracker) trackerEvalVerified(blk bookkeeping.Block, accUpdatesLedger eval.LedgerForEvaluator) (ledgercore.StateDelta, error) {
// support returning the deltas if the client explicitly provided them by calling addMockBlock, otherwise,
// just return an empty state delta ( since the client clearly didn't care about these )
if len(ml.deltas) > int(blk.Round()) {
Expand Down
4 changes: 2 additions & 2 deletions ledger/archival_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/ledger/internal"
"github.com/algorand/go-algorand/ledger/eval"
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
Expand Down Expand Up @@ -67,7 +67,7 @@ func (wl *wrappedLedger) BlockHdr(rnd basics.Round) (bookkeeping.BlockHeader, er
return wl.l.BlockHdr(rnd)
}

func (wl *wrappedLedger) trackerEvalVerified(blk bookkeeping.Block, accUpdatesLedger internal.LedgerForEvaluator) (ledgercore.StateDelta, error) {
func (wl *wrappedLedger) trackerEvalVerified(blk bookkeeping.Block, accUpdatesLedger eval.LedgerForEvaluator) (ledgercore.StateDelta, error) {
return wl.l.trackerEvalVerified(blk, accUpdatesLedger)
}

Expand Down
2 changes: 1 addition & 1 deletion ledger/internal/appcow.go → ledger/eval/appcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal_test
package eval_test

import (
"encoding/hex"
Expand Down
2 changes: 1 addition & 1 deletion ledger/internal/assetcow.go → ledger/eval/assetcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"github.com/algorand/go-algorand/data/basics"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion ledger/internal/cow.go → ledger/eval/cow.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion ledger/internal/cow_test.go → ledger/eval/cow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"testing"
Expand Down
12 changes: 6 additions & 6 deletions ledger/internal/double_test.go → ledger/eval/double_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal_test
package eval_test

import (
"testing"
Expand All @@ -23,7 +23,7 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/data/txntest"
"github.com/algorand/go-algorand/ledger"
"github.com/algorand/go-algorand/ledger/internal"
"github.com/algorand/go-algorand/ledger/eval"
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/protocol"
"github.com/stretchr/testify/require"
Expand All @@ -46,7 +46,7 @@ type DoubleLedger struct {
generator *ledger.Ledger
validator *ledger.Ledger

eval *internal.BlockEvaluator
eval *eval.BlockEvaluator
}

func (dl DoubleLedger) Close() {
Expand All @@ -61,7 +61,7 @@ func NewDoubleLedger(t *testing.T, balances bookkeeping.GenesisBalances, cv prot
return DoubleLedger{t, g, v, nil}
}

func (dl *DoubleLedger) beginBlock() *internal.BlockEvaluator {
func (dl *DoubleLedger) beginBlock() *eval.BlockEvaluator {
dl.eval = nextBlock(dl.t, dl.generator)
return dl.eval
}
Expand Down Expand Up @@ -160,7 +160,7 @@ func checkBlock(t *testing.T, checkLedger *ledger.Ledger, vb *ledgercore.Validat
// require.Equal(t, vb.Delta().Accts, cb.Delta().Accts)
}

func nextCheckBlock(t testing.TB, ledger *ledger.Ledger, rs bookkeeping.RewardsState) *internal.BlockEvaluator {
func nextCheckBlock(t testing.TB, ledger *ledger.Ledger, rs bookkeeping.RewardsState) *eval.BlockEvaluator {
rnd := ledger.Latest()
hdr, err := ledger.BlockHdr(rnd)
require.NoError(t, err)
Expand All @@ -169,7 +169,7 @@ func nextCheckBlock(t testing.TB, ledger *ledger.Ledger, rs bookkeeping.RewardsS
nextHdr.RewardsState = rs
// follow nextBlock, which does this for determinism
nextHdr.TimeStamp = hdr.TimeStamp + 1
eval, err := internal.StartEvaluator(ledger, nextHdr, internal.EvaluatorOptions{
eval, err := eval.StartEvaluator(ledger, nextHdr, eval.EvaluatorOptions{
Generate: false,
Validate: true, // Do the complete checks that a new txn would be subject to
})
Expand Down
4 changes: 2 additions & 2 deletions ledger/internal/eval.go → ledger/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"context"
Expand All @@ -31,7 +31,7 @@ import (
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/data/transactions/verify"
"github.com/algorand/go-algorand/ledger/apply"
"github.com/algorand/go-algorand/ledger/internal/prefetcher"
"github.com/algorand/go-algorand/ledger/eval/prefetcher"
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal_test
package eval_test

import (
"context"
Expand All @@ -34,7 +34,7 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/data/txntest"
"github.com/algorand/go-algorand/ledger"
"github.com/algorand/go-algorand/ledger/internal"
"github.com/algorand/go-algorand/ledger/eval"
"github.com/algorand/go-algorand/ledger/ledgercore"
ledgertesting "github.com/algorand/go-algorand/ledger/testing"
"github.com/algorand/go-algorand/logging"
Expand Down Expand Up @@ -385,22 +385,22 @@ ok:
}

// nextBlock begins evaluation of a new block, after ledger creation or endBlock()
func nextBlock(t testing.TB, ledger *ledger.Ledger) *internal.BlockEvaluator {
func nextBlock(t testing.TB, ledger *ledger.Ledger) *eval.BlockEvaluator {
rnd := ledger.Latest()
hdr, err := ledger.BlockHdr(rnd)
require.NoError(t, err)

nextHdr := bookkeeping.MakeBlock(hdr).BlockHeader
nextHdr.TimeStamp = hdr.TimeStamp + 1 // ensure deterministic tests
eval, err := internal.StartEvaluator(ledger, nextHdr, internal.EvaluatorOptions{
eval, err := eval.StartEvaluator(ledger, nextHdr, eval.EvaluatorOptions{
Generate: true,
Validate: true, // Do the complete checks that a new txn would be subject to
})
require.NoError(t, err)
return eval
}

func fillDefaults(t testing.TB, ledger *ledger.Ledger, eval *internal.BlockEvaluator, txn *txntest.Txn) {
func fillDefaults(t testing.TB, ledger *ledger.Ledger, eval *eval.BlockEvaluator, txn *txntest.Txn) {
if txn.GenesisHash.IsZero() && ledger.GenesisProto().SupportGenesisHash {
txn.GenesisHash = ledger.GenesisHash()
}
Expand All @@ -411,14 +411,14 @@ func fillDefaults(t testing.TB, ledger *ledger.Ledger, eval *internal.BlockEvalu
txn.FillDefaults(ledger.GenesisProto())
}

func txns(t testing.TB, ledger *ledger.Ledger, eval *internal.BlockEvaluator, txns ...*txntest.Txn) {
func txns(t testing.TB, ledger *ledger.Ledger, eval *eval.BlockEvaluator, txns ...*txntest.Txn) {
t.Helper()
for _, txn1 := range txns {
txn(t, ledger, eval, txn1)
}
}

func txn(t testing.TB, ledger *ledger.Ledger, eval *internal.BlockEvaluator, txn *txntest.Txn, problem ...string) {
func txn(t testing.TB, ledger *ledger.Ledger, eval *eval.BlockEvaluator, txn *txntest.Txn, problem ...string) {
t.Helper()
fillDefaults(t, ledger, eval, txn)
err := eval.Transaction(txn.SignedTxn(), transactions.ApplyData{})
Expand All @@ -433,7 +433,7 @@ func txn(t testing.TB, ledger *ledger.Ledger, eval *internal.BlockEvaluator, txn
require.True(t, len(problem) == 0 || problem[0] == "")
}

func txgroup(t testing.TB, ledger *ledger.Ledger, eval *internal.BlockEvaluator, txns ...*txntest.Txn) error {
func txgroup(t testing.TB, ledger *ledger.Ledger, eval *eval.BlockEvaluator, txns ...*txntest.Txn) error {
t.Helper()
for _, txn := range txns {
fillDefaults(t, ledger, eval, txn)
Expand Down Expand Up @@ -528,7 +528,7 @@ func TestEvalAppPooledBudgetWithTxnGroup(t *testing.T) {
}

// endBlock completes the block being created, returns the ValidatedBlock for inspection
func endBlock(t testing.TB, ledger *ledger.Ledger, eval *internal.BlockEvaluator) *ledgercore.ValidatedBlock {
func endBlock(t testing.TB, ledger *ledger.Ledger, eval *eval.BlockEvaluator) *ledgercore.ValidatedBlock {
validatedBlock, err := eval.GenerateBlock()
require.NoError(t, err)
err = ledger.AddValidatedBlock(*validatedBlock, agreement.Certificate{})
Expand Down
2 changes: 1 addition & 1 deletion ledger/internal/eval_test.go → ledger/eval/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal
package eval

// Export for testing only. See
// https://medium.com/@robiplus/golang-trick-export-for-test-aa16cbd7b8cd for a
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/ledger/internal"
"github.com/algorand/go-algorand/ledger/internal/prefetcher"
"github.com/algorand/go-algorand/ledger/eval"
"github.com/algorand/go-algorand/ledger/eval/prefetcher"
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/partitiontest"
Expand Down Expand Up @@ -281,7 +281,7 @@ func runEval(t *testing.T, l *prefetcherAlignmentTestLedger, txn transactions.Tr
require.NoError(t, err)
block := bookkeeping.MakeBlock(genesisBlockHeader)

eval, err := internal.StartEvaluator(l, block.BlockHeader, internal.EvaluatorOptions{})
eval, err := eval.StartEvaluator(l, block.BlockHeader, eval.EvaluatorOptions{})
require.NoError(t, err)

err = eval.TransactionGroup(makeGroupFromTxn(txn))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/ledger/internal/prefetcher"
"github.com/algorand/go-algorand/ledger/eval/prefetcher"
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/partitiontest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package internal_test
package eval_test

import (
"errors"
Expand Down
4 changes: 2 additions & 2 deletions ledger/evalbench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/data/transactions/logic"
"github.com/algorand/go-algorand/ledger/internal"
"github.com/algorand/go-algorand/ledger/eval"
"github.com/algorand/go-algorand/ledger/ledgercore"
ledgertesting "github.com/algorand/go-algorand/ledger/testing"
"github.com/algorand/go-algorand/logging"
Expand Down Expand Up @@ -491,7 +491,7 @@ func benchmarkBlockEvaluator(b *testing.B, inMem bool, withCrypto bool, proto pr
if withCrypto {
_, err = l2.Validate(context.Background(), validatedBlock.Block(), backlogPool)
} else {
_, err = internal.Eval(context.Background(), l2, validatedBlock.Block(), false, nil, nil)
_, err = eval.Eval(context.Background(), l2, validatedBlock.Block(), false, nil, nil)
}
require.NoError(b, err)
}
Expand Down
6 changes: 3 additions & 3 deletions ledger/evalindexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/bookkeeping"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/ledger/internal"
"github.com/algorand/go-algorand/ledger/eval"
"github.com/algorand/go-algorand/ledger/ledgercore"
)

Expand Down Expand Up @@ -214,9 +214,9 @@ func makeIndexerLedgerConnector(il indexerLedgerForEval, genesisHash crypto.Dige
func EvalForIndexer(il indexerLedgerForEval, block *bookkeeping.Block, proto config.ConsensusParams, resources EvalForIndexerResources) (ledgercore.StateDelta, []transactions.SignedTxnInBlock, error) {
ilc := makeIndexerLedgerConnector(il, block.GenesisHash(), proto, block.Round()-1, resources)

eval, err := internal.StartEvaluator(
eval, err := eval.StartEvaluator(
ilc, block.BlockHeader,
internal.EvaluatorOptions{
eval.EvaluatorOptions{
PaysetHint: len(block.Payset),
ProtoParams: &proto,
Generate: false,
Expand Down
Loading