Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #207 from HelixNetwork/dev
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
oracle58 authored Oct 10, 2019
2 parents 27ff9a8 + 569a379 commit a148f48
Show file tree
Hide file tree
Showing 38 changed files with 391 additions and 283 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ effective.pom
.settings/
enforcer.pom
out

# db
db
mainnet.log
Expand All @@ -44,6 +45,7 @@ spent-addresses-log
*.snapshot.state
*.snapshot.meta.bkp
*.snapshot.state.bkp
snapshot/*

# modules
XI
Expand All @@ -61,6 +63,7 @@ modules/*
# keys
*.key
*.pem
Validator.*

# os
.DS_Store
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 1.0.2
- Added roundIndex to transaction meta data
- Set round indices of a round's txs in MilestoneTracker
- Removed obsolete `isPoWDisabled` setting
- Removed obsolete spammer-class
- Changed default dir of local snapshots from mainnet to snapshot
- Only debug log most recent applied round
- Fixed #184: `NULL_HASH` not used as empty round's snapshot hash anymore
- Temporarily added parameter `NUM_OF_ACTIVE_VALIDATORS`
- Temporarily added parameter `CONFIRMATION_THRESHOLD`
- Set `roundIndex` of all round's txs - not only milestones
- Update `getConfirmedTransactions`
- Added `confirmations` to tx meta data. Each time a valid milestone refers to a transaction this counter is incremented.
- New implementation of `getConfirmationStates`, which now compares relative confirmations to a specifiable confirmation threshold.
- Add `validator-path` parameter

## 1.0.1
- Added dev instrumentation
- Added hardware specs
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# Pendulum

Pendulum is a quorum based [Tangle](https://github.com/iotaledger/iri/) implementation designed towards reliable timekeeping and high-throughput messaging.
- **Latest release:** 1.0.1 release

- **Latest release:** 1.0.2 pre-release
- **License:** GPLv3

Special thanks to all of the [IOTA Contributors](https://github.com/iotaledger/iri/graphs/contributors)!
Expand Down
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<groupId>net.pendulum</groupId>
<artifactId>pendulum</artifactId>

<version>1.0.1</version>

<version>1.0.2</version>


<name>Pendulum</name>
<description>Pendulum Protocol</description>
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/net/helix/pendulum/BundleValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ public static List<List<TransactionViewModel>> validate(Tangle tangle, Snapshot

TransactionViewModel tail = TransactionViewModel.fromHash(tangle, tailHash);
if (tail.getCurrentIndex() != 0 || tail.getValidity() == -1) {
//System.out.println("Empty List");
return Collections.EMPTY_LIST;
}

List<List<TransactionViewModel>> transactions = new LinkedList<>();
final Map<Hash, TransactionViewModel> bundleTransactions = loadTransactionsFromTangle(tangle, tail);
// System.out.println("bundle size: " + bundleTransactions.size());

//we don't really iterate, we just pick the tail tx. See the if on the next line
for (TransactionViewModel transactionViewModel : bundleTransactions.values()) {
Expand Down Expand Up @@ -106,7 +104,6 @@ public static List<List<TransactionViewModel>> validate(Tangle tangle, Snapshot
|| bundleValue > TransactionViewModel.SUPPLY)
) {
instanceTransactionViewModels.get(0).setValidity(tangle, initialSnapshot, -1);
//System.out.println("Semantics Error!");
break;
}

Expand All @@ -123,8 +120,6 @@ public static List<List<TransactionViewModel>> validate(Tangle tangle, Snapshot
}
sha3Instance.squeeze(bundleHashBytes, 0, bundleHashBytes.length);
//verify bundle hash is correct
//System.out.println("Bundle Hash: " + instanceTransactionViewModels.get(0).getBundleHash());
//System.out.println("recalculated Bundle Hash: " + Hex.toHexString(bundleHashBytes));
if (Arrays.equals(instanceTransactionViewModels.get(0).getBundleHash().bytes(), bundleHashBytes)) {
//normalizing the bundle in preparation for signature verification
normalizedBundle = Winternitz.normalizedBundle(bundleHashBytes);
Expand All @@ -151,7 +146,6 @@ public static List<List<TransactionViewModel>> validate(Tangle tangle, Snapshot
//signature verification
if (! Arrays.equals(transactionViewModel.getAddressHash().bytes(), addressBytes)) {
instanceTransactionViewModels.get(0).setValidity(tangle, initialSnapshot, -1);
//System.out.println("Signature Error!");
break MAIN_LOOP;
}
} else {
Expand All @@ -165,7 +159,6 @@ public static List<List<TransactionViewModel>> validate(Tangle tangle, Snapshot
//bundle hash verification failed
else {
instanceTransactionViewModels.get(0).setValidity(tangle, initialSnapshot, -1);
//System.out.println("Bundle Hash Error!");
}
}
//bundle validity status is known
Expand All @@ -176,7 +169,6 @@ public static List<List<TransactionViewModel>> validate(Tangle tangle, Snapshot
//total bundle value does not sum to 0
else {
instanceTransactionViewModels.get(0).setValidity(tangle, initialSnapshot, -1);
//System.out.println("Bundle Sum Error!");
}
//break from main loop
break;
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/net/helix/pendulum/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import net.helix.pendulum.conf.PendulumConfig;
import net.helix.pendulum.service.API;
import net.helix.pendulum.service.ApiArgs;
import net.helix.pendulum.service.Spammer;
import net.helix.pendulum.service.milestone.impl.MilestonePublisher;
import net.helix.pendulum.service.restserver.resteasy.RestEasy;
import net.helix.pendulum.service.validatomanager.impl.ValidatorPublisher;
import net.helix.pendulum.service.validatormanager.impl.ValidatorPublisher;
import net.helix.pendulum.utils.PendulumIOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -40,13 +39,15 @@
* </ul>
* </p>
*
* @see <a href="https://docs.hlx.ai/protocol">Online documentation on hlx</a>
* @see <a href="https://dev.hlx.ai">Online documentation on pendulum</a>
*/
public class Main {

public static final String MAINNET_NAME = "Pendulum";
public static final String TESTNET_NAME = "Pendulum Testnet";
public static final String VERSION = "1.0.1";

public static final String VERSION = "1.0.2";


/**
* The entry point of Pendulum.
Expand Down Expand Up @@ -99,10 +100,9 @@ private static class MainLauncher {
public static XI XI;
public static MilestonePublisher milestonePublisher;
public static ValidatorPublisher validatorPublisher;
public static Spammer spammer;

/**
* Starts hlx. Setup is as follows:
* Starts Pendulum. Setup is as follows:
* <ul>
* <li>Load the configuration.</li>
* <li>Create {@link Pendulum}, {@link XI} and {@link API}.</li>
Expand Down Expand Up @@ -135,7 +135,7 @@ public static void main(String [] args) throws Exception {
log.error("Exception during Pendulum node initialisation: ", e);
throw e;
}
if (config.getValidator() != null || new File(config.getValidatorKeyfile()).isFile() ) {
if (config.isValidatorEnabled()) {
milestonePublisher = new MilestonePublisher(config, api, pendulum.candidateTracker);
milestonePublisher.startScheduledExecutorService();
}
Expand All @@ -158,7 +158,7 @@ private static void shutdownHook() {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
log.info("Shutting down Pendulum node, please hold tight...");
try {
if (pendulum.configuration.getValidator() != null || new File(pendulum.configuration.getValidatorKeyfile()).isFile()) {
if (pendulum.configuration.isValidatorEnabled()) {
milestonePublisher.shutdown();
}
/*if (pendulum.configuration.getValidatorManagerEnabled()) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/helix/pendulum/Pendulum.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import net.helix.pendulum.service.tipselection.impl.WalkerAlpha;
import net.helix.pendulum.service.transactionpruning.TransactionPruningException;
import net.helix.pendulum.service.transactionpruning.async.AsyncTransactionPruner;
import net.helix.pendulum.service.validatomanager.impl.CandidateSolidifierImpl;
import net.helix.pendulum.service.validatomanager.impl.CandidateTrackerImpl;
import net.helix.pendulum.service.validatomanager.impl.ValidatorManagerServiceImpl;
import net.helix.pendulum.service.validatormanager.impl.CandidateSolidifierImpl;
import net.helix.pendulum.service.validatormanager.impl.CandidateTrackerImpl;
import net.helix.pendulum.service.validatormanager.impl.ValidatorManagerServiceImpl;
import net.helix.pendulum.storage.Indexable;
import net.helix.pendulum.storage.Persistable;
import net.helix.pendulum.storage.PersistenceProvider;
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/net/helix/pendulum/TransactionValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ public boolean checkSolidity(Hash hash, boolean milestone) throws Exception {
* @throws Exception if anything goes wrong while trying to solidify the transaction
*/
public boolean checkSolidity(Hash hash, boolean milestone, int maxProcessedTransactions) throws Exception {
//System.out.println("Check Solidity");
if(fromHash(tangle, hash).isSolid()) {
return true;
}
Expand All @@ -275,7 +274,6 @@ public boolean checkSolidity(Hash hash, boolean milestone, int maxProcessedTrans
}

final TransactionViewModel transaction = fromHash(tangle, hashPointer);
//System.out.println(hashPointer.toString() + ", solid: " + transaction.isSolid() + ", has solid entry point: " + snapshotProvider.getInitialSnapshot().hasSolidEntryPoint(hashPointer));
if(!transaction.isSolid() && !snapshotProvider.getInitialSnapshot().hasSolidEntryPoint(hashPointer)) {
if (transaction.getType() == PREFILLED_SLOT) {
solid = false;
Expand Down Expand Up @@ -407,21 +405,17 @@ public void updateStatus(TransactionViewModel transactionViewModel) throws Excep
transactionRequester.clearTransactionRequest(transactionViewModel.getHash());
if(transactionViewModel.getApprovers(tangle).size() == 0) {
tipsViewModel.addTipHash(transactionViewModel.getHash());
//System.out.println("Add Tip: " + transactionViewModel.getHash().hexString());
} else {
TransactionViewModel milestoneTx;
if ((milestoneTx = transactionViewModel.isMilestoneBundle(tangle)) != null){
Set<Hash> parents = RoundViewModel.getMilestoneTrunk(tangle, transactionViewModel, milestoneTx);
parents.addAll(RoundViewModel.getMilestoneBranch(tangle, transactionViewModel, milestoneTx, config.getValidatorSecurity()));
for (Hash parent : parents){
tipsViewModel.removeTipHash(parent);
//System.out.println("Remove Tip: " + parent.hexString());
}
} else {
tipsViewModel.removeTipHash(transactionViewModel.getTrunkTransactionHash());
tipsViewModel.removeTipHash(transactionViewModel.getBranchTransactionHash());
//System.out.println("Remove Tip: " + transactionViewModel.getTrunkTransactionHash().hexString());
//System.out.println("Remove Tip: " + transactionViewModel.getBranchTransactionHash().hexString());
}
}

Expand Down Expand Up @@ -454,7 +448,6 @@ private boolean quietQuickSetSolid(TransactionViewModel transactionViewModel) {
* @throws Exception
*/
private boolean quickSetSolid(final TransactionViewModel transactionViewModel) throws Exception {
//System.out.println("Quick Set Solid");
if(!transactionViewModel.isSolid()) {
boolean solid = true;
TransactionViewModel milestoneTx;
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/net/helix/pendulum/conf/APIConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ public interface APIConfig extends Config {
*/
String getRemoteAuth();

/**
* @return {@value Descriptions#IS_POW_DISABLED}
*/
boolean isPoWDisabled();

/**
* @return {@value Descriptions#RESOURCE_PATH}
*/
Expand All @@ -73,7 +68,6 @@ interface Descriptions {
String MAX_GET_TRANSACTION_STRINGS = "The maximal number of transaction strings that may be returned by the \"getTransactionStrings\" API call. If the number of transactions found exceeds this number an error will be returned.";
String MAX_BODY_LENGTH = "The maximal number of characters the body of an API call may hold. If a request body length exceeds this number an error will be returned.";
String REMOTE = "Open the API interface to any host. Equivalent to \"--api-host 0.0.0.0\"";
String IS_POW_DISABLED = "If pow is disabled the node will not require a valid nonce.";
String RESOURCE_PATH = "Resource path";
}
}
Loading

0 comments on commit a148f48

Please sign in to comment.