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

Update usage of tx validator interface #699

11 changes: 8 additions & 3 deletions emulator/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,10 @@ func (b *Blockchain) ReloadBlockchain() error {
}

b.pendingBlock = newPendingBlock(latestBlock, latestLedger, b.clock)
b.transactionValidator = configureTransactionValidator(b.conf, blocks)
b.transactionValidator, err = configureTransactionValidator(b.conf, blocks)
if err != nil {
return err
}

return nil
}
Expand Down Expand Up @@ -808,7 +811,7 @@ func configureBootstrapProcedure(conf config, flowAccountKey flowgo.AccountPubli
)
}

func configureTransactionValidator(conf config, blocks *blocks) *access.TransactionValidator {
func configureTransactionValidator(conf config, blocks *blocks) (*access.TransactionValidator, error) {
return access.NewTransactionValidator(
blocks,
conf.GetChainID().Chain(),
Expand All @@ -821,7 +824,9 @@ func configureTransactionValidator(conf config, blocks *blocks) *access.Transact
CheckScriptsParse: true,
MaxTransactionByteSize: flowgo.DefaultMaxTransactionByteSize,
MaxCollectionByteSize: flowgo.DefaultMaxCollectionByteSize,
CheckPayerBalance: false,
},
nil,
)
}

Expand Down Expand Up @@ -1208,7 +1213,7 @@ func (b *Blockchain) addTransaction(tx flowgo.TransactionBody) error {
return fmt.Errorf("failed to check storage for transaction %w", err)
}

err = b.transactionValidator.Validate(&tx)
err = b.transactionValidator.Validate(context.Background(), &tx)
if err != nil {
return types.ConvertAccessError(err)
}
Expand Down
9 changes: 9 additions & 0 deletions emulator/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ func (b *blocks) FinalizedHeader() (*flowgo.Header, error) {
return block.Header, nil
}

func (b *blocks) SealedHeader() (*flowgo.Header, error) {
block, err := b.blockchain.storage.LatestBlock(context.Background())
if err != nil {
return nil, err
}

return block.Header, nil
}

