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

add new blockchain hooks #6319

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a7e9294
add new blockchain hooks
laurci Jul 16, 2024
9ff3ca2
Merge remote-tracking branch 'origin/rc/v1.7.next1' into new-blockcha…
laurci Jul 24, 2024
67a99d6
Merge remote-tracking branch 'origin/rc/v1.7.2' into new-blockchain-h…
laurci Jul 25, 2024
f060fde
use cached epoch start block in vm blockchain hook
laurci Jul 26, 2024
a4b93be
tpn nil epoch start trigger
laurci Jul 26, 2024
c8ef463
use round handler to get round duration in blockchain hook
laurci Jul 26, 2024
9334561
fix nil pointer epoch start block header
laurci Jul 26, 2024
b9eef0c
nil checks for RoundHandler and EpochStartTriggerHandler
laurci Jul 29, 2024
f94bc3c
fix more RoundHandler nils in tests
laurci Jul 29, 2024
8d9114d
deep copy header when returning from trigger
laurci Jul 29, 2024
0684c29
epochStartHdr nil error check
laurci Jul 29, 2024
53f4563
propagate SetCurrentHeader errors
laurci Jul 30, 2024
0534fc4
remove log; epoch start hdr check if nil
laurci Jul 30, 2024
1f07ae2
simplify error handling in LastCommitedEpochStartHdr impl
laurci Jul 31, 2024
1877e0c
get epoch start block from storage for sc query
laurci Jul 31, 2024
6f64220
add comment for SetEpochStartHeader
laurci Aug 1, 2024
a333893
rc/1.7.2 update dependencies
laurci Aug 2, 2024
fc46b8b
managed buffer small ints gas cost
laurci Aug 2, 2024
5d877d8
formatting fixes
laurci Aug 2, 2024
4ac3ab5
update vm version
laurci Aug 2, 2024
a6a1af7
chainsimulator tests fixes
laurci Aug 7, 2024
e770491
more chain simulator tests fixing
laurci Aug 7, 2024
2a402b5
add warn logs for error cases in updateEpochStartHeaderFromCurrentHeader
laurci Aug 14, 2024
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
5 changes: 5 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
GetCodeMetadata = 10000
IsBuiltinFunction = 10000
IsReservedFunctionName = 10000
GetRoundTime = 1000
EpochStartBlockTimeStamp = 1000
EpochStartBlockNonce = 1000
EpochStartBlockRound = 1000


[EthAPICost]
UseGas = 100
Expand Down
4 changes: 4 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
GetCodeMetadata = 10000
IsBuiltinFunction = 10000
IsReservedFunctionName = 10000
GetRoundTime = 10000
EpochStartBlockTimeStamp = 10000
EpochStartBlockNonce = 10000
EpochStartBlockRound = 10000

[EthAPICost]
UseGas = 100
Expand Down
4 changes: 4 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
GetCodeMetadata = 10000
IsBuiltinFunction = 10000
IsReservedFunctionName = 10000
GetRoundTime = 10000
EpochStartBlockTimeStamp = 10000
EpochStartBlockNonce = 10000
EpochStartBlockRound = 10000

[EthAPICost]
UseGas = 100
Expand Down
4 changes: 4 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV4.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
GetCodeMetadata = 10000
IsBuiltinFunction = 10000
IsReservedFunctionName = 10000
GetRoundTime = 10000
EpochStartBlockTimeStamp = 10000
EpochStartBlockNonce = 10000
EpochStartBlockRound = 10000

[EthAPICost]
UseGas = 100
Expand Down
4 changes: 4 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV5.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
GetCodeMetadata = 10000
IsBuiltinFunction = 10000
IsReservedFunctionName = 10000
GetRoundTime = 10000
EpochStartBlockTimeStamp = 10000
EpochStartBlockNonce = 10000
EpochStartBlockRound = 10000

[EthAPICost]
UseGas = 100
Expand Down
4 changes: 4 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV6.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
GetCodeMetadata = 10000
IsBuiltinFunction = 10000
IsReservedFunctionName = 10000
GetRoundTime = 10000
EpochStartBlockTimeStamp = 10000
EpochStartBlockNonce = 10000
EpochStartBlockRound = 10000

