Skip to content

Commit

Permalink
Merge pull request #172 from galpHub/origin_master0_update
Browse files Browse the repository at this point in the history
Improvements for tests, SECP and startup
  • Loading branch information
galpHub committed Feb 27, 2020
2 parents fd11103 + 28935dd commit c0fc4c8
Show file tree
Hide file tree
Showing 53 changed files with 1,016 additions and 850 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ services:
script:
# Compile from source
- cd divi
- docker build -t divi -f Dockerfile .
- docker build -t divi -f DockerfileWithTests .
- docker run divi
after_failure:
- cat ./src/test-suite.log
29 changes: 29 additions & 0 deletions divi/DockerfileWithTests
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:bionic

RUN apt-get update
RUN apt-get install apt-utils -y
RUN apt-get install bsdmainutils -y
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:bitcoin/bitcoin -y
RUN apt-get update

RUN apt-get install make -y
RUN apt-get install gcc -y
RUN apt-get install g++ -y
RUN apt-get install pkg-config -y
RUN apt-get install autoconf -y
RUN apt-get install libtool -y
RUN apt-get install libboost-all-dev -y
RUN apt-get install libssl1.0-dev -y
RUN apt-get install libevent-dev -y
RUN apt-get install libdb4.8-dev libdb4.8++-dev -y

WORKDIR /app
COPY . .

RUN ./autogen.sh
RUN ./configure --without-gui NO_QT=1
RUN make NO_QT=1
RUN make check

CMD ["bash"]
37 changes: 15 additions & 22 deletions divi/contrib/gitian-descriptors/gitian-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ script: |
BASEPREFIX=`pwd`/depends
# Build dependencies for each host
for i in $HOSTS; do
make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}"
make ${MAKEOPTS} NO_QT=1 -C ${BASEPREFIX} HOST="${i}"
done
# Faketime for binaries
Expand Down Expand Up @@ -144,29 +144,22 @@ script: |
CONFIG_SITE=${BASEPREFIX}/${i}/share/config.site ./configure --prefix=/ --disable-ccache --disable-maintainer-mode --disable-dependency-tracking ${CONFIGFLAGS} CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}"
make ${MAKEOPTS}
mkdir -p $OUTDIR/bin/${DISTNAME}-${i}
cp `pwd`/src/divi*.exe $OUTDIR/bin/${DISTNAME}-${i}
zip -r $OUTDIR/${DISTNAME}-${i}.zip $OUTDIR/bin/${DISTNAME}-${i}
#make deploy
#make install DESTDIR=${INSTALLPATH}
#cp -f divi-*setup*.exe $OUTDIR/
make install DESTDIR=${INSTALLPATH}
cd installed
# mv ${DISTNAME}/bin/*.dll ${DISTNAME}/lib/ # temporarily disabled for Zerocoin
# find . -name "lib*.la" -delete # temporarily disabled for Zerocoin
# find . -name "lib*.a" -delete # temporarily disabled for Zerocoin
mkdir -p $OUTDIR/${DISTNAME}-${i}
rm -rf ${DISTNAME}/lib/pkgconfig
#find ${DISTNAME}/bin -type f -executable -exec ${i}-objcopy --only-keep-debug {} {}.dbg \; -exec ${i}-strip -s {} \; -exec ${i}-objcopy --add-gnu-debuglink={}.dbg {} \;
# find ${DISTNAME}/lib -type f -exec ${i}-objcopy --only-keep-debug {} {}.dbg \; -exec ${i}-strip -s {} \; -exec ${i}-objcopy --add-gnu-debuglink={}.dbg {} \;
# find ${DISTNAME} -not -name "*.dbg" -type f | sort | zip -X@ ${OUTDIR}/${DISTNAME}-${i}.zip
# find ${DISTNAME} -name "*.dbg" -type f | sort | zip -X@ ${OUTDIR}/${DISTNAME}-${i}-debug.zip
find ${DISTNAME}/bin -type f -executable -exec ${i}-objcopy --only-keep-debug {} {}.dbg \; -exec ${i}-strip -s {} \; -exec ${i}-objcopy --add-gnu-debuglink={}.dbg {} \;
find . -name "lib*.la" -delete # temporarily disabled for Zerocoin
find . -name "lib*.a" -delete # temporarily disabled for Zerocoin
find ${DISTNAME} -not -name "*.dbg" -type f | sort | zip -X@ ${OUTDIR}/${DISTNAME}-${i}.zip
find ${DISTNAME} -name "*.dbg" -type f | sort | zip -X@ ${OUTDIR}/${DISTNAME}-${i}-debug.zip
cd ../../
rm -rf distsrc-${i}
done
rm -rf $OUTDIR/bin
#cd $OUTDIR
#rename 's/-setup\.exe$/-setup-unsigned.exe/' *-setup.exe
#find . -name "*-setup-unsigned.exe" | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-win-unsigned.tar.gz
#mv ${OUTDIR}/${DISTNAME}-x86_64-*-debug.zip ${OUTDIR}/${DISTNAME}-win64-debug.zip
#mv ${OUTDIR}/${DISTNAME}-i686-*-debug.zip ${OUTDIR}/${DISTNAME}-win32-debug.zip
#mv ${OUTDIR}/${DISTNAME}-x86_64-*.zip ${OUTDIR}/${DISTNAME}-win64.zip
#mv ${OUTDIR}/${DISTNAME}-i686-*.zip ${OUTDIR}/${DISTNAME}-win32.zip
mv ${OUTDIR}/${DISTNAME}-x86_64-*-debug.zip ${OUTDIR}/${DISTNAME}-win64-debug.zip
mv ${OUTDIR}/${DISTNAME}-i686-*-debug.zip ${OUTDIR}/${DISTNAME}-win32-debug.zip
mv ${OUTDIR}/${DISTNAME}-x86_64-*.zip ${OUTDIR}/${DISTNAME}-win64.zip
mv ${OUTDIR}/${DISTNAME}-i686-*.zip ${OUTDIR}/${DISTNAME}-win32.zip
5 changes: 5 additions & 0 deletions divi/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ BITCOIN_CORE_H = \
bip39.h \
bip39_english.h \
bloom.h \
blockmap.h\
chain.h \
chainparams.h \
chainparamsbase.h \
chainparamsseeds.h \
checkpoints.h \
checkpoint_data.h\
checkqueue.h \
clientversion.h \
coincontrol.h \
Expand Down Expand Up @@ -153,6 +155,7 @@ BITCOIN_CORE_H = \
script/standard.h \
script/script_error.h \
serialize.h \
Secp256k1Context.h \
spork.h \
sporkdb.h \
spentindex.h \
Expand Down Expand Up @@ -258,6 +261,7 @@ libbitcoin_wallet_a_SOURCES = \
obfuscation.cpp \
obfuscation-relay.cpp \
db.cpp \
crypto/aes.cpp \
crypter.cpp \
swifttx.cpp \
masternode.cpp \
Expand Down Expand Up @@ -381,6 +385,7 @@ libbitcoin_common_a_SOURCES = \
script/sign.cpp \
script/standard.cpp \
script/script_error.cpp \
Secp256k1Context.cpp \
spork.cpp \
sporkdb.cpp \
$(BITCOIN_CORE_H)
Expand Down
46 changes: 46 additions & 0 deletions divi/src/Secp256k1Context.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "Secp256k1Context.h"

