Search in sources :

Example 1 with DeterministicNetwork

use of com.radixdlt.environment.deterministic.network.DeterministicNetwork in project radixdlt by radixdlt.

the class RecoveryLivenessTest method setup.

@Before
public void setup() {
    this.messageMutator = MessageMutator.nothing();
    this.network = new DeterministicNetwork(nodeKeys.stream().map(k -> BFTNode.create(k.getPublicKey())).toList(), MessageSelector.firstSelector(), this::mutate);
    var allNodes = nodeKeys.stream().map(k -> BFTNode.create(k.getPublicKey())).toList();
    this.nodeCreators = nodeKeys.stream().<Supplier<Injector>>map(k -> () -> createRunner(k, allNodes)).toList();
    for (Supplier<Injector> nodeCreator : nodeCreators) {
        this.nodes.add(nodeCreator.get());
    }
    this.nodes.forEach(i -> i.getInstance(DeterministicProcessor.class).start());
}
Also used : ControlledMessage(com.radixdlt.environment.deterministic.network.ControlledMessage) RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) Timed(io.reactivex.rxjava3.schedulers.Timed) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Key(com.google.inject.Key) PersistedNodeForTestingModule(com.radixdlt.PersistedNodeForTestingModule) EpochView(com.radixdlt.consensus.epoch.EpochView) FeeTable(com.radixdlt.application.system.FeeTable) After(org.junit.After) MSG(com.radixdlt.constraintmachine.REInstruction.REMicroOp.MSG) View(com.radixdlt.consensus.bft.View) Parameterized(org.junit.runners.Parameterized) ThreadContext(org.apache.logging.log4j.ThreadContext) DatabaseEnvironment(com.radixdlt.store.DatabaseEnvironment) PersistentSafetyStateStore(com.radixdlt.consensus.safety.PersistentSafetyStateStore) Collection(java.util.Collection) Set(java.util.Set) LastEventsModule(com.radixdlt.environment.deterministic.LastEventsModule) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) KeyComparator(com.radixdlt.utils.KeyComparator) Optional(java.util.Optional) Amount(com.radixdlt.application.tokens.Amount) Pattern(java.util.regex.Pattern) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) TypeLiteral(com.google.inject.TypeLiteral) SyncCheckTrigger(com.radixdlt.sync.messages.local.SyncCheckTrigger) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) OptionalInt(java.util.OptionalInt) Supplier(java.util.function.Supplier) DeterministicNetwork(com.radixdlt.environment.deterministic.network.DeterministicNetwork) EpochViewUpdate(com.radixdlt.consensus.epoch.EpochViewUpdate) ArrayList(java.util.ArrayList) MockedGenesisModule(com.radixdlt.statecomputer.checkpoint.MockedGenesisModule) ClassToInstanceMap(com.google.common.collect.ClassToInstanceMap) ImmutableList(com.google.common.collect.ImmutableList) DatabaseLocation(com.radixdlt.store.DatabaseLocation) MessageSelector(com.radixdlt.environment.deterministic.network.MessageSelector) MempoolConfig(com.radixdlt.mempool.MempoolConfig) RERulesConfig(com.radixdlt.statecomputer.forks.RERulesConfig) MessageQueue(com.radixdlt.environment.deterministic.network.MessageQueue) BerkeleyLedgerEntryStore(com.radixdlt.store.berkeley.BerkeleyLedgerEntryStore) Before(org.junit.Before) EventDispatcher(com.radixdlt.environment.EventDispatcher) Environment(com.radixdlt.environment.Environment) Test(org.junit.Test) DeterministicProcessor(com.radixdlt.environment.deterministic.DeterministicProcessor) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) Injector(com.google.inject.Injector) Provides(com.google.inject.Provides) ECKeyPair(com.radixdlt.crypto.ECKeyPair) Rule(org.junit.Rule) Self(com.radixdlt.consensus.bft.Self) Guice(com.google.inject.Guice) BFTNode(com.radixdlt.consensus.bft.BFTNode) MessageMutator(com.radixdlt.environment.deterministic.network.MessageMutator) PeersView(com.radixdlt.network.p2p.PeersView) Comparator(java.util.Comparator) LogManager(org.apache.logging.log4j.LogManager) TemporaryFolder(org.junit.rules.TemporaryFolder) AbstractModule(com.google.inject.AbstractModule) DeterministicNetwork(com.radixdlt.environment.deterministic.network.DeterministicNetwork) Injector(com.google.inject.Injector) Supplier(java.util.function.Supplier) Before(org.junit.Before)

