Search in sources :

Example 1 with MainnetForkConfigsModule

use of com.radixdlt.statecomputer.forks.MainnetForkConfigsModule in project radixdlt by radixdlt.

the class ApiTest method setup.

@Before
public void setup() {
    var injector = Guice.createInjector(MempoolConfig.asModule(mempoolMaxSize, 10), new MainnetForkConfigsModule(), new RadixEngineForksLatestOnlyModule(RERulesConfig.testingDefault().overrideFeeTable(FeeTable.create(Amount.ofSubunits(UInt256.ONE), Map.of(ValidatorRegisteredCopy.class, Amount.ofSubunits(UInt256.ONE))))), new ForksModule(), new SingleNodeAndPeersDeterministicNetworkModule(TEST_KEY, 1), new MockedGenesisModule(Set.of(TEST_KEY.getPublicKey()), totalTokenAmount, stakeAmount), new AbstractModule() {

        @Override
        protected void configure() {
            bind(BerkeleyRecoverableProcessedTxnStore.class).in(Scopes.SINGLETON);
            Multibinder.newSetBinder(binder(), BerkeleyAdditionalStore.class).addBinding().to(BerkeleyRecoverableProcessedTxnStore.class);
            bindConstant().annotatedWith(DatabaseLocation.class).to(folder.getRoot().getAbsolutePath());
            bindConstant().annotatedWith(NetworkId.class).to(99);
            bind(P2PConfig.class).toInstance(mock(P2PConfig.class));
            bind(AddressBook.class).in(Scopes.SINGLETON);
            var selfUri = RadixNodeUri.fromPubKeyAndAddress(99, TEST_KEY.getPublicKey(), "localhost", 23456);
            bind(RadixNodeUri.class).annotatedWith(Self.class).toInstance(selfUri);
            var addressBookPersistence = mock(AddressBookPersistence.class);
            when(addressBookPersistence.getAllEntries()).thenReturn(ImmutableList.of());
            bind(AddressBookPersistence.class).toInstance(addressBookPersistence);
            var runtimeProperties = mock(RuntimeProperties.class);
            when(runtimeProperties.get(eq("api.transactions.enable"), anyBoolean())).thenReturn(true);
            bind(RuntimeProperties.class).toInstance(runtimeProperties);
        }
    });
    injector.injectMembers(this);
}
Also used : SingleNodeAndPeersDeterministicNetworkModule(com.radixdlt.SingleNodeAndPeersDeterministicNetworkModule) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) AddressBookPersistence(com.radixdlt.network.p2p.addressbook.AddressBookPersistence) BerkeleyAdditionalStore(com.radixdlt.store.berkeley.BerkeleyAdditionalStore) RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) AbstractModule(com.google.inject.AbstractModule) BerkeleyRecoverableProcessedTxnStore(com.radixdlt.api.core.reconstruction.BerkeleyRecoverableProcessedTxnStore) MockedGenesisModule(com.radixdlt.statecomputer.checkpoint.MockedGenesisModule) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) RadixNodeUri(com.radixdlt.network.p2p.RadixNodeUri) RuntimeProperties(com.radixdlt.properties.RuntimeProperties) Before(org.junit.Before)

Example 2 with MainnetForkConfigsModule

use of com.radixdlt.statecomputer.forks.MainnetForkConfigsModule in project radixdlt by radixdlt.

the class RadixNodeModule method configure.

