Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

Commit

Permalink
2.2.6 -> 2.2.7 RC
Browse files Browse the repository at this point in the history
  • Loading branch information
rico666 committed Dec 16, 2018
1 parent 9f0fb92 commit d04d93b
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 37 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ burst.jar
brs.log
brs.log.*
/conf/logging.properties
/conf/brs.properties*
/conf/brs.properties.MainNet
/conf/brs.properties.Testnet
/conf/brs.properties.PrivNet
_config.yml
/html/ui/doc/*
target
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ If running for the first time,


if upgrading your wallet config from 1.3.6cg
(this feature will be removed in 2.2.8)

```
burst.sh upgrade
Expand Down Expand Up @@ -105,8 +106,8 @@ DB.Password=yourpassword

`latest` : Latest tag of the BRS with H2 database
`mariadb` : Latest tag of the BRS with MariaDB database
`2.2.3-h2`, `2.2-h2` : Version 2.2.3 of the BRS with H2 database
`2.2.3-mariadb`, `2.2-mariadb` : Version 2.2.3 of the BRS with MariaDB database
`2.2.7-h2`, `2.2-h2`, `2-h2` : Version 2.2.7 of the BRS with H2 database
`2.2.7-mariadb`, `2.2-mariadb`, `2-mariadb` : Version 2.2.7 of the BRS with MariaDB database


**Note (H2 only):**
Expand All @@ -126,7 +127,7 @@ version: '3'
services:
burstcoin:
image: burstcoin/core:2.2-mariadb
image: pocconsortium/burstcoin:2-mariadb
restart: always
depends_on:
- mariadb
Expand All @@ -147,7 +148,7 @@ services:
##### H2

```
docker run -p 8123:8123 -p 8125:8125 -v "$(pwd)"/burst_db:/db -d burstcoin/core:2.2-h2
docker run -p 8123:8123 -p 8125:8125 -v "$(pwd)"/burst_db:/db -d pocconsortium/burstcoin:2-h2
```


Expand Down
3 changes: 3 additions & 0 deletions conf/brs-default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ P2P.maxUnconfirmedTransactions = 8192
# Max percentage of unconfirmed transactions that have a full hash reference to another transaction kept in cache
P2P.maxUnconfirmedTransactionsFullHashReferencePercentage = 5

# Max amount of raw UT bytes we will send to someone through both push and pull. Keep in mind that the resulting JSON size will always be bigger.
P2P.maxUTRawSizeBytesToSend = 175000

# JETTY pass-through options. See documentation at
# https://www.eclipse.org/jetty/documentation/9.2.22.v20170531/dos-filter.html
# P2P section:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>burstcoin</groupId>
<artifactId>burstcoin</artifactId>
<version>2.2.6</version>
<version>2.2.7</version>
<name>Burstcoin Reference Software</name>
<url>https://github.com/PoC-Consortium/burstcoin</url>

Expand Down
2 changes: 2 additions & 0 deletions src/brs/BlockchainProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ void generateBlock(String secretPhrase, byte[] publicKey, Long nonce)

void validateAtNextScan();

Integer getWalletTTSD();

List<? extends Block> popOffTo(int height);

class BlockNotAcceptedException extends BurstException {
Expand Down
26 changes: 25 additions & 1 deletion src/brs/BlockchainProcessorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public final class BlockchainProcessorImpl implements BlockchainProcessor {
private boolean forceScan;
private boolean validateAtScan;

private boolean forgeFatBlocks;

private Integer ttsd;

private final Runnable debugInfoThread = () -> {
logger.info("Unverified blocks: " + downloadCache.getUnverifiedSize());
logger.info("Blocks in cache: " + downloadCache.size());
Expand Down Expand Up @@ -145,6 +149,11 @@ public BlockchainProcessorImpl(ThreadPool threadPool, BlockService blockService,

forceScan = propertyService.getBoolean(Props.DEV_FORCE_SCAN);
validateAtScan = propertyService.getBoolean(Props.DEV_FORCE_VALIDATE);
forgeFatBlocks = "fat".equals(propertyService.getString(Props.BRS_FORGING_STRATEGY));

if(forgeFatBlocks) {
ttsd = 400;
}

blockListeners.addListener(block -> {
if (block.getHeight() % 5000 == 0) {
Expand Down Expand Up @@ -787,6 +796,11 @@ public void validateAtNextScan() {
validateAtScan = true;
}

@Override
public Integer getWalletTTSD() {
return this.ttsd;
}

void setGetMoreBlocks(boolean getMoreBlocks) {
this.getMoreBlocks = getMoreBlocks;
}
Expand Down Expand Up @@ -825,6 +839,16 @@ private void addGenesisBlock() {
}

private void pushBlock(final Block block) throws BlockNotAcceptedException {
if(ttsd != null) {
ttsd--;

if (ttsd < 0) {
logger.warn("Tick tocks, been crafting too many fat blocks");
Burst.shutdown(false);
System.exit(0);
}
}

synchronized (transactionProcessor.getUnconfirmedTransactionsSyncObj()) {
stores.beginTransaction();
int curTime = timeService.getEpochTime();
Expand Down Expand Up @@ -1144,7 +1168,7 @@ else if ( transaction.getSize() > payloadSize ) {
continue COLLECT_TRANSACTIONS;
}

Long slotFee = Burst.getFluxCapacitor().isActive(PRE_DYMAXION) ? blockSize * FEE_QUANT : ONE_BURST;
Long slotFee = Burst.getFluxCapacitor().isActive(PRE_DYMAXION) ? (forgeFatBlocks ? 1 : blockSize) * FEE_QUANT : ONE_BURST;
if (transaction.getFeeNQT() >= slotFee) {
// transaction can only be handled if all referenced ones exist
if (hasAllReferencedTransactions(transaction, transaction.getTimestamp(), 0)) {
Expand Down
4 changes: 1 addition & 3 deletions src/brs/Burst.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@

public final class Burst {

public static final String VERSION = "2.2.6";
public static final String VERSION = "2.2.7";
public static final String APPLICATION = "BRS";
public static final String LEGACY_APP = "NRS";
public static final String LEGACY_VER = "1.2.9";

private static final String DEFAULT_PROPERTIES_NAME = "brs-default.properties";

Expand Down
2 changes: 1 addition & 1 deletion src/brs/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public final class Constants {
public static final int MAX_AUTOMATED_TRANSACTION_NAME_LENGTH = 30;
public static final int MAX_AUTOMATED_TRANSACTION_DESCRIPTION_LENGTH = 1000;

public static final String MIN_VERSION = "2.2.1";
public static final String MIN_VERSION = "2.2.6";

static final long UNCONFIRMED_POOL_DEPOSIT_NQT = (Burst.getPropertyService().getBoolean(Props.DEV_TESTNET) ? 50 : 100) * ONE_BURST;

Expand Down
4 changes: 3 additions & 1 deletion src/brs/TransactionProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ enum Event {

List<Transaction> getAllUnconfirmedTransactions();

List<Transaction> getAllUnconfirmedTransactionsFor(Peer peer, long limitInBytes);
int getAmountUnconfirmedTransactions();

List<Transaction> getAllUnconfirmedTransactionsFor(Peer peer);

void markFingerPrintsOf(Peer peer, List<Transaction> transactions);

Expand Down
9 changes: 7 additions & 2 deletions src/brs/TransactionProcessorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ public List<Transaction> getAllUnconfirmedTransactions() {
}

@Override
public List<Transaction> getAllUnconfirmedTransactionsFor(Peer peer, long limitInBytes) {
public int getAmountUnconfirmedTransactions() {
return unconfirmedTransactionStore.getAmount();
}

@Override
public List<Transaction> getAllUnconfirmedTransactionsFor(Peer peer) {
return unconfirmedTransactionStore.getAllFor(peer);
}

Expand Down Expand Up @@ -363,7 +368,7 @@ private List<Transaction> processTransactions(Collection<Transaction> transactio
private int broadcastToPeers(boolean toAll) {
List<? extends Peer> peersToSendTo = toAll ? Peers.getActivePeers().stream().limit(100).collect(Collectors.toList()) : Peers.getAllActivePriorityPlusSomeExtraPeers();

logger.info("Queueing up {} Peers for feeding", peersToSendTo.size());
logger.trace("Queueing up {} Peers for feeding", peersToSendTo.size());

for(Peer p: peersToSendTo) {
Peers.feedingTime(p, foodDispenser, doneFeedingLog);
Expand Down
1 change: 1 addition & 0 deletions src/brs/http/APIServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public APIServlet(TransactionProcessor transactionProcessor, Blockchain blockcha
map.put("getMyInfo", GetMyInfo.instance);
//map.put("getNextBlockGenerators", GetNextBlockGenerators.instance);
map.put("getPeer", GetPeer.instance);
map.put("getMyPeerInfo", new GetMyPeerInfo(blockchainProcessor, transactionProcessor));
map.put("getPeers", GetPeers.instance);
//map.put("getPoll", GetPoll.instance);
//map.put("getPollIds", GetPollIds.instance);
Expand Down
29 changes: 29 additions & 0 deletions src/brs/http/GetMyPeerInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package brs.http;

import brs.BlockchainProcessor;
import brs.TransactionProcessor;
import javax.servlet.http.HttpServletRequest;
import org.json.simple.JSONObject;
import org.json.simple.JSONStreamAware;

public final class GetMyPeerInfo extends APIServlet.APIRequestHandler {

private final BlockchainProcessor blockchainProcessor;
private final TransactionProcessor transactionProcessor;

public GetMyPeerInfo(BlockchainProcessor blockchainProcessor, TransactionProcessor transactionProcessor) {
super(new APITag[]{APITag.INFO});
this.blockchainProcessor = blockchainProcessor;
this.transactionProcessor = transactionProcessor;
}

@Override
JSONStreamAware processRequest(HttpServletRequest req) {

JSONObject response = new JSONObject();
response.put("walletTTSD", blockchainProcessor.getWalletTTSD());
response.put("utsInStore", transactionProcessor.getAmountUnconfirmedTransactions());
return response;
}

}
6 changes: 1 addition & 5 deletions src/brs/peer/GetUnconfirmedTransactions.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@ final class GetUnconfirmedTransactions extends PeerServlet.ExtendedPeerRequestHa
ExtendedProcessRequest extendedProcessRequest(JSONObject request, Peer peer) {
JSONObject response = new JSONObject();

// TODO Brabantian limit should be passed how? From PeerInfo somehow? Math.min(x, y);
final List<Transaction> unconfirmedTransactions = transactionProcessor.getAllUnconfirmedTransactionsFor(peer, 1000L);

//long newLastUnconfirmedTransactionTimestamp = unconfirmedTransactionsOverview.getTimestamp();
final List<Transaction> unconfirmedTransactions = transactionProcessor.getAllUnconfirmedTransactionsFor(peer);

JSONArray transactionsData = new JSONArray();
for (Transaction transaction : unconfirmedTransactions) {
transactionsData.add(transaction.getJSONObject());
}

response.put(UNCONFIRMED_TRANSACTIONS_RESPONSE, transactionsData);
// response.put(LAST_UNCONFIRMED_TRANSACTION_TIMESTAMP_RESPONSE, unconfirmedTransactionsOverview.getTimestamp());

return new ExtendedProcessRequest(response, () -> transactionProcessor.markFingerPrintsOf(peer, unconfirmedTransactions));
}
Expand Down
14 changes: 11 additions & 3 deletions src/brs/peer/PeerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,18 @@ public String getVersion() {
}

// semantic versioning for peer versions. here: ">=" negate it for "<"
public boolean isHigherOrEqualVersionThan(String ComparisonVersion) {
public boolean isHigherOrEqualVersionThan(String ourVersion) {
return isHigherOrEqualVersion(ourVersion, version);
}

public static boolean isHigherOrEqualVersion(String ourVersion, String possiblyLowerVersion) {
if(possiblyLowerVersion == null || possiblyLowerVersion.isEmpty()) {
return false;
}

Pattern pattern = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)?");
Matcher matchPeer = pattern.matcher(version);
Matcher matchCompare = pattern.matcher(ComparisonVersion);
Matcher matchPeer = pattern.matcher(possiblyLowerVersion);
Matcher matchCompare = pattern.matcher(ourVersion);

if (matchPeer.find() && matchCompare.find()) { // if both peer version and our comparison version are sane
// we have simplified versions with 3 limbs: X.Y.Z
Expand Down
3 changes: 3 additions & 0 deletions src/brs/peer/PeerServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public void init(ServletConfig config) throws ServletException {

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
if(! Peers.isSupportedUserAgent(req.getHeader("User-Agent"))) {
return;
}

PeerImpl peer = null;
JSONStreamAware response;
Expand Down
29 changes: 20 additions & 9 deletions src/brs/peer/Peers.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package brs.peer;

import static brs.Constants.MIN_VERSION;
import static brs.peer.PeerImpl.isHigherOrEqualVersion;
import static brs.props.Props.P2P_ENABLE_TX_REBROADCAST;
import static brs.props.Props.P2P_SEND_TO_LIMIT;
import static brs.util.JSON.prepareRequest;
Expand All @@ -12,6 +14,7 @@
import brs.util.*;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
Expand Down Expand Up @@ -44,6 +47,14 @@ public final class Peers {

private static final Logger logger = LoggerFactory.getLogger(Peers.class);

public static boolean isSupportedUserAgent(String header) {
if(header == null || header.isEmpty() || ! header.trim().startsWith("BRS/")) {
return false;
} else {
return isHigherOrEqualVersion(MIN_VERSION, header.trim().substring("BRS/".length()));
}
}

public enum Event {
BLACKLIST, UNBLACKLIST, DEACTIVATE, REMOVE,
DOWNLOADED_VOLUME, UPLOADED_VOLUME, WEIGHT,
Expand Down Expand Up @@ -432,7 +443,7 @@ public void run() {
* if we loose Internet connection
*/