[EthAPICost]
UseGas = 100
Expand Down
4 changes: 4 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV7.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
GetCodeMetadata = 10000
IsBuiltinFunction = 10000
IsReservedFunctionName = 10000
GetRoundTime = 10000
EpochStartBlockTimeStamp = 10000
EpochStartBlockNonce = 10000
EpochStartBlockRound = 10000

[EthAPICost]
UseGas = 100
Expand Down
4 changes: 4 additions & 0 deletions cmd/node/config/gasSchedules/gasScheduleV8.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
GetCodeMetadata = 10000
IsBuiltinFunction = 10000
IsReservedFunctionName = 10000
GetRoundTime = 10000
EpochStartBlockTimeStamp = 10000
EpochStartBlockNonce = 10000
EpochStartBlockRound = 10000

[EthAPICost]
UseGas = 100
Expand Down
1 change: 1 addition & 0 deletions epochStart/metachain/systemSCs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ func createFullArgumentsForSystemSCProcessing(enableEpochsConfig config.EnableEp
GasSchedule: gasScheduleNotifier,
Counter: &testscommon.BlockChainHookCounterStub{},
MissingTrieNodesNotifier: &testscommon.MissingTrieNodesNotifierStub{},
NodesSetup: nodesSetup,
}

defaults.FillGasMapInternal(gasSchedule, 1)
Expand Down
1 change: 1 addition & 0 deletions factory/api/apiResolverFactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ func createScQueryElement(
MissingTrieNodesNotifier: syncer.NewMissingTrieNodesNotifier(),
Accounts: accountsAdapterApi,
BlockChain: apiBlockchain,
NodesSetup: args.coreComponents.GenesisNodesSetup(),
}

var vmFactory process.VirtualMachinesContainerFactory
Expand Down
2 changes: 2 additions & 0 deletions factory/processing/blockProcessorCreator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,7 @@ func (pcf *processComponentsFactory) createVMFactoryShard(
GasSchedule: pcf.gasSchedule,
Counter: counter,
MissingTrieNodesNotifier: notifier,
NodesSetup: pcf.coreData.GenesisNodesSetup(),
}

blockChainHookImpl, err := hooks.NewBlockChainHookImpl(argsHook)
Expand Down Expand Up @@ -1123,6 +1124,7 @@ func (pcf *processComponentsFactory) createVMFactoryMeta(
GasSchedule: pcf.gasSchedule,
Counter: counters.NewDisabledCounter(),
MissingTrieNodesNotifier: syncer.NewMissingTrieNodesNotifier(),
NodesSetup: pcf.coreData.GenesisNodesSetup(),
}