@Override
protected void configure() {
    if (this.networkId <= 0) {
        throw new IllegalStateException("Illegal networkId " + networkId);
    }
    bind(Addressing.class).toInstance(Addressing.ofNetworkId(networkId));
    bindConstant().annotatedWith(NetworkId.class).to(networkId);
    bind(Txn.class).annotatedWith(Genesis.class).toInstance(loadGenesis(networkId));
    if (networkId == Network.MAINNET.getId()) {
        install(new MainnetForkConfigsModule());
    } else {
        install(new StokenetForkConfigsModule());
    }
    bind(RuntimeProperties.class).toInstance(properties);
    // Consensus configuration
    // These cannot be changed without introducing possibilities of
    // going out of sync with consensus.
    bindConstant().annotatedWith(BFTSyncPatienceMillis.class).to(properties.get("bft.sync.patience", 200));
    // Default values mean that pacemakers will sync if they are within 5 views of each other.
    // 5 consecutive failing views will take 1*(2^6)-1 seconds = 63 seconds.
    bindConstant().annotatedWith(PacemakerTimeout.class).to(3000L);
    bindConstant().annotatedWith(PacemakerRate.class).to(1.1);
    bindConstant().annotatedWith(PacemakerMaxExponent.class).to(0);
    // Mempool configuration
    var mempoolMaxSize = properties.get("mempool.maxSize", 10000);
    install(MempoolConfig.asModule(mempoolMaxSize, 5, 60000, 60000, 100));
    // Sync configuration
    final long syncPatience = properties.get("sync.patience", 5000L);
    bind(SyncConfig.class).toInstance(SyncConfig.of(syncPatience, 10, 3000L));
    // System (e.g. time, random)
    install(new SystemModule());
    install(new RxEnvironmentModule());
    install(new EventLoggerModule());
    install(new DispatcherModule());
    // Consensus
    install(new PersistedBFTKeyModule());
    install(new CryptoModule());
    install(new ConsensusModule());
    // Ledger
    install(new LedgerModule());
    install(new MempoolReceiverModule());
    // Mempool Relay
    install(new MempoolRelayerModule());
    // Sync
    install(new SyncServiceModule());
    // Epochs - Consensus
    install(new EpochsConsensusModule());
    // Epochs - Sync
    install(new EpochsSyncModule());
    // State Computer
    install(new ForksModule());
    if (properties.get("overwrite_forks.enable", false)) {
        log.info("Enabling fork overwrites");
        install(new ForkOverwritesFromPropertiesModule());
    }
    install(new RadixEngineStateComputerModule());
    install(new RadixEngineModule());
    install(new RadixEngineStoreModule());
    // Checkpoints
    install(new RadixEngineCheckpointModule());
    // Storage
    install(new DatabasePropertiesModule());
    install(new PersistenceModule());
    install(new ConsensusRecoveryModule());
    install(new LedgerRecoveryModule());
    // System Info
    install(new SystemInfoModule());
    // Network
    install(new MessagingModule());
    install(new MessageCentralModule(properties));
    install(new HostIpModule(properties));
    install(new P2PModule(properties));
    install(new PeerDiscoveryModule());
    install(new PeerLivenessMonitorModule());
    // API
    var bindAddress = properties.get("api.bind.address", DEFAULT_BIND_ADDRESS);
    var port = properties.get("api.port", DEFAULT_CORE_PORT);
    var enableTransactions = properties.get("api.transactions.enable", false);
    var enableSign = properties.get("api.sign.enable", false);
    install(new ApiModule(bindAddress, port, enableTransactions, enableSign));
}
Also used : RadixEngineModule(com.radixdlt.statecomputer.RadixEngineModule) ApiModule(com.radixdlt.api.ApiModule) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) RadixEngineStateComputerModule(com.radixdlt.statecomputer.RadixEngineStateComputerModule) SyncConfig(com.radixdlt.sync.SyncConfig) Addressing(com.radixdlt.networks.Addressing) MessageCentralModule(com.radixdlt.network.messaging.MessageCentralModule) PacemakerMaxExponent(com.radixdlt.consensus.bft.PacemakerMaxExponent) PacemakerRate(com.radixdlt.consensus.bft.PacemakerRate) StokenetForkConfigsModule(com.radixdlt.statecomputer.forks.StokenetForkConfigsModule) HostIpModule(com.radixdlt.network.hostip.HostIpModule) RuntimeProperties(com.radixdlt.properties.RuntimeProperties) PeerLivenessMonitorModule(com.radixdlt.network.p2p.PeerLivenessMonitorModule) BFTSyncPatienceMillis(com.radixdlt.consensus.sync.BFTSyncPatienceMillis) PacemakerTimeout(com.radixdlt.consensus.bft.PacemakerTimeout) PersistenceModule(com.radixdlt.store.PersistenceModule) NetworkId(com.radixdlt.networks.NetworkId) RxEnvironmentModule(com.radixdlt.environment.rx.RxEnvironmentModule) DatabasePropertiesModule(com.radixdlt.store.DatabasePropertiesModule) MempoolRelayerModule(com.radixdlt.mempool.MempoolRelayerModule) MessagingModule(com.radixdlt.network.messaging.MessagingModule) ForkOverwritesFromPropertiesModule(com.radixdlt.statecomputer.forks.ForkOverwritesFromPropertiesModule) RadixEngineCheckpointModule(com.radixdlt.statecomputer.checkpoint.RadixEngineCheckpointModule) Genesis(com.radixdlt.statecomputer.checkpoint.Genesis) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) P2PModule(com.radixdlt.network.p2p.P2PModule) PeerDiscoveryModule(com.radixdlt.network.p2p.PeerDiscoveryModule) PersistedBFTKeyModule(com.radixdlt.keys.PersistedBFTKeyModule) MempoolReceiverModule(com.radixdlt.mempool.MempoolReceiverModule)