#include <assert.h>
#include "random.h"
#include "allocators.h"

Secp256k1Context::Secp256k1Context()
{
assert(verifying_context == NULL);
verifying_context = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY);
assert(verifying_context != NULL);


assert(signing_context == NULL);
secp256k1_context *ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
assert(ctx != NULL);
{
// Pass in a random blinding seed to the secp256k1 context.
std::vector<unsigned char, secure_allocator<unsigned char>> vseed(32);
GetRandBytes(vseed.data(), 32);
bool ret = secp256k1_context_randomize(ctx, vseed.data());
assert(ret);
}
signing_context = ctx;
}
Secp256k1Context::~Secp256k1Context()
{
assert(verifying_context != NULL);
secp256k1_context_destroy(verifying_context);
verifying_context = NULL;

secp256k1_context *ctx = signing_context;
signing_context = NULL;
if (ctx) {
secp256k1_context_destroy(ctx);
}
}

secp256k1_context* Secp256k1Context::GetVerifyContext()
{
return verifying_context;
}
secp256k1_context* Secp256k1Context::GetSigningContext()
{
return signing_context;
}
24 changes: 24 additions & 0 deletions divi/src/Secp256k1Context.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef SECP256_K1_CONTEXT_H
#define SECP256_K1_CONTEXT_H
#include <secp256k1.h>
#include <secp256k1_recovery.h>

