Skip to content

Remove GetTx from the DAGVM interface #1642

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

Merged
merged 28 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
36988a4
Remove DAG based tx issuance logic
StephenButtolph Jun 19, 2023
f4ae592
Remove dagState and GetUTXOFromID
StephenButtolph Jun 19, 2023
d924932
Fix unit tests
StephenButtolph Jun 19, 2023
7d1dda4
Merge branch 'remove-get-utxo-from-id' into remove-avm-tx-batcher
StephenButtolph Jun 19, 2023
4855439
wip make tests compile
StephenButtolph Jun 19, 2023
c517ea9
nit lint
StephenButtolph Jun 20, 2023
30485cd
fix linting
StephenButtolph Jun 20, 2023
4bc87bd
Merge branch 'dev' into remove-get-utxo-from-id
StephenButtolph Jun 20, 2023
2ff0186
wip cleanup tests
StephenButtolph Jun 20, 2023
23c038d
Merge branch 'remove-get-utxo-from-id' into remove-avm-tx-batcher
StephenButtolph Jun 20, 2023
ad086ba
wip fixup service tests
StephenButtolph Jun 20, 2023
724d878
more cleanup
StephenButtolph Jun 20, 2023
26f86e0
fix tests
StephenButtolph Jun 21, 2023
97950f1
keep test
StephenButtolph Jun 21, 2023
4c2e286
nit
StephenButtolph Jun 21, 2023
168aed9
nit
StephenButtolph Jun 21, 2023
b03a622
nits
StephenButtolph Jun 21, 2023
e4aa1c9
Remove PendingTxs from the DAGVM interface
StephenButtolph Jun 21, 2023
fc2df6e
lint
StephenButtolph Jun 21, 2023
37ae15c
Remove GetTx from the DAGVM interface
StephenButtolph Jun 21, 2023
9ad9511
lint
StephenButtolph Jun 21, 2023
3db4590
clenaup
StephenButtolph Jun 21, 2023
ca82e41
remove code changes
StephenButtolph Jun 21, 2023
208c7d9
merged
StephenButtolph Jun 21, 2023
55d91dc
merged
StephenButtolph Jun 21, 2023
c4838d8
Merge branch 'remove-pending-txs' into remove-get-tx
StephenButtolph Jun 21, 2023
c512d15
oops
StephenButtolph Jun 21, 2023
cc9f8fe
merged
StephenButtolph Jun 22, 2023
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
18 changes: 3 additions & 15 deletions indexer/indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"github.com/ava-labs/avalanchego/database/versiondb"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/snow/choices"
"github.com/ava-labs/avalanchego/snow/consensus/snowstorm"
"github.com/ava-labs/avalanchego/snow/engine/avalanche/vertex"
"github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/snow/engine/snowman/block/mocks"
Expand Down Expand Up @@ -324,21 +322,11 @@ func TestIndexer(t *testing.T) {
txID, txBytes := ids.GenerateTestID(), utils.RandomBytes(32)
expectedTx := Container{
ID: txID,
Bytes: blkBytes,
Bytes: txBytes,
Timestamp: now.UnixNano(),
}
// Mocked VM knows about this tx now
dagVM.EXPECT().GetTx(gomock.Any(), txID).Return(
&snowstorm.TestTx{
TestDecidable: choices.TestDecidable{
IDV: txID,
StatusV: choices.Accepted,
},
BytesV: txBytes,
}, nil,
).AnyTimes()

require.NoError(config.TxAcceptorGroup.Accept(chain2Ctx, txID, blkBytes))

require.NoError(config.TxAcceptorGroup.Accept(chain2Ctx, txID, txBytes))

txIdx := idxr.txIndices[chain2Ctx.ChainID]
require.NotNil(txIdx)
Expand Down
15 changes: 0 additions & 15 deletions snow/engine/avalanche/vertex/mock_vm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions snow/engine/avalanche/vertex/test_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@ var (
type TestVM struct {
block.TestVM

CantLinearize, CantParse, CantGet bool
CantLinearize, CantParse bool

LinearizeF func(context.Context, ids.ID) error
ParseTxF func(context.Context, []byte) (snowstorm.Tx, error)
GetTxF func(context.Context, ids.ID) (snowstorm.Tx, error)
}

func (vm *TestVM) Default(cant bool) {
vm.TestVM.Default(cant)

vm.CantParse = cant
vm.CantGet = cant
}

func (vm *TestVM) Linearize(ctx context.Context, stopVertexID ids.ID) error {
Expand All @@ -56,13 +54,3 @@ func (vm *TestVM) ParseTx(ctx context.Context, b []byte) (snowstorm.Tx, error) {
}
return nil, errParse
}

func (vm *TestVM) GetTx(ctx context.Context, txID ids.ID) (snowstorm.Tx, error) {
if vm.GetTxF != nil {
return vm.GetTxF(ctx, txID)
}
if vm.CantGet && vm.T != nil {
require.FailNow(vm.T, errGet.Error())
}
return nil, errGet
}
7 changes: 0 additions & 7 deletions snow/engine/avalanche/vertex/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,7 @@ type LinearizableVM interface {
// implement
type DAGVM interface {
block.ChainVM
Getter

// Convert a stream of bytes to a transaction or return an error
ParseTx(ctx context.Context, txBytes []byte) (snowstorm.Tx, error)
}

// Getter defines the functionality for fetching a tx/block by its ID.
type Getter interface {
// Retrieve a transaction that was submitted previously
GetTx(ctx context.Context, txID ids.ID) (snowstorm.Tx, error)
}
10 changes: 0 additions & 10 deletions vms/avm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,6 @@ func (vm *VM) ParseTx(_ context.Context, bytes []byte) (snowstorm.Tx, error) {
return tx, nil
}

func (vm *VM) GetTx(_ context.Context, txID ids.ID) (snowstorm.Tx, error) {
tx := &UniqueTx{
vm: vm,
txID: txID,
}
// Verify must be called in the case the that tx was flushed from the unique
// cache.
return tx, tx.verifyWithoutCacheWrites()
}

/*
******************************************************************************
********************************** JSON API **********************************
Expand Down
95 changes: 0 additions & 95 deletions vms/avm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,101 +582,6 @@ func TestTxAcceptAfterParseTx(t *testing.T) {
require.Equal(choices.Accepted, secondTxStatus)
}

func TestTxAcceptAfterGetTx(t *testing.T) {
require := require.New(t)

env := setup(t, &envConfig{
notLinearized: true,
})
defer func() {
require.NoError(env.vm.Shutdown(context.Background()))
env.vm.ctx.Lock.Unlock()
}()

key := keys[0]
firstTx := &txs.Tx{Unsigned: &txs.BaseTx{
BaseTx: avax.BaseTx{
NetworkID: constants.UnitTestID,
BlockchainID: chainID,
Ins: []*avax.TransferableInput{{
UTXOID: avax.UTXOID{
TxID: env.genesisTx.ID(),
OutputIndex: 2,
},
Asset: avax.Asset{ID: env.genesisTx.ID()},
In: &secp256k1fx.TransferInput{
Amt: startBalance,
Input: secp256k1fx.Input{
SigIndices: []uint32{
0,
},
},
},
}},
Outs: []*avax.TransferableOutput{{
Asset: avax.Asset{ID: env.genesisTx.ID()},
Out: &secp256k1fx.TransferOutput{
Amt: startBalance - env.vm.TxFee,
OutputOwners: secp256k1fx.OutputOwners{
Threshold: 1,
Addrs: []ids.ShortID{key.PublicKey().Address()},
},
},
}},
},
}}
require.NoError(firstTx.SignSECP256K1Fx(env.vm.parser.Codec(), [][]*secp256k1.PrivateKey{{key}}))

secondTx := &txs.Tx{Unsigned: &txs.BaseTx{
BaseTx: avax.BaseTx{
NetworkID: constants.UnitTestID,
BlockchainID: chainID,
Ins: []*avax.TransferableInput{{
UTXOID: avax.UTXOID{
TxID: firstTx.ID(),
OutputIndex: 0,
},
Asset: avax.Asset{ID: env.genesisTx.ID()},
In: &secp256k1fx.TransferInput{
Amt: startBalance - env.vm.TxFee,
Input: secp256k1fx.Input{
SigIndices: []uint32{
0,
},
},
},
}},
},
}}
require.NoError(secondTx.SignSECP256K1Fx(env.vm.parser.Codec(), [][]*secp256k1.PrivateKey{{key}}))

_, err := env.vm.ParseTx(context.Background(), firstTx.Bytes())
require.NoError(err)

fetchedFirstTx, err := env.vm.GetTx(context.Background(), firstTx.ID())
require.NoError(err)

require.NoError(fetchedFirstTx.Verify(context.Background()))
require.NoError(fetchedFirstTx.Accept(context.Background()))

_, err = env.vm.ParseTx(context.Background(), secondTx.Bytes())
require.NoError(err)

fetchedSecondTx, err := env.vm.GetTx(context.Background(), secondTx.ID())
require.NoError(err)

require.NoError(fetchedSecondTx.Verify(context.Background()))
require.NoError(fetchedSecondTx.Accept(context.Background()))

firstTxStatus, err := env.vm.state.GetStatus(firstTx.ID())
require.NoError(err)
require.Equal(choices.Accepted, firstTxStatus)

secondTxStatus, err := env.vm.state.GetStatus(secondTx.ID())
require.NoError(err)
require.Equal(choices.Accepted, secondTxStatus)
}

// Test issuing an import transaction.
func TestIssueImportTx(t *testing.T) {
require := require.New(t)
Expand Down
4 changes: 0 additions & 4 deletions vms/metervm/vertex_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
type vertexMetrics struct {
parse,
parseErr,
get,
getErr,
verify,
verifyErr,
accept,
Expand All @@ -28,8 +26,6 @@ func (m *vertexMetrics) Initialize(
errs := wrappers.Errs{}
m.parse = newAverager(namespace, "parse_tx", reg, &errs)
m.parseErr = newAverager(namespace, "parse_tx_err", reg, &errs)
m.get = newAverager(namespace, "get_tx", reg, &errs)
m.getErr = newAverager(namespace, "get_tx_err", reg, &errs)
m.verify = newAverager(namespace, "verify_tx", reg, &errs)
m.verifyErr = newAverager(namespace, "verify_tx_err", reg, &errs)
m.accept = newAverager(namespace, "accept", reg, &errs)
Expand Down
17 changes: 0 additions & 17 deletions vms/metervm/vertex_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/ava-labs/avalanchego/api/metrics"
"github.com/ava-labs/avalanchego/database/manager"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/snow/consensus/snowstorm"
"github.com/ava-labs/avalanchego/snow/engine/avalanche/vertex"
Expand Down Expand Up @@ -93,22 +92,6 @@ func (vm *vertexVM) ParseTx(ctx context.Context, b []byte) (snowstorm.Tx, error)
}, nil
}

func (vm *vertexVM) GetTx(ctx context.Context, txID ids.ID) (snowstorm.Tx, error) {
start := vm.clock.Time()
tx, err := vm.LinearizableVMWithEngine.GetTx(ctx, txID)
end := vm.clock.Time()
duration := float64(end.Sub(start))
if err != nil {
vm.vertexMetrics.getErr.Observe(duration)
return nil, err
}
vm.vertexMetrics.get.Observe(duration)
return &meterTx{
Tx: tx,
vm: vm,
}, nil
}

type meterTx struct {
snowstorm.Tx

Expand Down
14 changes: 0 additions & 14 deletions vms/tracedvm/vertex_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
oteltrace "go.opentelemetry.io/otel/trace"

"github.com/ava-labs/avalanchego/database/manager"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/snow/consensus/snowstorm"
"github.com/ava-labs/avalanchego/snow/engine/avalanche/vertex"
Expand Down Expand Up @@ -72,16 +71,3 @@ func (vm *vertexVM) ParseTx(ctx context.Context, txBytes []byte) (snowstorm.Tx,
tracer: vm.tracer,
}, err
}

func (vm *vertexVM) GetTx(ctx context.Context, txID ids.ID) (snowstorm.Tx, error) {
ctx, span := vm.tracer.Start(ctx, "vertexVM.GetTx", oteltrace.WithAttributes(
attribute.Stringer("txID", txID),
))
defer span.End()

tx, err := vm.LinearizableVMWithEngine.GetTx(ctx, txID)
return &tracedTx{
Tx: tx,
tracer: vm.tracer,
}, err
}