Example 3 with MainnetForkConfigsModule

use of com.radixdlt.statecomputer.forks.MainnetForkConfigsModule in project radixdlt by radixdlt.

the class RadixEngineStateComputerTest method getExternalModule.

private Module getExternalModule() {
    return new AbstractModule() {

        @Override
        public void configure() {
            var validatorSet = BFTValidatorSet.from(registeredNodes.stream().map(ECKeyPair::getPublicKey).map(BFTNode::create).map(n -> BFTValidator.from(n, UInt256.ONE)));
            bind(ProposerElection.class).toInstance(new WeightedRotatingLeaders(validatorSet));
            bind(Serialization.class).toInstance(serialization);
            bind(Hasher.class).toInstance(Sha256Hasher.withDefaultSerialization());
            bind(new TypeLiteral<EngineStore<LedgerAndBFTProof>>() {
            }).toInstance(engineStore);
            bind(PersistentVertexStore.class).toInstance(mock(PersistentVertexStore.class));
            install(MempoolConfig.asModule(10, 10));
            install(new MainnetForkConfigsModule());
            install(new ForksModule());
            install(new RadixEngineForksLatestOnlyModule());
            // HACK
            bind(CommittedReader.class).toInstance(CommittedReader.mocked());
            bind(LedgerAccumulator.class).to(SimpleLedgerAccumulatorAndVerifier.class);
            bind(new TypeLiteral<EventDispatcher<MempoolAddSuccess>>() {
            }).toInstance(TypedMocks.rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<InvalidProposedTxn>>() {
            }).toInstance(TypedMocks.rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<TxnsRemovedFromMempool>>() {
            }).toInstance(TypedMocks.rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<REOutput>>() {
            }).toInstance(TypedMocks.rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<MempoolRelayTrigger>>() {
            }).toInstance(TypedMocks.rmock(EventDispatcher.class));
            bind(new TypeLiteral<EventDispatcher<LedgerUpdate>>() {
            }).toInstance(TypedMocks.rmock(EventDispatcher.class));
            bind(SystemCounters.class).to(SystemCountersImpl.class);
        }
    };
}
Also used : Module(com.google.inject.Module) RERules(com.radixdlt.statecomputer.forks.RERules) SimpleLedgerAccumulatorAndVerifier(com.radixdlt.ledger.SimpleLedgerAccumulatorAndVerifier) TxAction(com.radixdlt.atom.TxAction) RadixEngineException(com.radixdlt.engine.RadixEngineException) RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Inject(com.google.inject.Inject) TypedMocks(com.radixdlt.utils.TypedMocks) DefaultSerialization(com.radixdlt.DefaultSerialization) Hasher(com.radixdlt.crypto.Hasher) TimestampedECDSASignatures(com.radixdlt.consensus.TimestampedECDSASignatures) RoundData(com.radixdlt.application.system.state.RoundData) UnverifiedVertex(com.radixdlt.consensus.UnverifiedVertex) ByzantineQuorumException(com.radixdlt.ledger.ByzantineQuorumException) VerifiedTxnsAndProof(com.radixdlt.ledger.VerifiedTxnsAndProof) LedgerProof(com.radixdlt.consensus.LedgerProof) View(com.radixdlt.consensus.bft.View) HashUtils(com.radixdlt.crypto.HashUtils) Genesis(com.radixdlt.statecomputer.checkpoint.Genesis) SystemCounters(com.radixdlt.counters.SystemCounters) WeightedRotatingLeaders(com.radixdlt.consensus.liveness.WeightedRotatingLeaders) Sha256Hasher(com.radixdlt.consensus.Sha256Hasher) REEvent(com.radixdlt.constraintmachine.REEvent) StateComputerResult(com.radixdlt.ledger.StateComputerLedger.StateComputerResult) EngineStore(com.radixdlt.store.EngineStore) Collectors(java.util.stream.Collectors) LedgerHeader(com.radixdlt.consensus.LedgerHeader) ProposerElection(com.radixdlt.consensus.liveness.ProposerElection) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) List(java.util.List) Stream(java.util.stream.Stream) ConstraintMachineException(com.radixdlt.constraintmachine.exceptions.ConstraintMachineException) CommittedReader(com.radixdlt.sync.CommittedReader) Amount(com.radixdlt.application.tokens.Amount) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) TypeLiteral(com.google.inject.TypeLiteral) LedgerAccumulator(com.radixdlt.ledger.LedgerAccumulator) Mockito.mock(org.mockito.Mockito.mock) Serialization(com.radixdlt.serialization.Serialization) PermissionLevel(com.radixdlt.constraintmachine.PermissionLevel) BFTValidatorSet(com.radixdlt.consensus.bft.BFTValidatorSet) com.radixdlt.atom(com.radixdlt.atom) MockedGenesisModule(com.radixdlt.statecomputer.checkpoint.MockedGenesisModule) BFTValidator(com.radixdlt.consensus.bft.BFTValidator) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ImmutableList(com.google.common.collect.ImmutableList) MempoolConfig(com.radixdlt.mempool.MempoolConfig) AccumulatorState(com.radixdlt.ledger.AccumulatorState) RadixEngineCheckpointModule(com.radixdlt.statecomputer.checkpoint.RadixEngineCheckpointModule) UInt256(com.radixdlt.utils.UInt256) Before(org.junit.Before) MempoolAddSuccess(com.radixdlt.mempool.MempoolAddSuccess) EventDispatcher(com.radixdlt.environment.EventDispatcher) HashCode(com.google.common.hash.HashCode) RadixEngine(com.radixdlt.engine.RadixEngine) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) MempoolRelayTrigger(com.radixdlt.mempool.MempoolRelayTrigger) QuorumCertificate(com.radixdlt.consensus.QuorumCertificate) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) LedgerUpdate(com.radixdlt.ledger.LedgerUpdate) BFTHeader(com.radixdlt.consensus.BFTHeader) InMemoryEngineStore(com.radixdlt.store.InMemoryEngineStore) VerifiedVertex(com.radixdlt.consensus.bft.VerifiedVertex) ECKeyPair(com.radixdlt.crypto.ECKeyPair) Rule(org.junit.Rule) Ignore(org.junit.Ignore) Condition(org.assertj.core.api.Condition) Guice(com.google.inject.Guice) BFTNode(com.radixdlt.consensus.bft.BFTNode) PersistentVertexStore(com.radixdlt.consensus.bft.PersistentVertexStore) InvalidPermissionException(com.radixdlt.constraintmachine.exceptions.InvalidPermissionException) TemporaryFolder(org.junit.rules.TemporaryFolder) AbstractModule(com.google.inject.AbstractModule) LedgerUpdate(com.radixdlt.ledger.LedgerUpdate) BFTNode(com.radixdlt.consensus.bft.BFTNode) LedgerAccumulator(com.radixdlt.ledger.LedgerAccumulator) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) SystemCounters(com.radixdlt.counters.SystemCounters) RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) PersistentVertexStore(com.radixdlt.consensus.bft.PersistentVertexStore) AbstractModule(com.google.inject.AbstractModule) DefaultSerialization(com.radixdlt.DefaultSerialization) Serialization(com.radixdlt.serialization.Serialization) Hasher(com.radixdlt.crypto.Hasher) Sha256Hasher(com.radixdlt.consensus.Sha256Hasher) EventDispatcher(com.radixdlt.environment.EventDispatcher) MempoolRelayTrigger(com.radixdlt.mempool.MempoolRelayTrigger) TypeLiteral(com.google.inject.TypeLiteral) CommittedReader(com.radixdlt.sync.CommittedReader) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) MempoolAddSuccess(com.radixdlt.mempool.MempoolAddSuccess) ProposerElection(com.radixdlt.consensus.liveness.ProposerElection) WeightedRotatingLeaders(com.radixdlt.consensus.liveness.WeightedRotatingLeaders)