if (!peer.isHigherOrEqualVersionThan(Burst.LEGACY_VER)
if (!peer.isHigherOrEqualVersionThan(MIN_VERSION)
|| (peer.getState() != Peer.State.CONNECTED && !peer.isBlacklisted() && peers.size() > maxNumberOfConnectedPublicPeers)) {
removePeer(peer);
}
Expand All @@ -456,7 +467,7 @@ public void run() {
for (PeerImpl peer : peers.values()) {
if (peer.getState() == Peer.State.CONNECTED && now - peer.getLastUpdated() > 3600) {
peer.connect(timeService.getEpochTime());
if (!peer.isHigherOrEqualVersionThan(Burst.LEGACY_VER) ||
if (!peer.isHigherOrEqualVersionThan(MIN_VERSION) ||
(peer.getState() != Peer.State.CONNECTED && !peer.isBlacklisted() && peers.size() > maxNumberOfConnectedPublicPeers)) {
removePeer(peer);
}
Expand All @@ -479,7 +490,7 @@ private void updateSavedPeers() {
if (peer.getAnnouncedAddress() != null
&& ! peer.isBlacklisted()
&& ! peer.isWellKnown()
&& peer.isHigherOrEqualVersionThan(Burst.LEGACY_VER)) {
&& peer.isHigherOrEqualVersionThan(MIN_VERSION)) {
currentPeers.add(peer.getAnnouncedAddress());
}
}
Expand Down Expand Up @@ -562,7 +573,7 @@ public void run() {
&& myPeer.getState() == Peer.State.CONNECTED && myPeer.shareAddress()
&& ! addedAddresses.contains(myPeer.getAnnouncedAddress())
&& ! myPeer.getAnnouncedAddress().equals(peer.getAnnouncedAddress())
&& myPeer.isHigherOrEqualVersionThan(Burst.LEGACY_VER)
&& myPeer.isHigherOrEqualVersionThan(MIN_VERSION)
) {
myPeers.add(myPeer.getAnnouncedAddress());
}
Expand Down Expand Up @@ -817,16 +828,16 @@ private static void feedPeer(Peer peer, Function<Peer, List<Transaction>> foodDi
List<Transaction> transactionsToSend = foodDispenser.apply(peer);

if(! transactionsToSend.isEmpty()) {
logger.info("Feeding {} {} transactions", peer.getPeerAddress(), transactionsToSend.size());
logger.trace("Feeding {} {} transactions", peer.getPeerAddress(), transactionsToSend.size());
JSONObject response = peer.send(sendUnconfirmedTransactionsRequest(transactionsToSend));

if(response != null && response.get("error") == null) {
doneFeedingLog.accept(peer, transactionsToSend);
} else {
logger.error("Error feeding {} transactions: {} error: {}", peer.getPeerAddress(), transactionsToSend.stream().map(t -> t.getId()), response);
logger.warn("Error feeding {} transactions: {} error: {}", peer.getPeerAddress(), transactionsToSend.stream().map(t -> t.getId()).collect(Collectors.toList()), response);
}
} else {
logger.info("No need to feed {}", peer.getPeerAddress());
logger.trace("No need to feed {}", peer.getPeerAddress());
}

beingProcessed.remove(peer);
Expand All @@ -853,9 +864,9 @@ private static JSONStreamAware sendUnconfirmedTransactionsRequest(List<Transacti
}

private static boolean peerEligibleForSending(Peer peer, boolean sendSameBRSclass) {
return peer.isHigherOrEqualVersionThan(Burst.LEGACY_VER)
return peer.isHigherOrEqualVersionThan(MIN_VERSION)
&& (! sendSameBRSclass || peer.isAtLeastMyVersion())
&& !peer.isBlacklisted()
&& ! peer.isBlacklisted()
&& peer.getState() == Peer.State.CONNECTED
&& peer.getAnnouncedAddress() != null;
}
Expand Down
4 changes: 4 additions & 0 deletions src/brs/props/Props.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class Props {

public static final Prop BRS_SHUTDOWN_TIMEOUT = new Prop("brs.ShutdownTimeout", 180);

public static final Prop BRS_FORGING_STRATEGY = new Prop("brs.ForgingStrategy", "slots");

// GPU options
public static final Prop GPU_ACCELERATION = new Prop("GPU.Acceleration", false);
public static final Prop GPU_AUTODETECT = new Prop("GPU.AutoDetect", true);
Expand Down Expand Up @@ -100,6 +102,8 @@ public class Props {
public static final Prop P2P_MAX_UNCONFIRMED_TRANSACTIONS = new Prop("P2P.maxUnconfirmedTransactions", 8192);
public static final Prop P2P_MAX_PERCENTAGE_UNCONFIRMED_TRANSACTIONS_FULL_HASH_REFERENCE = new Prop("P2P.maxUnconfirmedTransactionsFullHashReferencePercentage", 5);

public static final Prop P2P_MAX_UNCONFIRMED_TRANSACTIONS_RAW_SIZE_BYTES_TO_SEND = new Prop("P2P.maxUTRawSizeBytesToSend", 175000);

// API options
public static final Prop API_DEBUG = new Prop("API.Debug", false);
public static final Prop API_SSL = new Prop("API.SSL", false);
Expand Down
Loading

0 comments on commit d04d93b

Please sign in to comment.