Search in sources :

Example 1 with LegacyPrivateStateStorage

use of org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateStorage in project besu by hyperledger.

the class PrivateStorageMigrationBuilder method build.

public PrivateStorageMigration build() {
    final Blockchain blockchain = besuController.getProtocolContext().getBlockchain();
    final Address privacyPrecompileAddress = privacyParameters.getPrivacyAddress();
    final ProtocolSchedule protocolSchedule = besuController.getProtocolSchedule();
    final WorldStateArchive publicWorldStateArchive = besuController.getProtocolContext().getWorldStateArchive();
    final PrivateStateStorage privateStateStorage = privacyParameters.getPrivateStateStorage();
    final LegacyPrivateStateStorage legacyPrivateStateStorage = privacyParameters.getPrivateStorageProvider().createLegacyPrivateStateStorage();
    final PrivateStateRootResolver privateStateRootResolver = privacyParameters.getPrivateStateRootResolver();
    return new PrivateStorageMigration(blockchain, privacyPrecompileAddress, protocolSchedule, publicWorldStateArchive, privateStateStorage, privateStateRootResolver, legacyPrivateStateStorage, PrivateMigrationBlockProcessor::new);
}
Also used : Address(org.hyperledger.besu.datatypes.Address) WorldStateArchive(org.hyperledger.besu.ethereum.worldstate.WorldStateArchive) PrivateStorageMigration(org.hyperledger.besu.ethereum.privacy.storage.migration.PrivateStorageMigration) Blockchain(org.hyperledger.besu.ethereum.chain.Blockchain) PrivateStateRootResolver(org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver) PrivateMigrationBlockProcessor(org.hyperledger.besu.ethereum.privacy.storage.migration.PrivateMigrationBlockProcessor) ProtocolSchedule(org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule) LegacyPrivateStateStorage(org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateStorage) PrivateStateStorage(org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage) LegacyPrivateStateStorage(org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateStorage)

Example 2 with LegacyPrivateStateStorage

use of org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateStorage in project besu by hyperledger.

the class PrivateStorageMigrationTest method setUp.

@Before
public void setUp() {
    final KeyValueStorage kvStorage = new InMemoryKeyValueStorage();
    privateStateStorage = new PrivateStateKeyValueStorage(kvStorage);
    privateStateRootResolver = new PrivateStateRootResolver(privateStateStorage);
    lenient().when(protocolSchedule.getByBlockNumber(anyLong())).thenReturn(protocolSpec);
    lenient().when(protocolSpec.getTransactionProcessor()).thenReturn(transactionProcessor);
    lenient().when(protocolSpec.getTransactionReceiptFactory()).thenReturn(transactionReceiptFactory);
    lenient().when(protocolSpec.getBlockReward()).thenReturn(Wei.ZERO);
    lenient().when(protocolSpec.getMiningBeneficiaryCalculator()).thenReturn(miningBeneficiaryCalculator);
    lenient().when(protocolSpec.isSkipZeroBlockRewards()).thenReturn(false);
    migration = new PrivateStorageMigration(blockchain, PRIVACY_ADDRESS, protocolSchedule, publicWorldStateArchive, privateStateStorage, privateStateRootResolver, legacyPrivateStateStorage, (protocolSpec) -> privateMigrationBlockProcessor);
}
Also used : PrivateStateRootResolver(org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver) Arrays(java.util.Arrays) PrivateTransactionMetadata(org.hyperledger.besu.ethereum.privacy.storage.PrivateTransactionMetadata) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) BlockDataGenerator(org.hyperledger.besu.ethereum.core.BlockDataGenerator) DEFAULT_PRIVACY(org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY) Map(java.util.Map) BigInteger(java.math.BigInteger) Block(org.hyperledger.besu.ethereum.core.Block) Bytes32(org.apache.tuweni.bytes.Bytes32) Blockchain(org.hyperledger.besu.ethereum.chain.Blockchain) List(java.util.List) PrivateBlockMetadata(org.hyperledger.besu.ethereum.privacy.storage.PrivateBlockMetadata) InMemoryKeyValueStorage(org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage) Optional(java.util.Optional) ProtocolSpec(org.hyperledger.besu.ethereum.mainnet.ProtocolSpec) TransactionType(org.hyperledger.besu.plugin.data.TransactionType) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Hash(org.hyperledger.besu.datatypes.Hash) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) EMPTY_ROOT_HASH(org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver.EMPTY_ROOT_HASH) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) Bytes(org.apache.tuweni.bytes.Bytes) Mockito.lenient(org.mockito.Mockito.lenient) Address(org.hyperledger.besu.datatypes.Address) ArrayList(java.util.ArrayList) TransactionReceiptFactory(org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor.TransactionReceiptFactory) ProtocolSchedule(org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule) SCHEMA_VERSION_1_0_0(org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage.SCHEMA_VERSION_1_0_0) ArgumentCaptor(org.mockito.ArgumentCaptor) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) SCHEMA_VERSION_1_4_0(org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage.SCHEMA_VERSION_1_4_0) WorldStateArchive(org.hyperledger.besu.ethereum.worldstate.WorldStateArchive) Wei(org.hyperledger.besu.datatypes.Wei) Before(org.junit.Before) PrivateTransactionDataFixture.privateMarkerTransaction(org.hyperledger.besu.ethereum.core.PrivateTransactionDataFixture.privateMarkerTransaction) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) MutableWorldState(org.hyperledger.besu.ethereum.core.MutableWorldState) MainnetTransactionProcessor(org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor) PrivateStateStorage(org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) SignatureAlgorithmFactory(org.hyperledger.besu.crypto.SignatureAlgorithmFactory) PrivateStateKeyValueStorage(org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage) Mockito.verify(org.mockito.Mockito.verify) LegacyPrivateStateStorage(org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateStorage) KeyValueStorage(org.hyperledger.besu.plugin.services.storage.KeyValueStorage) MiningBeneficiaryCalculator(org.hyperledger.besu.ethereum.mainnet.MiningBeneficiaryCalculator) Transaction(org.hyperledger.besu.ethereum.core.Transaction) PrivacyGroupHeadBlockMap(org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap) InMemoryKeyValueStorage(org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage) InMemoryKeyValueStorage(org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage) PrivateStateKeyValueStorage(org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage) KeyValueStorage(org.hyperledger.besu.plugin.services.storage.KeyValueStorage) PrivateStateRootResolver(org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver) PrivateStateKeyValueStorage(org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage) Before(org.junit.Before)

Aggregations

Address (org.hyperledger.besu.datatypes.Address)2 Blockchain (org.hyperledger.besu.ethereum.chain.Blockchain)2 ProtocolSchedule (org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule)2 PrivateStateRootResolver (org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver)2 LegacyPrivateStateStorage (org.hyperledger.besu.ethereum.privacy.storage.LegacyPrivateStateStorage)2 PrivateStateStorage (org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage)2 WorldStateArchive (org.hyperledger.besu.ethereum.worldstate.WorldStateArchive)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bytes (org.apache.tuweni.bytes.Bytes)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)1 SignatureAlgorithmFactory (org.hyperledger.besu.crypto.SignatureAlgorithmFactory)1 Hash (org.hyperledger.besu.datatypes.Hash)1 Wei (org.hyperledger.besu.datatypes.Wei)1