Example 4 with MainnetForkConfigsModule

use of com.radixdlt.statecomputer.forks.MainnetForkConfigsModule in project radixdlt by radixdlt.

the class AbstractRadixEngineTest method setup.

@Before
public void setup() {
    var injector = Guice.createInjector(MempoolConfig.asModule(mempoolMaxSize, 10), new MainnetForkConfigsModule(), new RadixEngineForksLatestOnlyModule(RERulesConfig.testingDefault().overrideFeeTable(FeeTable.create(Amount.ofSubunits(UInt256.ONE), Map.of(ValidatorRegisteredCopy.class, Amount.ofSubunits(UInt256.ONE)))).overrideMaxMessageLen(maxMessageLen)), new ForksModule(), new SingleNodeAndPeersDeterministicNetworkModule(TEST_KEY, 1), new MockedGenesisModule(Set.of(TEST_KEY.getPublicKey()), totalTokenAmount, stakeAmount), new AbstractModule() {

        @Override
        protected void configure() {
            bind(BerkeleyRecoverableProcessedTxnStore.class).in(Scopes.SINGLETON);
            Multibinder.newSetBinder(binder(), BerkeleyAdditionalStore.class).addBinding().to(BerkeleyRecoverableProcessedTxnStore.class);
            bindConstant().annotatedWith(DatabaseLocation.class).to(folder.getRoot().getAbsolutePath());
            bindConstant().annotatedWith(NetworkId.class).to(99);
            bind(P2PConfig.class).toInstance(mock(P2PConfig.class));
            bind(AddressBook.class).in(Scopes.SINGLETON);
            var selfUri = RadixNodeUri.fromPubKeyAndAddress(99, TEST_KEY.getPublicKey(), "localhost", 23456);
            bind(RadixNodeUri.class).annotatedWith(Self.class).toInstance(selfUri);
            var addressBookPersistence = mock(AddressBookPersistence.class);
            when(addressBookPersistence.getAllEntries()).thenReturn(ImmutableList.of());
            bind(AddressBookPersistence.class).toInstance(addressBookPersistence);
            var runtimeProperties = mock(RuntimeProperties.class);
            when(runtimeProperties.get(eq("api.transactions.enable"), anyBoolean())).thenReturn(true);
            bind(RuntimeProperties.class).toInstance(runtimeProperties);
        }
    });
    injector.injectMembers(this);
}
Also used : SingleNodeAndPeersDeterministicNetworkModule(com.radixdlt.SingleNodeAndPeersDeterministicNetworkModule) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) AddressBookPersistence(com.radixdlt.network.p2p.addressbook.AddressBookPersistence) BerkeleyAdditionalStore(com.radixdlt.store.berkeley.BerkeleyAdditionalStore) RadixEngineForksLatestOnlyModule(com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule) AbstractModule(com.google.inject.AbstractModule) ValidatorRegisteredCopy(com.radixdlt.application.validators.state.ValidatorRegisteredCopy) BerkeleyRecoverableProcessedTxnStore(com.radixdlt.api.core.reconstruction.BerkeleyRecoverableProcessedTxnStore) MockedGenesisModule(com.radixdlt.statecomputer.checkpoint.MockedGenesisModule) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) RadixNodeUri(com.radixdlt.network.p2p.RadixNodeUri) RuntimeProperties(com.radixdlt.properties.RuntimeProperties) Before(org.junit.Before)

