Skip to content

Commit a30a28c

Browse files
author
Leonor Boga
committed
ETCM-944 Pass getBlockHashByNumber field directly to InMemoryWorldStateProxy
1 parent b92da8a commit a30a28c

20 files changed

+29
-29
lines changed

src/it/scala/io/iohk/ethereum/ledger/BlockImporterItSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class BlockImporterItSpec
6262
val emptyWorld = InMemoryWorldStateProxy(
6363
storagesInstance.storages.evmCodeStorage,
6464
blockchain.getBackingStorage(-1),
65-
blockchain,
65+
(number: BigInt) => blockchain.getBlockHeaderByNumber(number).map(_.hash),
6666
blockchainConfig.accountStartNonce,
6767
ByteString(MerklePatriciaTrie.EmptyRootHash),
6868
noEmptyAccounts = false,

src/it/scala/io/iohk/ethereum/sync/util/CommonFakePeer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
244244
InMemoryWorldStateProxy(
245245
storagesInstance.storages.evmCodeStorage,
246246
bl.getBackingStorage(block.number),
247-
bl,
247+
(number: BigInt) => bl.getBlockHeaderByNumber(number).map(_.hash),
248248
blockchainConfig.accountStartNonce,
249249
block.header.stateRoot,
250250
noEmptyAccounts = EvmConfig.forBlock(block.number, blockchainConfig).noEmptyAccounts,

src/it/scala/io/iohk/ethereum/sync/util/RegularSyncItSpecUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ object RegularSyncItSpecUtils {
215215
InMemoryWorldStateProxy(
216216
storagesInstance.storages.evmCodeStorage,
217217
bl.getBackingStorage(block.number),
218-
bl,
218+
(number: BigInt) => bl.getBlockHeaderByNumber(number).map(_.hash),
219219
UInt256.Zero,
220220
ByteString(MerklePatriciaTrie.EmptyRootHash),
221221
noEmptyAccounts = false,

src/main/resources/conf/base.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ mantis {
386386
nodes-per-request = 384
387387

388388
# Minimum number of peers required to start fast-sync (by determining the pivot block)
389-
min-peers-to-choose-pivot-block = 3
389+
min-peers-to-choose-pivot-block = 1
390390

391391
# Number of additional peers used to determine pivot block during fast-sync
392392
# Number of peers used to reach consensus = min-peers-to-choose-pivot-block + peers-to-choose-pivot-block-margin

src/main/scala/io/iohk/ethereum/jsonrpc/EthUserService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class EthUserService(
3535
val world = InMemoryWorldStateProxy(
3636
evmCodeStorage,
3737
blockchain.getBackingStorage(block.header.number),
38-
blockchain,
38+
(number: BigInt) => blockchain.getBlockHeaderByNumber(number).map(_.hash),
3939
blockchainConfig.accountStartNonce,
4040
block.header.stateRoot,
4141
noEmptyAccounts = false,

src/main/scala/io/iohk/ethereum/ledger/BlockExecution.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class BlockExecution(
6565
initialWorld = InMemoryWorldStateProxy(
6666
evmCodeStorage = evmCodeStorage,
6767
blockchain.getBackingStorage(block.header.number),
68-
blockchain,
68+
(number: BigInt) => blockchain.getBlockHeaderByNumber(number).map(_.hash),
6969
accountStartNonce = blockchainConfig.accountStartNonce,
7070
stateRootHash = parentHeader.stateRoot,
7171
noEmptyAccounts = EvmConfig.forBlock(parentHeader.number, blockchainConfig).noEmptyAccounts,

src/main/scala/io/iohk/ethereum/ledger/BlockPreparator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ class BlockPreparator(
382382
InMemoryWorldStateProxy(
383383
evmCodeStorage = evmCodeStorage,
384384
mptStorage = blockchain.getReadOnlyStorage(),
385-
blockchain = blockchain,
385+
getBlockHashByNumber = (number: BigInt) => blockchain.getBlockHeaderByNumber(number).map(_.hash),
386386
accountStartNonce = blockchainConfig.accountStartNonce,
387387
stateRootHash = parent.stateRoot,
388388
noEmptyAccounts = EvmConfig.forBlock(block.header.number, blockchainConfig).noEmptyAccounts,

src/main/scala/io/iohk/ethereum/ledger/InMemoryWorldStateProxy.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object InMemoryWorldStateProxy {
1616
def apply(
1717
evmCodeStorage: EvmCodeStorage,
1818
mptStorage: MptStorage,
19-
blockchain: Blockchain,
19+
getBlockHashByNumber: BigInt => Option[ByteString],
2020
accountStartNonce: UInt256,
2121
stateRootHash: ByteString,
2222
noEmptyAccounts: Boolean,
@@ -25,7 +25,7 @@ object InMemoryWorldStateProxy {
2525
evmCodeStorage,
2626
mptStorage,
2727
accountStartNonce,
28-
(number: BigInt) => blockchain.getBlockHeaderByNumber(number).map(_.hash),
28+
getBlockHashByNumber,
2929
stateRootHash,
3030
noEmptyAccounts,
3131
ethCompatibleStorage

src/main/scala/io/iohk/ethereum/ledger/StxLedger.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class StxLedger(
2424
InMemoryWorldStateProxy(
2525
evmCodeStorage = evmCodeStorage,
2626
mptStorage = blockchain.getReadOnlyStorage(),
27-
blockchain = blockchain,
27+
getBlockHashByNumber = (number: BigInt) => blockchain.getBlockHeaderByNumber(number).map(_.hash),
2828
accountStartNonce = blockchainConfig.accountStartNonce,
2929
stateRootHash = blockHeader.stateRoot,
3030
noEmptyAccounts = EvmConfig.forBlock(blockHeader.number, blockchainConfig).noEmptyAccounts,

src/test/scala/io/iohk/ethereum/blockchain/sync/StateSyncUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ object StateSyncUtils extends EphemBlockchainTestSetup {
3535
val init = InMemoryWorldStateProxy(
3636
evmCodeStorage,
3737
blockchain.getBackingStorage(1),
38-
blockchain,
38+
(number: BigInt) => blockchain.getBlockHeaderByNumber(number).map(_.hash),
3939
blockchainConfig.accountStartNonce,
4040
existingTree.getOrElse(ByteString(MerklePatriciaTrie.EmptyRootHash)),
4141
noEmptyAccounts = true,

0 commit comments

Comments
 (0)