// We don't have to do anything complex here, as emulator does not fork the chain
func (b *blocks) ByHeightFrom(height uint64, header *flowgo.Header) (*flowgo.Header, error) {
if height > header.Height {
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ require (
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/improbable-eng/grpc-web v0.15.0
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/onflow/cadence v1.0.0-preview.36
github.com/onflow/cadence v1.0.0-preview.37
github.com/onflow/crypto v0.25.1
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1
turbolent marked this conversation as resolved.
Show resolved Hide resolved
github.com/onflow/flow-go v0.35.14-crescendo-preview.27.0.20240626210601-604590f19db9
github.com/onflow/flow-go-sdk v1.0.0-preview.38
github.com/onflow/flow-go-sdk v1.0.0-preview.39
github.com/onflow/flow-nft/lib/go/contracts v1.2.1
github.com/onflow/flow/protobuf/go/flow v0.4.5
github.com/prometheus/client_golang v1.18.0
Expand Down Expand Up @@ -151,7 +151,7 @@ require (
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onflow/atree v0.7.0-rc.2 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.0 // indirect
github.com/onflow/flow-nft/lib/go/templates v1.2.0 // indirect
Expand Down Expand Up @@ -237,4 +237,4 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/onflow/flow-go v0.35.14-crescendo-preview.27.0.20240626210601-604590f19db9 => github.com/AndriiDiachuk/flow-go v0.0.0-20240711140457-69e2f4007091
replace github.com/onflow/flow-go v0.35.14-crescendo-preview.27.0.20240626210601-604590f19db9 => github.com/The-K-R-O-K/flow-go v0.35.14-crescendo-preview.27.0.20240716115708-5866b5c41fb5
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,6 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8=
git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc=
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/AndriiDiachuk/flow-go v0.0.0-20240711140457-69e2f4007091 h1:9lI8wMf2HDx8jCEXWwqxAZYBJ9+yq0U7Kd7GWQ1lviE=
github.com/AndriiDiachuk/flow-go v0.0.0-20240711140457-69e2f4007091/go.mod h1:zyDRnDHQ7am6Ial1Sk9w5dPB9gQZzAtzYLJIYyLA3z8=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q=
Expand Down Expand Up @@ -982,6 +980,8 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/The-K-R-O-K/flow-go v0.35.14-crescendo-preview.27.0.20240716115708-5866b5c41fb5 h1:qsi3F6xPgl2gACQcWvA2Kjmh9PV+ZvH19N8RDkW1yLw=
github.com/The-K-R-O-K/flow-go v0.35.14-crescendo-preview.27.0.20240716115708-5866b5c41fb5/go.mod h1:h/vv58zjd/tCwPvUnr6OrT89zQCLViVLCj+ucUm0GxU=
github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw=
github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40=
github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o=
Expand Down Expand Up @@ -2052,22 +2052,22 @@ github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs
github.com/onflow/atree v0.7.0-rc.2 h1:mZmVrl/zPlfI44EjV3FdR2QwIqT8nz1sCONUBFcML/U=
github.com/onflow/atree v0.7.0-rc.2/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM=
github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8=
github.com/onflow/cadence v1.0.0-preview.36 h1:mbxqoYSYiVX2Uo+Plrkmu29ezrShohlN+4Ltw0cfJxU=
github.com/onflow/cadence v1.0.0-preview.36/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0=
github.com/onflow/cadence v1.0.0-preview.37 h1:CclIG7GXEBJCwk5d5jumJ6cU8xj/Q1A9cfVJKIxvLH8=
github.com/onflow/cadence v1.0.0-preview.37/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0=
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A=
github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 h1:cq3RfBr9TnTSnsGlUHMjMGZib24Horfb1XJqMpkN5ew=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0/go.mod h1:u/mkP/B+PbV33tEG3qfkhhBlydSvAKxfLZSfB4lsJHg=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 h1:aMFJdB2CW+Dzm+AJ5QN6J1yWh+a0l2RxHN2/TtLaXUo=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0/go.mod h1:NgbMOYnMh0GN48VsNKZuiwK7uyk38Wyo8jN9+C9QE30=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 h1:q9tXLIALwQ76bO4bmSrhtTkyc2cZF4/gH11ix9E3F5k=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1/go.mod h1:u/mkP/B+PbV33tEG3qfkhhBlydSvAKxfLZSfB4lsJHg=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 h1:FfhMBAb78p6VAWkJ+iqdKLErGQVQgxk5w6DP5ZruWX8=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1/go.mod h1:NgbMOYnMh0GN48VsNKZuiwK7uyk38Wyo8jN9+C9QE30=
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 h1:mToacZ5NWqtlWwk/7RgIl/jeKB/Sy/tIXdw90yKHcV0=
github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs=
github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo=
github.com/onflow/flow-go-sdk v1.0.0-preview.38 h1:vzTXhNkklnuxFaqhFeLPry+sud6LzhRMFFQveYJuXt4=
github.com/onflow/flow-go-sdk v1.0.0-preview.38/go.mod h1:SuSH+SB9jONwjhXrb402JM7HfDLAcXRABN1wF+iYAfw=
github.com/onflow/flow-go-sdk v1.0.0-preview.39 h1:LAFqq8fph9BnnbYO/PuT4+bZHrfDCZOBG9RytJbrBZ4=
github.com/onflow/flow-go-sdk v1.0.0-preview.39/go.mod h1:/72XLyAy6//wS4Xnt2sp6FgR+MtWPqrLwrkVzbjSE44=
github.com/onflow/flow-nft/lib/go/contracts v1.2.1 h1:woAAS5z651sDpi7ihAHll8NvRS9uFXIXkL6xR+bKFZY=
github.com/onflow/flow-nft/lib/go/contracts v1.2.1/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE=
github.com/onflow/flow-nft/lib/go/templates v1.2.0 h1:JSQyh9rg0RC+D1930BiRXN8lrtMs+ubVMK6aQPon6Yc=
Expand Down
Loading