blockChainHookImpl, err := hooks.NewBlockChainHookImpl(argsHook)
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ require (
github.com/multiversx/mx-chain-crypto-go v1.2.12-0.20240508074452-cc21c1b505df
github.com/multiversx/mx-chain-es-indexer-go v1.7.2-0.20240703134111-bda0024613cc
github.com/multiversx/mx-chain-logger-go v1.0.15-0.20240508072523-3f00a726af57
github.com/multiversx/mx-chain-scenario-go v1.4.4-0.20240509103754-9e8129721f00
github.com/multiversx/mx-chain-scenario-go v1.4.4-0.20240716122141-cb25f6e7cef0
github.com/multiversx/mx-chain-storage-go v1.0.16-0.20240508073549-dcb8e6e0370f
github.com/multiversx/mx-chain-vm-common-go v1.5.13-0.20240715100647-8ce0ec25ff1d
github.com/multiversx/mx-chain-vm-go v1.5.30-0.20240715111121-ec175dad3ac8
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68-0.20240509103859-89de3c5da36b
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.69-0.20240509104009-598a37ff36b9
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.98-0.20240509104102-2a6a709b4041
github.com/multiversx/mx-chain-vm-common-go v1.5.13-0.20240716084819-890cf285a584
github.com/multiversx/mx-chain-vm-go v1.5.30-0.20240716125541-f2321722ffd8
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68-0.20240716132123-55d87f4f76a2
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.69-0.20240716132655-84c237b4ff86
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.98-0.20240716131510-9655bc0017ec
github.com/pelletier/go-toml v1.9.3
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
Expand Down
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -395,20 +395,20 @@ github.com/multiversx/mx-chain-es-indexer-go v1.7.2-0.20240703134111-bda0024613c
github.com/multiversx/mx-chain-es-indexer-go v1.7.2-0.20240703134111-bda0024613cc/go.mod h1:yMq9q5VdN7jBaErRGQ0T8dkZwbBtfQYmqGbD/Ese1us=
github.com/multiversx/mx-chain-logger-go v1.0.15-0.20240508072523-3f00a726af57 h1:g9t410dqjcb7UUptbVd/H6Ua12sEzWU4v7VplyNvRZ0=
github.com/multiversx/mx-chain-logger-go v1.0.15-0.20240508072523-3f00a726af57/go.mod h1:cY6CIXpndW5g5PTPn4WzPwka/UBEf+mgw+PSY5pHGAU=
github.com/multiversx/mx-chain-scenario-go v1.4.4-0.20240509103754-9e8129721f00 h1:hFEcbGBtXu8UyB9BMhmAIH2R8BtV/NOq/rsxespLCN8=
github.com/multiversx/mx-chain-scenario-go v1.4.4-0.20240509103754-9e8129721f00/go.mod h1:pnIIfWopbDMQ1EW5Ddc6KDMqv8Qtx+hxbH9rorHpCyo=
github.com/multiversx/mx-chain-scenario-go v1.4.4-0.20240716122141-cb25f6e7cef0 h1:kyf4meBS6n8Km9ds2OQIn/V1u67AzVv0cALct1l4z9s=
github.com/multiversx/mx-chain-scenario-go v1.4.4-0.20240716122141-cb25f6e7cef0/go.mod h1:IelKhXNV/5Q2SlgMYsf+Dh+WCtIJcss0evvX22s5stw=
github.com/multiversx/mx-chain-storage-go v1.0.16-0.20240508073549-dcb8e6e0370f h1:yd/G8iPBGOEAwbaS8zndJpO6bQk7Tk72ZhmlqRasThI=
github.com/multiversx/mx-chain-storage-go v1.0.16-0.20240508073549-dcb8e6e0370f/go.mod h1:E6nfj9EQzGxWDGM3Dn6eZWRC3qFy1G8IqOsYsBOcgWw=
github.com/multiversx/mx-chain-vm-common-go v1.5.13-0.20240715100647-8ce0ec25ff1d h1:GqwJaWDgWFuHx4AsUBMwpHWzY4afyTbWBk0nwYG6lsY=
github.com/multiversx/mx-chain-vm-common-go v1.5.13-0.20240715100647-8ce0ec25ff1d/go.mod h1:RgGmPei0suQcFTHfO4cS5dxJSiokp2SM5lmNgp1icMo=
github.com/multiversx/mx-chain-vm-go v1.5.30-0.20240715111121-ec175dad3ac8 h1:yWqReDIF3P7Y37nonIip7uVVUERFCJIWlIvM3G2qb38=
github.com/multiversx/mx-chain-vm-go v1.5.30-0.20240715111121-ec175dad3ac8/go.mod h1:AKygEQlZe9F2YdO8VKK8QCWb7UTCuN2KclFcEfFo0m4=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68-0.20240509103859-89de3c5da36b h1:puYO0lUyPGA5kZqsiDjGa+daDGQwj9xFs0S5urhZjU8=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68-0.20240509103859-89de3c5da36b/go.mod h1:SY95hGdAIc8YCGb4uNSy1ux8V8qQbF1ReZJDwQ6AqEo=
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.69-0.20240509104009-598a37ff36b9 h1:rrkgAS58jRXc6LThPHY5fm3AnFoUa0VUiYkH5czdlYg=
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.69-0.20240509104009-598a37ff36b9/go.mod h1:TiOTsz2kxHadU0It7okOwcynyNPePXzjyl7lnpGLlUQ=
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.98-0.20240509104102-2a6a709b4041 h1:k0xkmCrJiQzsWk4ZM3oNQ31lheiDvd1qQnNwnyuZzXU=
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.98-0.20240509104102-2a6a709b4041/go.mod h1:XeZNaDMV0hbDlm3JtW0Hj3mCWKaB/XecQlCzEjiK5L8=
github.com/multiversx/mx-chain-vm-common-go v1.5.13-0.20240716084819-890cf285a584 h1:f4ybUYrES2XzumD9KsLzXfy/QdR9LiX1nJ4Nz2eBID4=
github.com/multiversx/mx-chain-vm-common-go v1.5.13-0.20240716084819-890cf285a584/go.mod h1:RgGmPei0suQcFTHfO4cS5dxJSiokp2SM5lmNgp1icMo=
github.com/multiversx/mx-chain-vm-go v1.5.30-0.20240716125541-f2321722ffd8 h1:jPLHRA1BMz0oTvxHuEbFXKWwJ7SYy0gFHTWHNKWG2BQ=
github.com/multiversx/mx-chain-vm-go v1.5.30-0.20240716125541-f2321722ffd8/go.mod h1:8Eso3RjhK1VM/e3pVnmvx+JlAlE7APmls6lA+rP65co=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68-0.20240716132123-55d87f4f76a2 h1:69pa9Kf7MiTr9iXkNT66tstJLgUq0eLzlmXCU6my3wM=
github.com/multiversx/mx-chain-vm-v1_2-go v1.2.68-0.20240716132123-55d87f4f76a2/go.mod h1:AczUpKXgHsYqVYmZpoHI5IILAjaJrZoNpyTeCExIeaM=
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.69-0.20240716132655-84c237b4ff86 h1:hvM9g67RRK3WNyjWL4nmT9/2KaI3CDSSFr0jgEyw9VY=
github.com/multiversx/mx-chain-vm-v1_3-go v1.3.69-0.20240716132655-84c237b4ff86/go.mod h1:GwV1inaPJtY3QX9C0rsT1kUsaIM/ZfXzX2DSSFSA0D0=
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.98-0.20240716131510-9655bc0017ec h1:peZ8Mg6Vjg7/M3/R2aksUmWxwlM8FvfNWms8Oa2Cdkw=
github.com/multiversx/mx-chain-vm-v1_4-go v1.4.98-0.20240716131510-9655bc0017ec/go.mod h1:XdebtaCIcnF4jAxOynYKI9MjerqhLeH29s3Jht2cpzs=
github.com/multiversx/mx-components-big-int v1.0.0 h1:Wkr8lSzK2nDqixOrrBa47VNuqdhV1m/aJhaP1EMaiS8=
github.com/multiversx/mx-components-big-int v1.0.0/go.mod h1:maIEMgHlNE2u78JaDD0oLzri+ShgU4okHfzP3LWGdQM=
github.com/multiversx/protobuf v1.3.2 h1:RaNkxvGTGbA0lMcnHAN24qE1G1i+Xs5yHA6MDvQ4mSM=
Expand Down
3 changes: 3 additions & 0 deletions integrationTests/testProcessorNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ func (tpn *TestProcessorNode) createFullSCQueryService(gasMap map[string]map[str
GasSchedule: gasSchedule,
Counter: counters.NewDisabledCounter(),
MissingTrieNodesNotifier: &testscommon.MissingTrieNodesNotifierStub{},
NodesSetup: tpn.NodesSetup,
}

var apiBlockchain data.ChainHandler
Expand Down Expand Up @@ -1642,6 +1643,7 @@ func (tpn *TestProcessorNode) initInnerProcessors(gasMap map[string]map[string]u
GasSchedule: gasSchedule,
Counter: counter,
MissingTrieNodesNotifier: &testscommon.MissingTrieNodesNotifierStub{},
NodesSetup: tpn.NodesSetup,
}

maxGasLimitPerBlock := uint64(0xFFFFFFFFFFFFFFFF)
Expand Down Expand Up @@ -1869,6 +1871,7 @@ func (tpn *TestProcessorNode) initMetaInnerProcessors(gasMap map[string]map[stri
GasSchedule: gasSchedule,
Counter: counters.NewDisabledCounter(),
MissingTrieNodesNotifier: &testscommon.MissingTrieNodesNotifierStub{},
NodesSetup: tpn.NodesSetup,
}

var signVerifier vm.MessageSignVerifier
Expand Down
11 changes: 11 additions & 0 deletions integrationTests/vm/testInitializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ func CreateTxProcessorWithOneSCExecutorMockVM(
defaults.FillGasMapInternal(gasSchedule, 1)
gasScheduleNotifier := mock.NewGasScheduleNotifierMock(gasSchedule)

nodesSetup := &genesisMocks.NodesSetupStub{}

builtInFuncs := vmcommonBuiltInFunctions.NewBuiltInFunctionContainer()
datapool := dataRetrieverMock.NewPoolsHolderMock()
args := hooks.ArgBlockChainHook{
Expand All @@ -415,6 +417,7 @@ func CreateTxProcessorWithOneSCExecutorMockVM(
GasSchedule: gasScheduleNotifier,
Counter: &testscommon.BlockChainHookCounterStub{},
MissingTrieNodesNotifier: &testscommon.MissingTrieNodesNotifierStub{},
NodesSetup: nodesSetup,
}

blockChainHook, _ := hooks.NewBlockChainHookImpl(args)
Expand Down Expand Up @@ -503,6 +506,7 @@ func CreateTxProcessorWithOneSCExecutorMockVM(
// CreateOneSCExecutorMockVM -
func CreateOneSCExecutorMockVM(accnts state.AccountsAdapter) vmcommon.VMExecutionHandler {
datapool := dataRetrieverMock.NewPoolsHolderMock()
nodesSetup := &genesisMocks.NodesSetupStub{}
args := hooks.ArgBlockChainHook{
Accounts: accnts,
PubkeyConv: pubkeyConv,
Expand All @@ -523,6 +527,7 @@ func CreateOneSCExecutorMockVM(accnts state.AccountsAdapter) vmcommon.VMExecutio
GasSchedule: CreateMockGasScheduleNotifier(),
Counter: &testscommon.BlockChainHookCounterStub{},
MissingTrieNodesNotifier: &testscommon.MissingTrieNodesNotifierStub{},
NodesSetup: nodesSetup,
}
blockChainHook, _ := hooks.NewBlockChainHookImpl(args)
vm, _ := mock.NewOneSCExecutorMockVM(blockChainHook, integrationtests.TestHasher)
Expand Down Expand Up @@ -573,6 +578,8 @@ func CreateVMAndBlockchainHookAndDataPool(
esdtTransferParser, _ := parsers.NewESDTTransferParser(integrationtests.TestMarshalizer)
counter, _ := counters.NewUsageCounter(esdtTransferParser)

nodesSetup := &genesisMocks.NodesSetupStub{}

datapool := dataRetrieverMock.NewPoolsHolderMock()
args := hooks.ArgBlockChainHook{
Accounts: accnts,
Expand All @@ -594,6 +601,7 @@ func CreateVMAndBlockchainHookAndDataPool(
GasSchedule: gasSchedule,
Counter: counter,
MissingTrieNodesNotifier: &testscommon.MissingTrieNodesNotifierStub{},
NodesSetup: nodesSetup,
}

maxGasLimitPerBlock := uint64(0xFFFFFFFFFFFFFFFF)
Expand Down Expand Up @@ -664,6 +672,8 @@ func CreateVMAndBlockchainHookMeta(
argsBuiltIn.AutomaticCrawlerAddresses = integrationTests.GenerateOneAddressPerShard(argsBuiltIn.ShardCoordinator)
builtInFuncFactory, _ := builtInFunctions.CreateBuiltInFunctionsFactory(argsBuiltIn)

nodesSetup := &genesisMocks.NodesSetupStub{}

datapool := dataRetrieverMock.NewPoolsHolderMock()
args := hooks.ArgBlockChainHook{
Accounts: validatorAccounts,
Expand All @@ -684,6 +694,7 @@ func CreateVMAndBlockchainHookMeta(
GasSchedule: gasSchedule,
Counter: &testscommon.BlockChainHookCounterStub{},
MissingTrieNodesNotifier: &testscommon.MissingTrieNodesNotifierStub{},
NodesSetup: nodesSetup,
}

economicsData, err := createEconomicsData(config.EnableEpochs{})
Expand Down
3 changes: 3 additions & 0 deletions integrationTests/vm/wasm/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
dataRetrieverMock "github.com/multiversx/mx-chain-go/testscommon/dataRetriever"
"github.com/multiversx/mx-chain-go/testscommon/dblookupext"
"github.com/multiversx/mx-chain-go/testscommon/epochNotifier"
"github.com/multiversx/mx-chain-go/testscommon/genesisMocks"
"github.com/multiversx/mx-chain-go/testscommon/guardianMocks"
"github.com/multiversx/mx-chain-go/testscommon/integrationtests"
"github.com/multiversx/mx-chain-go/testscommon/marshallerMock"
Expand Down Expand Up @@ -280,6 +281,7 @@ func (context *TestContext) initVMAndBlockchainHook() {

blockchainMock := &testscommon.ChainHandlerStub{}
chainStorer := &storageStubs.ChainStorerStub{}
nodesSetup := &genesisMocks.NodesSetupStub{}
datapool := dataRetrieverMock.NewPoolsHolderMock()
args := hooks.ArgBlockChainHook{
Accounts: context.Accounts,
Expand Down Expand Up @@ -313,6 +315,7 @@ func (context *TestContext) initVMAndBlockchainHook() {
GasSchedule: gasSchedule,
Counter: &testscommon.BlockChainHookCounterStub{},
MissingTrieNodesNotifier: &testscommon.MissingTrieNodesNotifierStub{},
NodesSetup: nodesSetup,
}

vmFactoryConfig := config.VirtualMachineConfig{
Expand Down
26 changes: 26 additions & 0 deletions process/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,32 @@ func GetMetaHeaderFromStorageWithNonce(
return hdr, hash, nil
}

func GetBlockHeaderForEpochStartFromStorage(
epoch uint32,
shard uint32,
storageService dataRetriever.StorageService,
uint64Converter typeConverters.Uint64ByteSliceConverter,
marshalizer marshal.Marshalizer,
) (data.HeaderHandler, []byte, error) {
storer, err := storageService.GetStorer(dataRetriever.BlockHeaderUnit)
if err != nil {
return nil, nil, err
}

identifier := core.EpochStartIdentifier(epoch)
headerBytes, err := storer.GetFromEpoch([]byte(identifier), epoch)
if err != nil {
return nil, nil, err
}

header, err := UnmarshalShardHeader(marshalizer, headerBytes)
if err != nil {
return nil, nil, err
}

return GetHeaderFromStorageWithNonce(header.GetNonce(), shard, storageService, uint64Converter, marshalizer)
}

// GetTransactionHandler gets the transaction with a given sender/receiver shardId and txHash
func GetTransactionHandler(
senderShardID uint32,
Expand Down
4 changes: 4 additions & 0 deletions process/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ type BlockChainHookHandler interface {
CurrentTimeStamp() uint64
CurrentRandomSeed() []byte
CurrentEpoch() uint32
RoundTime() uint64
EpochStartBlockNonce() uint64
EpochStartBlockRound() uint64
EpochStartBlockTimeStamp() uint64
NewAddress(creatorAddress []byte, creatorNonce uint64, vmType []byte) ([]byte, error)
ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
SaveNFTMetaDataToSystemAccount(tx data.TransactionHandler) error
Expand Down
Loading
Loading