Example 2 with DeterministicNetwork

use of com.radixdlt.environment.deterministic.network.DeterministicNetwork in project radixdlt by radixdlt.

the class DeterministicActorsTest method setup.

@SuppressWarnings("UnstableApiUsage")
@Before
public void setup() {
    var allNodes = nodeKeys.stream().map(k -> BFTNode.create(k.getPublicKey())).toList();
    this.network = new DeterministicNetwork(allNodes, MessageSelector.firstSelector(), MessageMutator.nothing());
    var nodeCreators = Streams.mapWithIndex(nodeKeys.stream(), (k, i) -> (Supplier<Injector>) () -> createRunner(i == 1, k, allNodes)).toList();
    deterministicRunner = new MultiNodeDeterministicRunner(nodeCreators, this::stopDatabase, network);
    deterministicRunner.start();
}
Also used : Module(com.google.inject.Module) Key(com.google.inject.Key) BerkeleyAdditionalStore(com.radixdlt.store.berkeley.BerkeleyAdditionalStore) PersistedNodeForTestingModule(com.radixdlt.PersistedNodeForTestingModule) After(org.junit.After) DatabaseEnvironment(com.radixdlt.store.DatabaseEnvironment) PersistentSafetyStateStore(com.radixdlt.consensus.safety.PersistentSafetyStateStore) Streams(com.google.common.collect.Streams) Multibinder(com.google.inject.multibindings.Multibinder) LastEventsModule(com.radixdlt.environment.deterministic.LastEventsModule) Collectors(java.util.stream.Collectors) Logger(org.apache.logging.log4j.Logger) InvalidProposedTxn(com.radixdlt.statecomputer.InvalidProposedTxn) Amount(com.radixdlt.application.tokens.Amount) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) NetworkId(com.radixdlt.networks.NetworkId) java.util(java.util) Modules(com.google.inject.util.Modules) SyncCheckTrigger(com.radixdlt.sync.messages.local.SyncCheckTrigger) Supplier(java.util.function.Supplier) DeterministicNetwork(com.radixdlt.environment.deterministic.network.DeterministicNetwork) MockedGenesisModule(com.radixdlt.statecomputer.checkpoint.MockedGenesisModule) ImmutableList(com.google.common.collect.ImmutableList) DatabaseLocation(com.radixdlt.store.DatabaseLocation) MessageSelector(com.radixdlt.environment.deterministic.network.MessageSelector) MempoolConfig(com.radixdlt.mempool.MempoolConfig) EvictingQueue(com.google.common.collect.EvictingQueue) BerkeleyLedgerEntryStore(com.radixdlt.store.berkeley.BerkeleyLedgerEntryStore) BerkeleyRecoverableProcessedTxnStore(com.radixdlt.api.core.reconstruction.BerkeleyRecoverableProcessedTxnStore) Before(org.junit.Before) PrivateKeys(com.radixdlt.utils.PrivateKeys) EventDispatcher(com.radixdlt.environment.EventDispatcher) Network(com.radixdlt.networks.Network) Environment(com.radixdlt.environment.Environment) Test(org.junit.Test) MempoolRelayTrigger(com.radixdlt.mempool.MempoolRelayTrigger) Scopes(com.google.inject.Scopes) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) Injector(com.google.inject.Injector) LedgerUpdate(com.radixdlt.ledger.LedgerUpdate) Provides(com.google.inject.Provides) ECKeyPair(com.radixdlt.crypto.ECKeyPair) Rule(org.junit.Rule) Self(com.radixdlt.consensus.bft.Self) FailOnEvent(com.radixdlt.harness.FailOnEvent) Guice(com.google.inject.Guice) BFTNode(com.radixdlt.consensus.bft.BFTNode) MultiNodeDeterministicRunner(com.radixdlt.environment.deterministic.MultiNodeDeterministicRunner) MessageMutator(com.radixdlt.environment.deterministic.network.MessageMutator) PeersView(com.radixdlt.network.p2p.PeersView) LogManager(org.apache.logging.log4j.LogManager) TemporaryFolder(org.junit.rules.TemporaryFolder) AbstractModule(com.google.inject.AbstractModule) MultiNodeDeterministicRunner(com.radixdlt.environment.deterministic.MultiNodeDeterministicRunner) DeterministicNetwork(com.radixdlt.environment.deterministic.network.DeterministicNetwork) Supplier(java.util.function.Supplier) Before(org.junit.Before)

