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
19 changes: 10 additions & 9 deletions adapters/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/onflow/flow-go/access"
"github.com/onflow/flow-go/engine/access/subscription"
"github.com/onflow/flow-go/engine/common/rpc/convert"
accessmodel "github.com/onflow/flow-go/model/access"
flowgo "github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow/protobuf/go/flow/entities"
"github.com/rs/zerolog"
Expand All @@ -38,7 +39,7 @@ import (

var _ access.API = &AccessAdapter{}

// AccessAdapter wraps the emulator adapters to be compatible with access.API.
// AccessAdapter wraps the emulator adapters to be compatible with accessmodel.API.
type AccessAdapter struct {
logger *zerolog.Logger
emulator emulator.Emulator
Expand Down Expand Up @@ -70,7 +71,7 @@ func (a *AccessAdapter) Ping(_ context.Context) error {
return convertError(a.emulator.Ping(), codes.Internal)
}

func (a *AccessAdapter) GetNetworkParameters(_ context.Context) access.NetworkParameters {
func (a *AccessAdapter) GetNetworkParameters(_ context.Context) accessmodel.NetworkParameters {
return a.emulator.GetNetworkParameters()
}

Expand Down Expand Up @@ -205,7 +206,7 @@ func (a *AccessAdapter) GetTransactionResult(
_ flowgo.Identifier,
requiredEventEncodingVersion entities.EventEncodingVersion,
) (
*access.TransactionResult,
*accessmodel.TransactionResult,
error,
) {
result, err := a.emulator.GetTransactionResult(id)
Expand Down Expand Up @@ -434,7 +435,7 @@ func (a *AccessAdapter) GetSystemTransaction(_ context.Context, _ flowgo.Identif
return nil, nil
}

func (a *AccessAdapter) GetSystemTransactionResult(_ context.Context, _ flowgo.Identifier, _ entities.EventEncodingVersion) (*access.TransactionResult, error) {
func (a *AccessAdapter) GetSystemTransactionResult(_ context.Context, _ flowgo.Identifier, _ entities.EventEncodingVersion) (*accessmodel.TransactionResult, error) {
return nil, nil
}

Expand Down Expand Up @@ -539,7 +540,7 @@ func (a *AccessAdapter) GetTransactionResultByIndex(
blockID flowgo.Identifier,
index uint32,
requiredEventEncodingVersion entities.EventEncodingVersion,
) (*access.TransactionResult, error) {
) (*accessmodel.TransactionResult, error) {
results, err := a.emulator.GetTransactionResultsByBlockID(blockID)
if err != nil {
return nil, convertError(err, codes.Internal)
Expand Down Expand Up @@ -573,7 +574,7 @@ func (a *AccessAdapter) GetTransactionResultsByBlockID(
_ context.Context,
blockID flowgo.Identifier,
requiredEventEncodingVersion entities.EventEncodingVersion,
) ([]*access.TransactionResult, error) {
) ([]*accessmodel.TransactionResult, error) {
result, err := a.emulator.GetTransactionResultsByBlockID(blockID)
if err != nil {
return nil, convertError(err, codes.Internal)
Expand Down Expand Up @@ -603,10 +604,10 @@ func (a *AccessAdapter) SendTransaction(_ context.Context, tx *flowgo.Transactio
func (a *AccessAdapter) GetNodeVersionInfo(
_ context.Context,
) (
*access.NodeVersionInfo,
*accessmodel.NodeVersionInfo,
error,
) {
return &access.NodeVersionInfo{}, nil
return &accessmodel.NodeVersionInfo{}, nil
}

func (a *AccessAdapter) SubscribeBlocksFromStartBlockID(ctx context.Context, startBlockID flowgo.Identifier, blockStatus flowgo.BlockStatus) subscription.Subscription {
Expand Down Expand Up @@ -645,7 +646,7 @@ func (a *AccessAdapter) SubscribeBlockDigestsFromLatest(ctx context.Context, blo
return nil
}

func (a *AccessAdapter) SubscribeTransactionStatuses(ctx context.Context, tx *flowgo.TransactionBody, _ entities.EventEncodingVersion) subscription.Subscription {
func (a *AccessAdapter) SubscribeTransactionStatuses(ctx context.Context, _ flowgo.Identifier, _ entities.EventEncodingVersion) subscription.Subscription {
return nil
}

Expand Down
18 changes: 9 additions & 9 deletions adapters/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (

"github.com/onflow/cadence"
"github.com/onflow/cadence/encoding/ccf"
"github.com/onflow/flow-go/access"
"github.com/onflow/flow-go/engine/common/rpc/convert"
accessmodel "github.com/onflow/flow-go/model/access"
flowgo "github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow/protobuf/go/flow/entities"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestAccess(t *testing.T) {
}))

t.Run("GetNetworkParameters", accessTest(func(t *testing.T, adapter *AccessAdapter, emu *mocks.MockEmulator) {
expected := access.NetworkParameters{
expected := accessmodel.NetworkParameters{
ChainID: flowgo.MonotonicEmulator,
}

Expand Down Expand Up @@ -325,12 +325,12 @@ func TestAccess(t *testing.T) {
blockID := flowgo.Identifier{}
collectionID := flowgo.Identifier{}

emuResult := access.TransactionResult{
emuResult := accessmodel.TransactionResult{
Events: []flowgo.Event{
ccfEventFixture(t),
},
}
expected := access.TransactionResult{
expected := accessmodel.TransactionResult{
Events: []flowgo.Event{
jsonCDCEventFixture(t),
},
Expand Down Expand Up @@ -632,13 +632,13 @@ func TestAccess(t *testing.T) {
blockID := flowgo.Identifier{}
index := uint32(0)

txResult := &access.TransactionResult{
txResult := &accessmodel.TransactionResult{
Events: []flowgo.Event{
ccfEventFixture(t),
},
}
results := []*access.TransactionResult{txResult}
convertedTXResult := &access.TransactionResult{
results := []*accessmodel.TransactionResult{txResult}
convertedTXResult := &accessmodel.TransactionResult{
Events: []flowgo.Event{
jsonCDCEventFixture(t),
},
Expand Down Expand Up @@ -698,14 +698,14 @@ func TestAccess(t *testing.T) {

blockID := flowgo.Identifier{}

results := []*access.TransactionResult{
results := []*accessmodel.TransactionResult{
{
Events: []flowgo.Event{
ccfEventFixture(t),
},
},
}
expected := []*access.TransactionResult{
expected := []*accessmodel.TransactionResult{
{
Events: []flowgo.Event{
jsonCDCEventFixture(t),
Expand Down
4 changes: 2 additions & 2 deletions adapters/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/onflow/cadence/stdlib"
sdk "github.com/onflow/flow-go-sdk"
"github.com/onflow/flow-go-sdk/templates"
"github.com/onflow/flow-go/access"
accessmodel "github.com/onflow/flow-go/model/access"
flowgo "github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow/protobuf/go/flow/entities"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -403,7 +403,7 @@ func (b *SDKAdapter) GetSystemTransaction(_ context.Context, _ flowgo.Identifier
return nil, nil
}

func (b *SDKAdapter) GetSystemTransactionResult(_ context.Context, _ flowgo.Identifier, _ entities.EventEncodingVersion) (*access.TransactionResult, error) {
func (b *SDKAdapter) GetSystemTransactionResult(_ context.Context, _ flowgo.Identifier, _ entities.EventEncodingVersion) (*accessmodel.TransactionResult, error) {
return nil, nil
}

Expand Down
6 changes: 3 additions & 3 deletions adapters/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

"github.com/onflow/cadence"
flowgosdk "github.com/onflow/flow-go-sdk"
"github.com/onflow/flow-go/access"
accessmodel "github.com/onflow/flow-go/model/access"
flowgo "github.com/onflow/flow-go/model/flow"

"github.com/onflow/flow-emulator/convert"
Expand Down Expand Up @@ -438,7 +438,7 @@ func TestSDK(t *testing.T) {
expected := flowgosdk.TransactionResult{
Events: []flowgosdk.Event{},
}
flowResult := access.TransactionResult{}
flowResult := accessmodel.TransactionResult{}

//success
emu.EXPECT().
Expand Down Expand Up @@ -776,7 +776,7 @@ func TestSDK(t *testing.T) {

blockID := flowgosdk.Identifier{}

flowTransactionResults := []*access.TransactionResult{}
flowTransactionResults := []*accessmodel.TransactionResult{}
expected := []*flowgosdk.TransactionResult{}

//success
Expand Down
4 changes: 2 additions & 2 deletions convert/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/onflow/cadence/encoding/ccf"

sdk "github.com/onflow/flow-go-sdk"
"github.com/onflow/flow-go/access"
accessmodel "github.com/onflow/flow-go/model/access"
flowgo "github.com/onflow/flow-go/model/flow"
)

Expand Down Expand Up @@ -158,7 +158,7 @@ func FlowTransactionToSDK(flowTx flowgo.TransactionBody) sdk.Transaction {
return transaction
}

func FlowTransactionResultToSDK(result *access.TransactionResult) (*sdk.TransactionResult, error) {
func FlowTransactionResultToSDK(result *accessmodel.TransactionResult) (*sdk.TransactionResult, error) {

events, err := FlowEventsToSDK(result.Events)
if err != nil {
Expand Down
31 changes: 16 additions & 15 deletions emulator/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import (
"github.com/onflow/flow-core-contracts/lib/go/templates"
flowsdk "github.com/onflow/flow-go-sdk"
sdkcrypto "github.com/onflow/flow-go-sdk/crypto"
"github.com/onflow/flow-go/access"
"github.com/onflow/flow-go/access/validator"
"github.com/onflow/flow-go/engine"
"github.com/onflow/flow-go/fvm"
fvmcrypto "github.com/onflow/flow-go/fvm/crypto"
Expand All @@ -58,6 +58,7 @@ import (
"github.com/onflow/flow-go/fvm/meter"
reusableRuntime "github.com/onflow/flow-go/fvm/runtime"
"github.com/onflow/flow-go/fvm/storage/snapshot"
accessmodel "github.com/onflow/flow-go/model/access"
flowgo "github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/metrics"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -347,7 +348,7 @@ type Blockchain struct {
vm *fvm.VirtualMachine
vmCtx fvm.Context

transactionValidator *access.TransactionValidator
transactionValidator *validator.TransactionValidator

serviceKey ServiceKey

Expand Down Expand Up @@ -505,8 +506,8 @@ func (b *Blockchain) GetChain() flowgo.Chain {
return b.vmCtx.Chain
}

func (b *Blockchain) GetNetworkParameters() access.NetworkParameters {
return access.NetworkParameters{
func (b *Blockchain) GetNetworkParameters() accessmodel.NetworkParameters {
return accessmodel.NetworkParameters{
ChainID: b.GetChain().ChainID(),
}
}
Expand Down Expand Up @@ -820,12 +821,12 @@ func configureBootstrapProcedure(conf config, flowAccountKey flowgo.AccountPubli
)
}

func configureTransactionValidator(conf config, blocks *blocks) (*access.TransactionValidator, error) {
return access.NewTransactionValidator(
func configureTransactionValidator(conf config, blocks *blocks) (*validator.TransactionValidator, error) {
return validator.NewTransactionValidator(
blocks,
conf.GetChainID().Chain(),
metrics.NewNoopCollector(),
access.TransactionValidationOptions{
validator.TransactionValidationOptions{
Expiry: conf.TransactionExpiry,
ExpiryBuffer: 0,
AllowEmptyReferenceBlockID: conf.TransactionExpiry == 0,
Expand All @@ -834,7 +835,7 @@ func configureTransactionValidator(conf config, blocks *blocks) (*access.Transac
CheckScriptsParse: true,
MaxTransactionByteSize: flowgo.DefaultMaxTransactionByteSize,
MaxCollectionByteSize: flowgo.DefaultMaxCollectionByteSize,
CheckPayerBalanceMode: access.Disabled,
CheckPayerBalanceMode: validator.Disabled,
},
nil,
)
Expand Down Expand Up @@ -1007,24 +1008,24 @@ func (b *Blockchain) getTransaction(txID flowgo.Identifier) (*flowgo.Transaction
return &tx, nil
}

func (b *Blockchain) GetTransactionResult(txID flowgo.Identifier) (*access.TransactionResult, error) {
func (b *Blockchain) GetTransactionResult(txID flowgo.Identifier) (*accessmodel.TransactionResult, error) {
b.mu.RLock()
defer b.mu.RUnlock()

return b.getTransactionResult(txID)
}

func (b *Blockchain) getTransactionResult(txID flowgo.Identifier) (*access.TransactionResult, error) {
func (b *Blockchain) getTransactionResult(txID flowgo.Identifier) (*accessmodel.TransactionResult, error) {
if b.pendingBlock.ContainsTransaction(txID) {
return &access.TransactionResult{
return &accessmodel.TransactionResult{
Status: flowgo.TransactionStatusPending,
}, nil
}

storedResult, err := b.storage.TransactionResultByID(context.Background(), txID)
if err != nil {
if errors.Is(err, storage.ErrNotFound) {
return &access.TransactionResult{
return &accessmodel.TransactionResult{
Status: flowgo.TransactionStatusUnknown,
}, nil
}
Expand All @@ -1035,7 +1036,7 @@ func (b *Blockchain) getTransactionResult(txID flowgo.Identifier) (*access.Trans
if storedResult.ErrorCode > 0 {
statusCode = 1
}
result := access.TransactionResult{
result := accessmodel.TransactionResult{
Status: flowgo.TransactionStatusSealed,
StatusCode: uint(statusCode),
ErrorMessage: storedResult.ErrorMessage,
Expand Down Expand Up @@ -1714,7 +1715,7 @@ func (b *Blockchain) GetTransactionsByBlockID(blockID flowgo.Identifier) ([]*flo
return transactions, nil
}

func (b *Blockchain) GetTransactionResultsByBlockID(blockID flowgo.Identifier) ([]*access.TransactionResult, error) {
func (b *Blockchain) GetTransactionResultsByBlockID(blockID flowgo.Identifier) ([]*accessmodel.TransactionResult, error) {
b.mu.RLock()
defer b.mu.RUnlock()

Expand All @@ -1723,7 +1724,7 @@ func (b *Blockchain) GetTransactionResultsByBlockID(blockID flowgo.Identifier) (
return nil, fmt.Errorf("failed to get block %s: %w", blockID, err)
}

var results []*access.TransactionResult
var results []*accessmodel.TransactionResult
for i, guarantee := range block.Payload.Guarantees {
c, err := b.getCollectionByID(guarantee.CollectionID)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions emulator/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ import (
"context"
"errors"

"github.com/onflow/flow-go/access"

"github.com/onflow/flow-go/access/validator"
"github.com/onflow/flow-go/fvm/environment"
flowgo "github.com/onflow/flow-go/model/flow"

"github.com/onflow/flow-emulator/storage"
)

var _ environment.Blocks = &blocks{}
var _ access.Blocks = &blocks{}
var _ validator.Blocks = &blocks{}

type blocks struct {
blockchain *Blockchain
Expand Down
8 changes: 4 additions & 4 deletions emulator/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/onflow/cadence/runtime"
flowgosdk "github.com/onflow/flow-go-sdk"
sdkcrypto "github.com/onflow/flow-go-sdk/crypto"
"github.com/onflow/flow-go/access"
accessmodel "github.com/onflow/flow-go/model/access"
flowgo "github.com/onflow/flow-go/model/flow"

"github.com/onflow/flow-emulator/types"
Expand Down Expand Up @@ -124,7 +124,7 @@ type RollbackCapable interface {

type AccessProvider interface {
Ping() error
GetNetworkParameters() access.NetworkParameters
GetNetworkParameters() accessmodel.NetworkParameters

GetLatestBlock() (*flowgo.Block, error)
GetBlockByID(id flowgo.Identifier) (*flowgo.Block, error)
Expand All @@ -134,9 +134,9 @@ type AccessProvider interface {
GetFullCollectionByID(colID flowgo.Identifier) (*flowgo.Collection, error)

GetTransaction(txID flowgo.Identifier) (*flowgo.TransactionBody, error)
GetTransactionResult(txID flowgo.Identifier) (*access.TransactionResult, error)
GetTransactionResult(txID flowgo.Identifier) (*accessmodel.TransactionResult, error)
GetTransactionsByBlockID(blockID flowgo.Identifier) ([]*flowgo.TransactionBody, error)
GetTransactionResultsByBlockID(blockID flowgo.Identifier) ([]*access.TransactionResult, error)
GetTransactionResultsByBlockID(blockID flowgo.Identifier) ([]*accessmodel.TransactionResult, error)

GetAccount(address flowgo.Address) (*flowgo.Account, error)
GetAccountAtBlockHeight(address flowgo.Address, blockHeight uint64) (*flowgo.Account, error)
Expand Down
2 changes: 1 addition & 1 deletion emulator/mocks/emulator.go

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

Loading
Loading