Skip to content

Commit 88f8bf5

Browse files
authored
Merge pull request #33 from MarathonDH/fix-image-prune
add asset type 2, remove blob node storage outside of block, and add block blob storage along with TX blob storage.
2 parents 44337bf + 610e045 commit 88f8bf5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+667
-518
lines changed

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
LABEL maintainer="michael.casey@mara.com"
55
LABEL version="0.1"
6-
LABEL description="Docker file for mara federation"
6+
LABEL description="Docker file for anduro"
77

88
ARG DEBIAN_FRONTEND=noninteractive
99

@@ -27,13 +27,13 @@
2727

2828

2929
#Setup base directory
30-
RUN mkdir -p /opt/marachain
31-
WORKDIR /opt/marachain
30+
RUN mkdir -p /opt/coordinate
31+
WORKDIR /opt/coordinate
3232

3333
COPY . ./
3434

3535
#Configure sidechain node
36-
WORKDIR /opt/marachain
36+
WORKDIR /opt/coordinate
3737
RUN ./autogen.sh \
3838
&& ./configure --without-gui \
3939
&& make

entrypoint.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/Makefile.am

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ BITCOIN_CORE_H = \
122122
addrman_impl.h \
123123
attributes.h \
124124
auxpow.h \
125-
federation_deposit.h \
126-
chroma_assets.h \
125+
anduro_deposit.h \
126+
coordinate_assets.h \
127+
coordinate_mempool_entry.h \
127128
banman.h \
128129
base58.h \
129130
bech32.h \
@@ -249,7 +250,7 @@ BITCOIN_CORE_H = \
249250
rpc/server.h \
250251
rpc/server_util.h \
251252
rpc/util.h \
252-
rpc/marachainrpc.h \
253+
rpc/coordinaterpc.h \
253254
scheduler.h \
254255
script/descriptor.h \
255256
script/keyorigin.h \
@@ -420,7 +421,7 @@ libbitcoin_node_a_SOURCES = \
420421
rpc/blockchain.cpp \
421422
rpc/fees.cpp \
422423
rpc/mempool.cpp \
423-
rpc/marachainrpc.cpp \
424+
rpc/coordinaterpc.cpp \
424425
rpc/mining.cpp \
425426
rpc/net.cpp \
426427
rpc/node.cpp \
@@ -643,9 +644,10 @@ libbitcoin_common_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLA
643644
libbitcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
644645
libbitcoin_common_a_SOURCES = \
645646
auxpow.cpp \
646-
federation_deposit.cpp \
647-
chroma/chroma_assets.cpp \
648-
federation_validator.cpp \
647+
anduro_deposit.cpp \
648+
coordinate/coordinate_assets.cpp \
649+
coordinate/coordinate_mempool_entry.cpp \
650+
anduro_validator.cpp \
649651
base58.cpp \
650652
bech32.cpp \
651653
chainparams.cpp \
@@ -905,9 +907,10 @@ libbitcoinkernel_la_SOURCES = \
905907
kernel/bitcoinkernel.cpp \
906908
arith_uint256.cpp \
907909
auxpow.cpp \
908-
federation_deposit.cpp \
909-
chroma/chroma_assets.cpp \
910-
federation_validator.cpp \
910+
anduro_deposit.cpp \
911+
coordinate/coordinate_assets.cpp \
912+
coordinate/coordinate_mempool_entry.cpp \
913+
anduro_validator.cpp \
911914
chain.cpp \
912915
chainparamsbase.cpp \
913916
chainparams.cpp \
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,46 @@
99
#include <node/blockstorage.h>
1010
#include <rpc/util.h>
1111
#include <rpc/client.h>
12-
#include <federation_deposit.h>
13-
#include <federation_validator.h>
12+
#include <anduro_deposit.h>
13+
#include <anduro_validator.h>
1414