class Secp256k1Context
{
private:
secp256k1_context* verifying_context = NULL;
secp256k1_context* signing_context = NULL;

Secp256k1Context();
~Secp256k1Context();
public:
static Secp256k1Context& instance()
{
static Secp256k1Context uniqueInstance;
return uniqueInstance;
}

secp256k1_context* GetVerifyContext();
secp256k1_context* GetSigningContext();
};
#endif //SECP256_K1_CONTEXT_H
11 changes: 11 additions & 0 deletions divi/src/blockmap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef BLOCK_MAP_H
#define BLOCK_MAP_H
#include "chain.h"
#include <boost/unordered_map.hpp>
struct BlockHasher {
size_t operator()(const uint256& hash) const { return hash.GetLow64(); }
};
class BlockMap: public boost::unordered_map<uint256, CBlockIndex*, BlockHasher>
{
};
#endif // BLOCK_MAP_H
27 changes: 16 additions & 11 deletions divi/src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,30 @@ void MineGenesis(CBlock genesis)
// (no blocks before with a timestamp after, none after with
// timestamp before)
// + Contains no strange transactions
static Checkpoints::MapCheckpoints mapCheckpoints =
static MapCheckpoints mapCheckpoints =
boost::assign::map_list_of
(0, uint256("0x00000e258596876664989374c7ee36445cf5f4f80889af415cc32478214394ea"))
(100, uint256("0x000000275b2b4a8af2c93ebdfd36ef8dd8c8ec710072bcc388ecbf5d0c8d3f9d"));

static const Checkpoints::CCheckpointData data = {
static const CCheckpointData data = {
&mapCheckpoints,
1538069980, // * UNIX timestamp of last checkpoint block
100, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
2000 // * estimated number of transactions per day after checkpoint
};

static Checkpoints::MapCheckpoints mapCheckpointsTestnet =
static MapCheckpoints mapCheckpointsTestnet =
boost::assign::map_list_of(0, uint256("0x000000f351b8525f459c879f1e249b5d3d421b378ac6b760ea8b8e0df2454f33"));
static const Checkpoints::CCheckpointData dataTestnet = {
static const CCheckpointData dataTestnet = {
&mapCheckpointsTestnet,
1537971708,
0,
250};

static Checkpoints::MapCheckpoints mapCheckpointsRegtest =
static MapCheckpoints mapCheckpointsRegtest =
boost::assign::map_list_of(0, uint256("0x79ba0d9d15d36edee8d07cc300379ec65ab7e12765acd883e870aa618dbcc1a8"));
static const Checkpoints::CCheckpointData dataRegtest = {
static const CCheckpointData dataRegtest = {
&mapCheckpointsRegtest,
1518723178,
0,
Expand Down Expand Up @@ -275,7 +275,7 @@ class CMainParams : public CChainParams
nBudget_Fee_Confirmations = 6; // Number of confirmations for the finalization fee
}

const Checkpoints::CCheckpointData& Checkpoints() const
const CCheckpointData& Checkpoints() const
{
return data;
}
Expand Down Expand Up @@ -414,7 +414,7 @@ class CBetaParams : public CChainParams
nBudget_Fee_Confirmations = 6; // Number of confirmations for the finalization fee
}

const Checkpoints::CCheckpointData& Checkpoints() const
const CCheckpointData& Checkpoints() const
{
return data;
}
Expand Down Expand Up @@ -534,7 +534,7 @@ class CTestNetParams : public CMainParams
nBudget_Fee_Confirmations = 3; // Number of confirmations for the finalization fee. We have to make this very short
// here because we only have a 8 block finalization window on testnet
}
const Checkpoints::CCheckpointData& Checkpoints() const
const CCheckpointData& Checkpoints() const
{
return dataTestnet;
}
Expand Down Expand Up @@ -591,7 +591,7 @@ class CRegTestParams : public CTestNetParams
fMineBlocksOnDemand = true;
fTestnetToBeDeprecatedFieldRPC = false;
}
const Checkpoints::CCheckpointData& Checkpoints() const
const CCheckpointData& Checkpoints() const
{
return dataRegtest;
}
Expand Down Expand Up @@ -619,7 +619,7 @@ class CUnitTestParams : public CMainParams, public CModifiableParams
fMineBlocksOnDemand = true;
}

const Checkpoints::CCheckpointData& Checkpoints() const
const CCheckpointData& Checkpoints() const
{
// UnitTest share the same checkpoints as MAIN
return data;
Expand Down Expand Up @@ -652,6 +652,11 @@ const CChainParams& Params()
return *pCurrentParams;
}

const CCheckpointData& GetCurrentChainCheckpoints()
{
return Params().Checkpoints();
}

CChainParams& Params(CBaseChainParams::Network network)
{
switch (network) {
Expand Down
Loading

0 comments on commit c0fc4c8

Please sign in to comment.