Example 3 with DeterministicNetwork

use of com.radixdlt.environment.deterministic.network.DeterministicNetwork in project radixdlt by radixdlt.

the class OneNodeAlwaysAliveSafetyTest method setup.

@Before
public void setup() {
    var allNodes = nodeKeys.stream().map(k -> BFTNode.create(k.getPublicKey())).toList();
    this.network = new DeterministicNetwork(allNodes, MessageSelector.firstSelector(), (message, queue) -> message.message() instanceof GetVerticesRequest || message.message() instanceof LocalSyncRequest);
    Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(new TypeLiteral<List<BFTNode>>() {
            }).toInstance(allNodes);
        }

        @ProvidesIntoSet
        public NodeEventProcessor<?> updateChecker() {
            return new NodeEventProcessor<>(ViewQuorumReached.class, (node, viewQuorumReached) -> {
                if (viewQuorumReached.votingResult() instanceof FormedQC && ((FormedQC) viewQuorumReached.votingResult()).getQC().getCommitted().isPresent()) {
                    lastNodeToCommit = network.lookup(node);
                }
            });
        }
    }, new SafetyCheckerModule(), new NodeEventsModule()).injectMembers(this);
    this.nodeCreators = nodeKeys.stream().<Supplier<Injector>>map(k -> () -> createRunner(k, allNodes)).toList();
    for (var nodeCreator : nodeCreators) {
        this.nodes.add(nodeCreator.get());
    }
}
Also used : GetVerticesRequest(com.radixdlt.consensus.sync.GetVerticesRequest) RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) Inject(com.google.inject.Inject) Key(com.google.inject.Key) BFTCommittedUpdate(com.radixdlt.consensus.bft.BFTCommittedUpdate) PersistedNodeForTestingModule(com.radixdlt.PersistedNodeForTestingModule) EventProcessor(com.radixdlt.environment.EventProcessor) FeeTable(com.radixdlt.application.system.FeeTable) After(org.junit.After) ViewQuorumReached(com.radixdlt.consensus.bft.ViewQuorumReached) MSG(com.radixdlt.constraintmachine.REInstruction.REMicroOp.MSG) NodeEvents(com.radixdlt.harness.deterministic.NodeEvents) Parameterized(org.junit.runners.Parameterized) ThreadContext(org.apache.logging.log4j.ThreadContext) ProvidesIntoSet(com.google.inject.multibindings.ProvidesIntoSet) DatabaseEnvironment(com.radixdlt.store.DatabaseEnvironment) PersistentSafetyStateStore(com.radixdlt.consensus.safety.PersistentSafetyStateStore) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) KeyComparator(com.radixdlt.utils.KeyComparator) NodeEventsModule(com.radixdlt.harness.deterministic.NodeEventsModule) Amount(com.radixdlt.application.tokens.Amount) Pattern(java.util.regex.Pattern) ProcessOnDispatch(com.radixdlt.environment.ProcessOnDispatch) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) TypeLiteral(com.google.inject.TypeLiteral) SafetyCheckerModule(com.radixdlt.harness.deterministic.SafetyCheckerModule) FormedQC(com.radixdlt.consensus.bft.ViewVotingResult.FormedQC) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) Proposal(com.radixdlt.consensus.Proposal) OptionalInt(java.util.OptionalInt) Supplier(java.util.function.Supplier) DeterministicNetwork(com.radixdlt.environment.deterministic.network.DeterministicNetwork) ArrayList(java.util.ArrayList) MockedGenesisModule(com.radixdlt.statecomputer.checkpoint.MockedGenesisModule) LocalSyncRequest(com.radixdlt.sync.messages.local.LocalSyncRequest) DatabaseLocation(com.radixdlt.store.DatabaseLocation) MessageSelector(com.radixdlt.environment.deterministic.network.MessageSelector) MempoolConfig(com.radixdlt.mempool.MempoolConfig) RERulesConfig(com.radixdlt.statecomputer.forks.RERulesConfig) BerkeleyLedgerEntryStore(com.radixdlt.store.berkeley.BerkeleyLedgerEntryStore) Before(org.junit.Before) EventProcessorOnDispatch(com.radixdlt.environment.EventProcessorOnDispatch) Environment(com.radixdlt.environment.Environment) Test(org.junit.Test) DeterministicProcessor(com.radixdlt.environment.deterministic.DeterministicProcessor) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) Injector(com.google.inject.Injector) ECKeyPair(com.radixdlt.crypto.ECKeyPair) Rule(org.junit.Rule) Self(com.radixdlt.consensus.bft.Self) NodeEventProcessor(com.radixdlt.harness.deterministic.NodeEvents.NodeEventProcessor) Guice(com.google.inject.Guice) BFTNode(com.radixdlt.consensus.bft.BFTNode) PeersView(com.radixdlt.network.p2p.PeersView) Comparator(java.util.Comparator) LogManager(org.apache.logging.log4j.LogManager) TemporaryFolder(org.junit.rules.TemporaryFolder) AbstractModule(com.google.inject.AbstractModule) BFTNode(com.radixdlt.consensus.bft.BFTNode) GetVerticesRequest(com.radixdlt.consensus.sync.GetVerticesRequest) LocalSyncRequest(com.radixdlt.sync.messages.local.LocalSyncRequest) DeterministicNetwork(com.radixdlt.environment.deterministic.network.DeterministicNetwork) FormedQC(com.radixdlt.consensus.bft.ViewVotingResult.FormedQC) AbstractModule(com.google.inject.AbstractModule) SafetyCheckerModule(com.radixdlt.harness.deterministic.SafetyCheckerModule) TypeLiteral(com.google.inject.TypeLiteral) Supplier(java.util.function.Supplier) NodeEventsModule(com.radixdlt.harness.deterministic.NodeEventsModule) NodeEventProcessor(com.radixdlt.harness.deterministic.NodeEvents.NodeEventProcessor) Before(org.junit.Before)