1515
using node::BlockManager;
1616
using node::ReadBlockFromDisk;
1717
// temporary storage for including presigned signature on next block
18-
std::vector<FederationTxOut> tDeposits;
19-
// check blocks are fully synced to active federation presign validation
18+
std::vector<AnduroTxOut> tDeposits;
19+
// check blocks are fully synced to active anduro presign validation
2020
bool isValidationActivate = false;
2121
// temporary storage for deposit address
2222
std::string depositAddress = "";
2323
// temporary storage for withdraw address
2424
std::string burnAddress = "";
2525

2626
/**
27-
* Include presigned signature from federation.
27+
* Include presigned signature from anduro.
2828
*/
29-
void includePreSignedSignature(std::vector<FederationTxOut> txOuts) {
29+
void includePreSignedSignature(std::vector<AnduroTxOut> txOuts) {
3030
if (txOuts.size() == 0) {
3131
return;
3232
}
3333
if(!isSignatureAlreadyExist(txOuts[0])) {
34-
for (const FederationTxOut& tx : txOuts) {
34+
for (const AnduroTxOut& tx : txOuts) {
3535
tDeposits.push_back(tx);
3636
depositAddress = tx.depositAddress;
3737
burnAddress = tx.burnAddress;
3838
}
3939
}
4040
}
4141

42-
bool isSignatureAlreadyExist(FederationTxOut txOut) {
42+
bool isSignatureAlreadyExist(AnduroTxOut txOut) {
4343
bool isExist = false;
44-
std::vector<FederationTxOut> pending_deposits = listPendingDepositTransaction(txOut.block_height);
44+
std::vector<AnduroTxOut> pending_deposits = listPendingDepositTransaction(txOut.block_height);
4545
if(pending_deposits.size() > 0) {
4646
isExist = true;
4747
}
4848
return isExist;
4949
}
5050

51-
bool isSpecialTxoutValid(std::vector<FederationTxOut> txOuts, ChainstateManager& chainman) {
51+
bool isSpecialTxoutValid(std::vector<AnduroTxOut> txOuts, ChainstateManager& chainman) {
5252

5353
if(txOuts.size()==0) {
5454
return false;
@@ -59,7 +59,7 @@ bool isSpecialTxoutValid(std::vector<FederationTxOut> txOuts, ChainstateManager&
5959
if(txOuts[0].block_height <= blockindex) {
6060
blockindex = blockindex - 1;
6161
}
62-
// get block to find the eligible federation keys to be signed on presigned block
62+
// get block to find the eligible anduro keys to be signed on presigned block
6363
CBlock block;
6464
if (!ReadBlockFromDisk(block, CHECK_NONFATAL(active_chain[blockindex]), Params().GetConsensus())) {
6565
LogPrintf("Error reading block from disk at index %d\n", CHECK_NONFATAL(active_chain[blockindex])->GetBlockHash().ToString());
@@ -68,7 +68,7 @@ bool isSpecialTxoutValid(std::vector<FederationTxOut> txOuts, ChainstateManager&
6868
UniValue messages(UniValue::VARR);
6969
int tIndex = 1;
7070
// preparing message for signature verification
71-
for (const FederationTxOut& txOut : txOuts) {
71+
for (const AnduroTxOut& txOut : txOuts) {
7272

7373
CTxDestination address;
7474
ExtractDestination(txOut.scriptPubKey, address);
@@ -84,7 +84,7 @@ bool isSpecialTxoutValid(std::vector<FederationTxOut> txOuts, ChainstateManager&
8484
messages.push_back(message);
8585
}
8686
// check signature is valid
87-
bool isValid = validateFederationSignature(txOuts[0].witness,messages.write(),block.currentKeys);
87+
bool isValid = validateAnduroSignature(txOuts[0].witness,messages.write(),block.currentKeys);
8888

8989
if (isValid) {
9090
return true;
@@ -96,13 +96,13 @@ bool isSpecialTxoutValid(std::vector<FederationTxOut> txOuts, ChainstateManager&
9696
/**
9797
* This function list all presigned pegin details for upcoming blocks by height
9898
*/
99-
std::vector<FederationTxOut> listPendingDepositTransaction(uint32_t block_height) {
99+
std::vector<AnduroTxOut> listPendingDepositTransaction(uint32_t block_height) {
100100
if(block_height == -1) {
101101
return tDeposits;
102102
}
103103

104-
std::vector<FederationTxOut> tDepositsNew;
105-
for (const FederationTxOut& tx_out : tDeposits) {
104+
std::vector<AnduroTxOut> tDepositsNew;
105+
for (const AnduroTxOut& tx_out : tDeposits) {
106106
if(tx_out.block_height == block_height) {
107107
tDepositsNew.push_back(tx_out);
108108
}
@@ -115,19 +115,19 @@ std::vector<FederationTxOut> listPendingDepositTransaction(uint32_t block_height
115115
* This function find total pegin amount for particular block
116116
*/
117117
CAmount listPendingDepositTotal(uint32_t block_height) {
118-
std::vector<FederationTxOut> tDepositsNew;
118+
std::vector<AnduroTxOut> tDepositsNew;
119119
if(block_height == -1) {
120120
tDepositsNew = tDeposits;
121121
} else {
122-
for (const FederationTxOut& tx_out : tDeposits) {
122+
for (const AnduroTxOut& tx_out : tDeposits) {
123123
if(tx_out.block_height == block_height) {
124124
tDepositsNew.push_back(tx_out);
125125
}
126126
}
127127
}
128128

129129
CAmount totalDeposit = CAmount(0);
130-
for (const FederationTxOut& txOut: tDepositsNew) {
130+
for (const AnduroTxOut& txOut: tDepositsNew) {
131131
totalDeposit = totalDeposit + CAmount(txOut.nValue);
132132
}
133133

@@ -138,17 +138,17 @@ CAmount listPendingDepositTotal(uint32_t block_height) {
138138
* Used to reset presigned signature for processed blocks
139139
*/
140140
void resetDeposit(uint32_t block_height) {
141-
std::vector<FederationTxOut> tDepositsNew;
141+
std::vector<AnduroTxOut> tDepositsNew;
142142
bool hasDeposits = true;
143143
uint32_t currentHeight = block_height;
144144
while(hasDeposits) {
145-
for (const FederationTxOut& tx_out : tDeposits) {
145+
for (const AnduroTxOut& tx_out : tDeposits) {
146146
if(tx_out.block_height != block_height) {
147147
tDepositsNew.push_back(tx_out);
148148
}
149149
}
150150
currentHeight = currentHeight - 1;
151-
std::vector<FederationTxOut> pending_deposits = listPendingDepositTransaction(currentHeight);
151+
std::vector<AnduroTxOut> pending_deposits = listPendingDepositTransaction(currentHeight);
152152
if(pending_deposits.size() == 0) {
153153
hasDeposits = false;
154154
}
@@ -188,36 +188,36 @@ int32_t getNextIndex(ChainstateManager& chainman) {
188188
}
189189

190190
/**
191-
* Check block are fully synced to start validating federation new presigned signature for upcoming blocks
191+
* Check block are fully synced to start validating anduro new presigned signature for upcoming blocks
192192
*/
193-
bool isFederationValidationActive() {
193+
bool isAnduroValidationActive() {
194194
return isValidationActivate;
195195
}
196196

197197
/**
198-
* Validate the federation signature on confirmed blocks
198+
* Validate the anduro signature on confirmed blocks
199199
*/
200-
bool verifyFederation(ChainstateManager& chainman, const CBlock& block) {
200+
bool verifyAnduro(ChainstateManager& chainman, const CBlock& block) {
201201
LOCK(cs_main);
202202
CChain& active_chain = chainman.ActiveChain();
203203
// activate presigned signature checker after blocks fully synced in node
204204
if(listPendingDepositTransaction(active_chain.Height()+1).size()>0) {
205205
isValidationActivate = true;
206206
}
207207

208-
if(!isFederationValidationActive()) {
208+
if(!isAnduroValidationActive()) {
209209
return true;
210210
}
211211

212212
// check coinbase should have three output
213213
// 0 - fee reward for merge mine
214214
// 1 - coinbase message
215-
// 2 - signature by previous block federation current keys
215+
// 2 - signature by previous block anduro current keys
216216
if(block.vtx[0]->vout.size() < 3) {
217217
return false;
218218
}
219219

220-
// check for current keys for federation
220+
// check for current keys for anduro
221221
CBlock prevblock;
222222
if (!ReadBlockFromDisk(prevblock, CHECK_NONFATAL(active_chain[active_chain.Height()]), Params().GetConsensus())) {
223223
return false;
@@ -235,17 +235,17 @@ bool verifyFederation(ChainstateManager& chainman, const CBlock& block) {
235235

236236
const std::string witnessStr = ScriptToAsmStr(witnessOut.scriptPubKey).replace(0,10,"");
237237

238-
std::vector<FederationTxOut> tOuts;
238+
std::vector<AnduroTxOut> tOuts;
239239
if(block.vtx[0]->vout.size() == 3) {
240240
const CTxDestination coinbaseScript = DecodeDestination(find_value(witnessVal.get_obj(), "current_address").get_str());
241241
const CScript scriptPubKey = GetScriptForDestination(coinbaseScript);
242-
FederationTxOut out(AmountFromValue(0), scriptPubKey, witnessStr, active_chain.Height() + 1,block.nextIndex,block.currentKeys, "", "");
242+
AnduroTxOut out(AmountFromValue(0), scriptPubKey, witnessStr, active_chain.Height() + 1,block.nextIndex,block.currentKeys, "", "");
243243
tOuts.push_back(out);
244244
} else {
245-
// if more than 3 output in coinbase should be considered as pegin and recreating presigned signature for pegin to verify with federation current keys
245+
// if more than 3 output in coinbase should be considered as pegin and recreating presigned signature for pegin to verify with anduro current keys
246246
for (size_t i = 1; i < block.vtx[0]->vout.size()-2; i=i+1) {
247247
CTxOut pegTx = block.vtx[0]->vout[i];
248-
FederationTxOut out(pegTx.nValue, pegTx.scriptPubKey, witnessStr, active_chain.Height() + 1,block.nextIndex,block.currentKeys, "", "");
248+
AnduroTxOut out(pegTx.nValue, pegTx.scriptPubKey, witnessStr, active_chain.Height() + 1,block.nextIndex,block.currentKeys, "", "");
249249
tOuts.push_back(out);
250250
}
251251
}
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
#include <util/message.h>
2121

2222
/**
23-
* This is call is used to receive or prepare federation presigned signature data along with federation deposit and withdrawal address
23+
* This is call is used to receive or prepare anduro presigned signature data along with anduro deposit and withdrawal address
2424
*/
25-
class FederationTxOut
25+
class AnduroTxOut
2626
{
2727
public:
2828
CAmount nValue; /*!< amount going to process as pegin in sidechain */
2929
CScript scriptPubKey; /*!< script pubkey to receive the pegin amount in sidechain */
3030
std::string witness; /*!< presigned signature information */
3131
int32_t block_height; /*!< block height where the presigned signature belong to */
3232
std::string currentKeys; /*!< next key going to be included in block header */
33-
int32_t nextIndex; /*!< next derivation index going to be include in block header. This index is refer back by federation and identify the current derivation path to be signed*/
33+
int32_t nextIndex; /*!< next derivation index going to be include in block header. This index is refer back by anduro and identify the current derivation path to be signed*/
3434
std::string depositAddress; /*!< hold current deposit address from bitcoin */
3535
std::string burnAddress; /*!< hold current withdrawal address from sidechain */
3636

37-
FederationTxOut()
37+
AnduroTxOut()
3838
{
3939
SetNull();
4040
}
@@ -49,7 +49,7 @@ class FederationTxOut
4949
* @param[in] depositAddressIn hold current deposit address from bitcoin
5050
* @param[in] burnAddressIn hold current withdrawal address from sidechain
5151
*/
52-
FederationTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn, std::string witnessIn, int32_t block_heightIn, int32_t nextIndexIn, std::string currentKeysIn, std::string depositAddressIn, std::string burnAddressIn) {
52+
AnduroTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn, std::string witnessIn, int32_t block_heightIn, int32_t nextIndexIn, std::string currentKeysIn, std::string depositAddressIn, std::string burnAddressIn) {
5353
nValue = nValueIn;
5454
scriptPubKey = scriptPubKeyIn;
5555
witness = witnessIn;
@@ -60,7 +60,7 @@ class FederationTxOut
6060
burnAddress = burnAddressIn;
6161
}
6262

63-
SERIALIZE_METHODS(FederationTxOut, obj) {
63+
SERIALIZE_METHODS(AnduroTxOut, obj) {
6464
READWRITE(obj.nValue, obj.scriptPubKey, obj.witness, obj.block_height, obj.currentKeys, obj.nextIndex, obj.depositAddress, obj.burnAddress);
6565
}
6666

@@ -88,35 +88,35 @@ std::string getDepositAddress();
8888
std::string getBurnAddress();
8989

9090
/**
91-
* This function include presigned signature from federation
91+
* This function include presigned signature from anduro
9292
* @param[in] txOuts hold three block presigned signature.
9393
*/
94-
void includePreSignedSignature(std::vector<FederationTxOut> txOuts);
94+
void includePreSignedSignature(std::vector<AnduroTxOut> txOuts);
9595

9696
/**
97-
* This function check block are fully synced to start validating federation new presigned signature for upcoming blocks
97+
* This function check block are fully synced to start validating anduro new presigned signature for upcoming blocks
9898
*/
99-
bool isFederationValidationActive();
99+
bool isAnduroValidationActive();
100100

101101
/**
102-
* validate the federation signature on confirmed blocks
103-
* @param[in] chainman used to find previous blocks based on active chain state to find federation current keys
102+
* validate the anduro signature on confirmed blocks
103+
* @param[in] chainman used to find previous blocks based on active chain state to find anduro current keys
104104
* @param[in] block current block received from connectblock
105105
*/
106-
bool verifyFederation(ChainstateManager& chainman, const CBlock& block);
106+
bool verifyAnduro(ChainstateManager& chainman, const CBlock& block);
107107

108108
/**
109109
* This function check presigned signatures are valid
110110
* @param[in] txOuts presigned signature for validation
111111
* @param[in] chainman used to find next block number and active chain state
112112
*/
113-
bool isSpecialTxoutValid(std::vector<FederationTxOut> txOuts, ChainstateManager& chainman);
113+
bool isSpecialTxoutValid(std::vector<AnduroTxOut> txOuts, ChainstateManager& chainman);
114114

115115
/**
116116
* This function list all presigned pegin details for upcoming blocks by height
117117
* @param[in] block_height block height to find pending pegin
118118
*/
119-
std::vector<FederationTxOut> listPendingDepositTransaction(uint32_t block_height);
119+
std::vector<AnduroTxOut> listPendingDepositTransaction(uint32_t block_height);
120120

121121
/**
122122
* This function find total pegin amount for particular block
@@ -128,7 +128,7 @@ CAmount listPendingDepositTotal(uint32_t block_height);
128128
* This function used to check whether presigned signature already exist when received signature through peer message
129129
* @param[in] txOut presigned signature details
130130
*/
131-
bool isSignatureAlreadyExist(FederationTxOut txOut);
131+
bool isSignatureAlreadyExist(AnduroTxOut txOut);
132132

133133
/**
134134
* This function used to reset presigned signature for processed blocks

0 commit comments

Comments
 (0)