Example 5 with MainnetForkConfigsModule

use of com.radixdlt.statecomputer.forks.MainnetForkConfigsModule in project radixdlt by radixdlt.

the class GenerateUniverses method main.

public static void main(String[] args) throws Exception {
    Security.insertProviderAt(new BouncyCastleProvider(), 1);
    Options options = new Options();
    options.addOption("h", "help", false, "Show usage information (this message)");
    options.addOption("p", "public-keys", true, "Specify validator keys");
    options.addOption("v", "validator-count", true, "Specify number of validators to generate");
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(options, args);
    if (!cmd.getArgList().isEmpty()) {
        System.err.println("Extra arguments: " + String.join(" ", cmd.getArgList()));
        usage(options);
        return;
    }
    if (cmd.hasOption('h')) {
        usage(options);
        return;
    }
    var validatorKeys = new HashSet<ECPublicKey>();
    if (cmd.getOptionValue("p") != null) {
        var hexKeys = cmd.getOptionValue("p").split(",");
        for (var hexKey : hexKeys) {
            validatorKeys.add(ECPublicKey.fromHex(hexKey));
        }
    }
    final int validatorsCount = cmd.getOptionValue("v") != null ? Integer.parseInt(cmd.getOptionValue("v")) : 0;
    var generatedValidatorKeys = PrivateKeys.numeric(6).limit(validatorsCount).toList();
    generatedValidatorKeys.stream().map(ECKeyPair::getPublicKey).forEach(validatorKeys::add);
    // Issuances to mnemomic account, keys 1-5, and 1st validator
    final var mnemomicKey = ECPublicKey.fromHex(mnemomicKeyHex);
    final ImmutableList.Builder<TokenIssuance> tokenIssuancesBuilder = ImmutableList.builder();
    tokenIssuancesBuilder.add(TokenIssuance.of(mnemomicKey, DEFAULT_ISSUANCE));
    PrivateKeys.numeric(1).limit(5).map(k -> TokenIssuance.of(k.getPublicKey(), DEFAULT_ISSUANCE)).forEach(tokenIssuancesBuilder::add);
    // Issue tokens to initial validators for now to support application services
    validatorKeys.forEach(pk -> tokenIssuancesBuilder.add(TokenIssuance.of(pk, DEFAULT_ISSUANCE)));
    // Stakes issued by mnemomic account
    var stakes = validatorKeys.stream().map(pk -> new StakeTokens(REAddr.ofPubKeyAccount(mnemomicKey), pk, DEFAULT_STAKE)).collect(Collectors.toSet());
    var timestamp = String.valueOf(Instant.now().getEpochSecond());
    var genesisProvider = Guice.createInjector(new AbstractModule() {

        @Provides
        @Singleton
        RERules reRules(Forks forks) {
            return forks.get(0);
        }

        @Override
        protected void configure() {
            install(new CryptoModule());
            install(new MainnetForkConfigsModule());
            install(new ForksModule());
            bind(new TypeLiteral<List<TxAction>>() {
            }).annotatedWith(Genesis.class).toInstance(List.of());
            bind(LedgerAccumulator.class).to(SimpleLedgerAccumulatorAndVerifier.class);
            bind(SystemCounters.class).toInstance(new SystemCountersImpl());
            bindConstant().annotatedWith(Genesis.class).to(timestamp);
            bind(new TypeLiteral<Set<StakeTokens>>() {
            }).annotatedWith(Genesis.class).toInstance(stakes);
            bind(new TypeLiteral<ImmutableList<TokenIssuance>>() {
            }).annotatedWith(Genesis.class).toInstance(tokenIssuancesBuilder.build());
            bind(new TypeLiteral<Set<ECPublicKey>>() {
            }).annotatedWith(Genesis.class).toInstance(validatorKeys);
            bindConstant().annotatedWith(MaxValidators.class).to(100);
            OptionalBinder.newOptionalBinder(binder(), Key.get(new TypeLiteral<List<TxAction>>() {
            }, Genesis.class));
        }
    }).getInstance(GenesisProvider.class);
    var genesis = genesisProvider.get().getTxns().get(0);
    IntStream.range(0, generatedValidatorKeys.size()).forEach(i -> {
        System.out.format("export RADIXDLT_VALIDATOR_%s_PRIVKEY=%s%n", i, Bytes.toBase64String(generatedValidatorKeys.get(i).getPrivateKey()));
        System.out.format("export RADIXDLT_VALIDATOR_%s_PUBKEY=%s%n", i, Addressing.ofNetwork(Network.LOCALNET).forNodes().of(generatedValidatorKeys.get(i).getPublicKey()));
    });
    if (validatorsCount > 0) {
        System.out.format("export RADIXDLT_GENESIS_TXN=%s%n", Bytes.toHexString(genesis.getPayload()));
    } else {
        try (var writer = new BufferedWriter(new FileWriter("genesis.json"))) {
            writer.write(new JSONObject().put("genesis", Bytes.toHexString(genesis.getPayload())).toString());
        }
    }
}
Also used : IntStream(java.util.stream.IntStream) RERules(com.radixdlt.statecomputer.forks.RERules) SimpleLedgerAccumulatorAndVerifier(com.radixdlt.ledger.SimpleLedgerAccumulatorAndVerifier) TxAction(com.radixdlt.atom.TxAction) Key(com.google.inject.Key) MaxValidators(com.radixdlt.statecomputer.MaxValidators) Options(org.apache.commons.cli.Options) Security(java.security.Security) Forks(com.radixdlt.statecomputer.forks.Forks) HelpFormatter(org.apache.commons.cli.HelpFormatter) ECPublicKey(com.radixdlt.crypto.ECPublicKey) DefaultParser(org.apache.commons.cli.DefaultParser) HashSet(java.util.HashSet) JSONObject(org.json.JSONObject) ImmutableList(com.google.common.collect.ImmutableList) CryptoModule(com.radixdlt.CryptoModule) CommandLine(org.apache.commons.cli.CommandLine) UInt256(com.radixdlt.utils.UInt256) Genesis(com.radixdlt.statecomputer.checkpoint.Genesis) PrivateKeys(com.radixdlt.utils.PrivateKeys) SystemCounters(com.radixdlt.counters.SystemCounters) Addressing(com.radixdlt.networks.Addressing) Network(com.radixdlt.networks.Network) CommandLineParser(org.apache.commons.cli.CommandLineParser) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) GenesisProvider(com.radixdlt.statecomputer.checkpoint.GenesisProvider) Set(java.util.Set) REAddr(com.radixdlt.identifiers.REAddr) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) List(java.util.List) Provides(com.google.inject.Provides) ECKeyPair(com.radixdlt.crypto.ECKeyPair) Bytes(com.radixdlt.utils.Bytes) OptionalBinder(com.google.inject.multibindings.OptionalBinder) Guice(com.google.inject.Guice) Amount(com.radixdlt.application.tokens.Amount) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) TypeLiteral(com.google.inject.TypeLiteral) LedgerAccumulator(com.radixdlt.ledger.LedgerAccumulator) AbstractModule(com.google.inject.AbstractModule) Singleton(com.google.inject.Singleton) Options(org.apache.commons.cli.Options) HashSet(java.util.HashSet) Set(java.util.Set) ImmutableList(com.google.common.collect.ImmutableList) FileWriter(java.io.FileWriter) ForksModule(com.radixdlt.statecomputer.forks.ForksModule) BufferedWriter(java.io.BufferedWriter) TypeLiteral(com.google.inject.TypeLiteral) TxAction(com.radixdlt.atom.TxAction) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) CommandLineParser(org.apache.commons.cli.CommandLineParser) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) DefaultParser(org.apache.commons.cli.DefaultParser) HashSet(java.util.HashSet) Forks(com.radixdlt.statecomputer.forks.Forks) MaxValidators(com.radixdlt.statecomputer.MaxValidators) LedgerAccumulator(com.radixdlt.ledger.LedgerAccumulator) CryptoModule(com.radixdlt.CryptoModule) SystemCounters(com.radixdlt.counters.SystemCounters) AbstractModule(com.google.inject.AbstractModule) CommandLine(org.apache.commons.cli.CommandLine) JSONObject(org.json.JSONObject) SystemCountersImpl(com.radixdlt.counters.SystemCountersImpl) MainnetForkConfigsModule(com.radixdlt.statecomputer.forks.MainnetForkConfigsModule) Genesis(com.radixdlt.statecomputer.checkpoint.Genesis)