Aggregations

AbstractModule (com.google.inject.AbstractModule)3 Guice (com.google.inject.Guice)3 Injector (com.google.inject.Injector)3 Key (com.google.inject.Key)3 PersistedNodeForTestingModule (com.radixdlt.PersistedNodeForTestingModule)3 Amount (com.radixdlt.application.tokens.Amount)3 BFTNode (com.radixdlt.consensus.bft.BFTNode)3 Self (com.radixdlt.consensus.bft.Self)3 PersistentSafetyStateStore (com.radixdlt.consensus.safety.PersistentSafetyStateStore)3 ECKeyPair (com.radixdlt.crypto.ECKeyPair)3 Environment (com.radixdlt.environment.Environment)3 DeterministicNetwork (com.radixdlt.environment.deterministic.network.DeterministicNetwork)3 MessageSelector (com.radixdlt.environment.deterministic.network.MessageSelector)3 MempoolConfig (com.radixdlt.mempool.MempoolConfig)3 PeersView (com.radixdlt.network.p2p.PeersView)3 MockedGenesisModule (com.radixdlt.statecomputer.checkpoint.MockedGenesisModule)3 ForksModule (com.radixdlt.statecomputer.forks.ForksModule)3 MainnetForkConfigsModule (com.radixdlt.statecomputer.forks.MainnetForkConfigsModule)3 DatabaseEnvironment (com.radixdlt.store.DatabaseEnvironment)3 DatabaseLocation (com.radixdlt.store.DatabaseLocation)3