Aggregations

ForksModule (com.radixdlt.statecomputer.forks.ForksModule)5 MainnetForkConfigsModule (com.radixdlt.statecomputer.forks.MainnetForkConfigsModule)5 AbstractModule (com.google.inject.AbstractModule)4 Genesis (com.radixdlt.statecomputer.checkpoint.Genesis)3 MockedGenesisModule (com.radixdlt.statecomputer.checkpoint.MockedGenesisModule)3 RadixEngineForksLatestOnlyModule (com.radixdlt.statecomputer.forks.RadixEngineForksLatestOnlyModule)3 Before (org.junit.Before)3 ImmutableList (com.google.common.collect.ImmutableList)2 Guice (com.google.inject.Guice)2 TypeLiteral (com.google.inject.TypeLiteral)2 SingleNodeAndPeersDeterministicNetworkModule (com.radixdlt.SingleNodeAndPeersDeterministicNetworkModule)2 BerkeleyRecoverableProcessedTxnStore (com.radixdlt.api.core.reconstruction.BerkeleyRecoverableProcessedTxnStore)2 Amount (com.radixdlt.application.tokens.Amount)2 TxAction (com.radixdlt.atom.TxAction)2 SystemCounters (com.radixdlt.counters.SystemCounters)2 SystemCountersImpl (com.radixdlt.counters.SystemCountersImpl)2 ECKeyPair (com.radixdlt.crypto.ECKeyPair)2 LedgerAccumulator (com.radixdlt.ledger.LedgerAccumulator)2 SimpleLedgerAccumulatorAndVerifier (com.radixdlt.ledger.SimpleLedgerAccumulatorAndVerifier)2 RuntimeProperties (com.radixdlt.properties.RuntimeProperties)2