Skip to content

Commit 5c0fb8f

Browse files
authored
Merge pull request #1431 from psgreco/elem-23.3.0rc5
Prepare 23.3.0rc5
2 parents f4e65b1 + 30eeffd commit 5c0fb8f

27 files changed

+115
-88
lines changed

build_msvc/bitcoind/bitcoind.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
<Target Name="AfterBuild">
5858
<Copy SourceFiles="$(ConfigIniIn)" DestinationFiles="$(ConfigIniOut)" ></Copy>
5959
<ReplaceInFile FilePath="$(ConfigIniOut)"
60-
Replace="@PACKAGE_NAME@" By="Bitcoin Core"></ReplaceInFile>
60+
Replace="@PACKAGE_NAME@" By="Elements Core"></ReplaceInFile>
6161
<ReplaceInFile FilePath="$(ConfigIniOut)"
62-
Replace="@PACKAGE_BUGREPORT@" By="https://github.com/bitcoin/bitcoin/issues"></ReplaceInFile>
62+
Replace="@PACKAGE_BUGREPORT@" By="https://github.com/ElementsProject/elements/issues"></ReplaceInFile>
6363
<ReplaceInFile FilePath="$(ConfigIniOut)"
6464
Replace="@abs_top_srcdir@" By="..\.." ToFullPath="true"></ReplaceInFile>
6565
<ReplaceInFile FilePath="$(ConfigIniOut)"

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ AC_PREREQ([2.69])
22
define(_CLIENT_VERSION_MAJOR, 23)
33
define(_CLIENT_VERSION_MINOR, 3)
44
define(_CLIENT_VERSION_BUILD, 0)
5-
define(_CLIENT_VERSION_RC, 4)
5+
define(_CLIENT_VERSION_RC, 5)
66
define(_CLIENT_VERSION_IS_RELEASE, true)
77
define(_COPYRIGHT_YEAR, 2024)
88
define(_COPYRIGHT_HOLDERS,[The %s developers])

src/block_proof.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static bool CheckProofGeneric(const CBlockHeader& block, const uint32_t max_bloc
4343
| SCRIPT_VERIFY_SIGPUSHONLY // Witness is push-only
4444
| SCRIPT_VERIFY_LOW_S // Stop easiest signature fiddling
4545
| SCRIPT_VERIFY_WITNESS // Witness and to enforce cleanstack
46-
| (is_dyna ? 0 : SCRIPT_NO_SIGHASH_BYTE); // Non-dynafed blocks do not have sighash byte
46+
| (is_dyna ? SCRIPT_VERIFY_NONE : SCRIPT_NO_SIGHASH_BYTE); // Non-dynafed blocks do not have sighash byte
4747
return GenericVerifyScript(scriptSig, witness, challenge, proof_flags, block);
4848
}
4949

src/net_processing.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,29 +2131,30 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
21312131
// If we are already too far ahead of where we want to be on headers, discard
21322132
// the received headers. We can still get ahead by up to a single maximum-sized
21332133
// headers message here, but never further, so that's fine.
2134-
if (pindexBestHeader) {
2135-
int64_t headers_ahead = pindexBestHeader->nHeight - m_chainman.ActiveHeight();
2136-
bool too_far_ahead = node::fTrimHeaders && (headers_ahead >= node::nHeaderDownloadBuffer);
2137-
if (too_far_ahead) {
2138-
LOCK(cs_main);
2139-
CNodeState *nodestate = State(pfrom.GetId());
2140-
if ((nodestate->pindexBestKnownBlock == nullptr) ||
2134+
if (node::fTrimHeaders) {
2135+
LOCK(cs_main);
2136+
if (pindexBestHeader) {
2137+
int64_t headers_ahead = pindexBestHeader->nHeight - m_chainman.ActiveHeight();
2138+
if (headers_ahead >= node::nHeaderDownloadBuffer) {
2139+
CNodeState *nodestate = State(pfrom.GetId());
2140+
if ((nodestate->pindexBestKnownBlock == nullptr) ||
21412141
(nodestate->pindexBestKnownBlock->nHeight < m_chainman.ActiveHeight())) {
2142-
// Our notion of what blocks a peer has available is based on its pindexBestKnownBlock,
2143-
// which is based on headers received from it. If we don't have one, or it's too old,
2144-
// then we can never get blocks from this peer until we accept headers from it first.
2145-
LogPrint(BCLog::NET, "NOT discarding headers from peer=%d, to update its block availability. (current best header %d, active chain height %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
2146-
} else {
2147-
LogPrint(BCLog::NET, "Discarding received headers and pausing header sync from peer=%d, because we are too far ahead of block sync. (%d > %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
2148-
if (nodestate->fSyncStarted) {
2149-
// Cancel sync from this node, so we don't penalize it later.
2150-
// This will cause us to automatically start syncing from a different node (or restart syncing from the same node) later,
2151-
// if we still need to sync headers.
2152-
nSyncStarted--;
2153-
nodestate->fSyncStarted = false;
2154-
nodestate->m_headers_sync_timeout = 0us;
2142+
// Our notion of what blocks a peer has available is based on its pindexBestKnownBlock,
2143+
// which is based on headers received from it. If we don't have one, or it's too old,
2144+
// then we can never get blocks from this peer until we accept headers from it first.
2145+
LogPrint(BCLog::NET, "NOT discarding headers from peer=%d, to update its block availability. (current best header %d, active chain height %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
2146+
} else {
2147+
LogPrint(BCLog::NET, "Discarding received headers and pausing header sync from peer=%d, because we are too far ahead of block sync. (%d > %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
2148+
if (nodestate->fSyncStarted) {
2149+
// Cancel sync from this node, so we don't penalize it later.
2150+
// This will cause us to automatically start syncing from a different node (or restart syncing from the same node) later,
2151+
// if we still need to sync headers.
2152+
nSyncStarted--;
2153+
nodestate->fSyncStarted = false;
2154+
nodestate->m_headers_sync_timeout = 0us;
2155+
}
2156+
return;
21552157
}
2156-
return;
21572158
}
21582159
}
21592160
}

src/primitives/confidential.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class CConfidentialValue : public CConfidentialCommitment<9, 8, 9>
149149
return -1;
150150
}
151151

152-
assert(IsExplicit());;
152+
assert(IsExplicit());
153153
return ReadBE64(&vchCommitment[1]);
154154
}
155155
void SetToAmount(CAmount nAmount);

src/rpc/request.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ static fs::path GetMainchainAuthCookieFile()
139139
if (gArgs.GetChainName() == "liquidv1") {
140140
cookie_file = ".cookie";
141141
}
142-
return fsbridge::AbsPathJoin(GetMainchainDefaultDataDir(), fs::PathFromString(gArgs.GetArg("-mainchainrpccookiefile", cookie_file)));
142+
fs::path cookie_path = fs::PathFromString(gArgs.GetArg("-mainchainrpccookiefile", cookie_file));
143+
if (cookie_path.is_absolute())
144+
return cookie_path;
145+
return fsbridge::AbsPathJoin(GetMainchainDefaultDataDir(), cookie_path);
143146
}
144147

145148
bool GetMainchainAuthCookie(std::string *cookie_out)
@@ -148,7 +151,7 @@ bool GetMainchainAuthCookie(std::string *cookie_out)
148151
std::string cookie;
149152

150153
std::filesystem::path filepath = GetMainchainAuthCookieFile();
151-
file.open(filepath.string().c_str());
154+
file.open(filepath);
152155
if (!file.is_open())
153156
return false;
154157
std::getline(file, cookie);

src/script/interpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,7 +2669,7 @@ void PrecomputedTransactionData::Init(const T& txTo, std::vector<CTxOut>&& spent
26692669
simplicityRawTx.version = txTo.nVersion;
26702670
simplicityRawTx.lockTime = txTo.nLockTime;
26712671

2672-
m_simplicity_tx_data = simplicity_elements_mallocTransaction(&simplicityRawTx);
2672+
m_simplicity_tx_data = SimplicityTransactionUniquePtr(simplicity_elements_mallocTransaction(&simplicityRawTx));
26732673

26742674
m_bip341_taproot_ready = true;
26752675
}
@@ -3121,7 +3121,7 @@ bool GenericTransactionSignatureChecker<T>::CheckSimplicity(const valtype& progr
31213121

31223122
assert(txdata->m_simplicity_tx_data);
31233123
assert(simplicityTapEnv);
3124-
if (!simplicity_elements_execSimplicity(&error, 0, txdata->m_simplicity_tx_data, nIn, simplicityTapEnv, txdata->m_hash_genesis_block.data(), budget, 0, program.data(), program.size(), witness.data(), witness.size())) {
3124+
if (!simplicity_elements_execSimplicity(&error, 0, txdata->m_simplicity_tx_data.get(), nIn, simplicityTapEnv, txdata->m_hash_genesis_block.data(), budget, 0, program.data(), program.size(), witness.data(), witness.size())) {
31253125
assert(!"simplicity_elements_execSimplicity internal error");
31263126
}
31273127
simplicity_elements_freeTapEnv(simplicityTapEnv);

src/script/interpreter.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,18 @@ enum : uint32_t {
169169

170170
bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror);
171171

172+
struct SimplicityTransactionDeleter
173+
{
174+
void operator()(transaction* ptr)
175+
{
176+
simplicity_elements_freeTransaction(ptr);
177+
}
178+
};
179+
using SimplicityTransactionUniquePtr = std::unique_ptr<transaction, SimplicityTransactionDeleter>;
180+
172181
struct PrecomputedTransactionData
173182
{
174-
transaction* m_simplicity_tx_data = nullptr;
183+
SimplicityTransactionUniquePtr m_simplicity_tx_data;
175184
// BIP341 precomputed data.
176185
// These are single-SHA256, see https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_note-15.
177186
uint256 m_prevouts_single_hash;
@@ -221,9 +230,6 @@ struct PrecomputedTransactionData
221230

222231
template <class T>
223232
explicit PrecomputedTransactionData(const T& tx);
224-
~PrecomputedTransactionData() {
225-
simplicity_elements_freeTransaction(m_simplicity_tx_data);
226-
}
227233
};
228234

229235
enum class SigVersion

src/simplicity/dag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ void simplicity_computeAnnotatedMerkleRoot(analyses* analysis, const dag_node* d
367367
}
368368

369369
/* Verifies that the 'dag' is in canonical order, meaning that nodes under the left branches have lower indices than nodes under
370-
* right branches, with the exception that nodes under right braches may (cross-)reference identical nodes that already occur under
370+
* right branches, with the exception that nodes under right branches may (cross-)reference identical nodes that already occur under
371371
* left branches.
372372
*
373373
* Returns 'SIMPLICITY_NO_ERROR' if the 'dag' is in canonical order, and returns 'SIMPLICITY_ERR_DATA_OUT_OF_ORDER' if it is not.
@@ -389,7 +389,7 @@ simplicity_err simplicity_verifyCanonicalOrder(dag_node* dag, const uint_fast32_
389389
/* We use dag[i].aux as a "stack" to manage the traversal of the DAG. */
390390
dag[top].aux = len; /* We will set top to 'len' to indicate we are finished. */
391391

392-
/* Each time any particular 'top' value is revisted in this loop, bottom has increased to be strictly larger than the last 'child'
392+
/* Each time any particular 'top' value is revisited in this loop, bottom has increased to be strictly larger than the last 'child'
393393
value examined. Therefore we will make further progress in the loop the next time around.
394394
By this reasoning any given 'top' value will be visited no more than numChildren(dag[top].tag) + 1 <= 3 times.
395395
Thus this loop iterates at most O('len') times.

src/simplicity/dag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void simplicity_computeCommitmentMerkleRoot(dag_node* dag, uint_fast32_t i);
350350
void simplicity_computeAnnotatedMerkleRoot(analyses* analysis, const dag_node* dag, const type* type_dag, uint_fast32_t len);
351351

352352
/* Verifies that the 'dag' is in canonical order, meaning that nodes under the left branches have lower indices than nodes under
353-
* right branches, with the exception that nodes under right braches may (cross-)reference identical nodes that already occur under
353+
* right branches, with the exception that nodes under right branches may (cross-)reference identical nodes that already occur under
354354
* left branches.
355355
*
356356
* Returns 'SIMPLICITY_NO_ERROR' if the 'dag' is in canonical order, and returns 'SIMPLICITY_ERR_DATA_OUT_OF_ORDER' if it is not.

src/simplicity/jets-secp256k1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ bool simplicity_hash_to_curve(frameItem* dst, frameItem src, const txEnv* env) {
714714
return true;
715715
}
716716

717-
/* THIS IS NOT A JET. It doesn't have the type signatue of a jet
717+
/* THIS IS NOT A JET. It doesn't have the type signature of a jet
718718
* This is a generic taptweak jet implementation parameterized by the tag used in the hash.
719719
* It is designed to be specialized to implement slightly different taptweak operations for Bitcoin and Elements.
720720
*

src/simplicity/jets.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ RIGHT_EXTEND_(32,64)
591591

592592
#define LEFT_SHIFT_(log, bits) \
593593
static inline void left_shift_helper_##bits(bool with, frameItem* dst, frameItem *src) { \
594-
static_assert(log <= 8, "Only log parameter upto 8 is supported."); \
594+
static_assert(log <= 8, "Only log parameter up to 8 is supported."); \
595595
uint_fast8_t amt = simplicity_read##log(src); \
596596
uint_fast##bits##_t output = simplicity_read##bits(src); \
597597
if (with) output = UINT##bits##_MAX ^ output; \
@@ -625,7 +625,7 @@ LEFT_SHIFT_(8,64)
625625

626626
#define RIGHT_SHIFT_(log, bits) \
627627
static inline void right_shift_helper_##bits(bool with, frameItem* dst, frameItem *src) { \
628-
static_assert(log <= 8, "Only log parameter upto 8 is supported."); \
628+
static_assert(log <= 8, "Only log parameter up to 8 is supported."); \
629629
uint_fast8_t amt = simplicity_read##log(src); \
630630
uint_fast##bits##_t output = simplicity_read##bits(src); \
631631
if (with) output = UINT##bits##_MAX ^ output; \
@@ -1046,7 +1046,7 @@ DIVIDES_(64)
10461046
/* Implements the 3n/2n division algorithm for n=32 bits.
10471047
* For more details see "Fast Recursive Division" by Christoph Burnikel and Joachim Ziegler, MPI-I-98-1-022, Oct. 1998.
10481048
*
1049-
* Given a 96 bit (unsigned) value A and a 64 bit value B, set *q and *r to the quotent and remainder of A divided by B.
1049+
* Given a 96 bit (unsigned) value A and a 64 bit value B, set *q and *r to the quotient and remainder of A divided by B.
10501050
*
10511051
* ah is passed the high 64 bits of A, and al is passed the low 32 bits of A.
10521052
* We say that A = [ah;al] where [ah;al] denotes ah * 2^32 + al.
@@ -1067,7 +1067,7 @@ DIVIDES_(64)
10671067
*
10681068
* Preconditon 2 ensures that this estimate is close to the true value of Q. In fact Q <= estQ <= Q + 2 (see proof below)
10691069
*
1070-
* There is a corresponding estR value satifying the equation estR = A - estQ * B.
1070+
* There is a corresponding estR value satisfying the equation estR = A - estQ * B.
10711071
* This estR is one of {R, R - B, R - 2B}.
10721072
* Therefore if estR is non-negative, then estR is equal to the true R value, and hence estQ is equal to the true Q value.
10731073
*
@@ -1085,7 +1085,7 @@ DIVIDES_(64)
10851085
*
10861086
* Lemma 2: estQ < [1;2] (== 2^32 + 2).
10871087
* First note that ah - [bh;0] < [1;0] because
1088-
* ah < B (by precondtion 1)
1088+
* ah < B (by precondition 1)
10891089
* < [bh+1;0]
10901090
* == [bh;0] + [1;0]
10911091
*
@@ -1116,7 +1116,7 @@ static void div_mod_96_64(uint_fast32_t *q, uint_fast64_t *r,
11161116
/* B == b == [bh;bl] */
11171117
uint_fast64_t estQ = ah / bh;
11181118

1119-
/* Precondition 1 guarentees Q is 32-bits, if estQ is greater than UINT32_MAX, then reduce our initial estimated quotient to UINT32_MAX. */
1119+
/* Precondition 1 guarantees Q is 32-bits, if estQ is greater than UINT32_MAX, then reduce our initial estimated quotient to UINT32_MAX. */
11201120
*q = estQ <= UINT32_MAX ? (uint_fast32_t)estQ : UINT32_MAX;
11211121

11221122
/* *q * bh <= estQ * bh <= ah */
@@ -1131,7 +1131,7 @@ static void div_mod_96_64(uint_fast32_t *q, uint_fast64_t *r,
11311131
* This value is negative when [rh;al] < d.
11321132
* Note that d is 64 bit and thus if rh is greater than UINT32_MAX, then this value cannot be negative.
11331133
*/
1134-
/* This loop is exectued at most twice. */
1134+
/* This loop is executed at most twice. */
11351135
while (rh <= UINT32_MAX && 0x100000000u*rh + al < d) {
11361136
/* Our estimated remainder, A - *q * B is negative. */
11371137
/* 0 < d == *q * bl and hence 0 < *q, so this decrement does not underflow. */
@@ -1173,7 +1173,7 @@ bool simplicity_div_mod_128_64(frameItem* dst, frameItem src, const txEnv* env)
11731173
* RR
11741174
*
11751175
* First divide the high 3 "digit"s (96-bits) of A by the two "digit"s (64-bits) of B,
1176-
* returning the first "digit" (high 32-bits) of the quotient, and an intermediate remainer consisiting of 2 "digit"s (64-bits).
1176+
* returning the first "digit" (high 32-bits) of the quotient, and an intermediate remainder consisiting of 2 "digit"s (64-bits).
11771177
*/
11781178
div_mod_96_64(&qh, &r, ah, am, b);
11791179
simplicity_debug_assert(r < b);
@@ -1187,8 +1187,8 @@ bool simplicity_div_mod_128_64(frameItem* dst, frameItem src, const txEnv* env)
11871187
* ---
11881188
* RR
11891189
*
1190-
* Then append the last "digit" of A to the intermidiate remainder and divide that value (96_bits) by the two "digit"s (64-bits) of B,
1191-
* returning the second "digit" (low 32-bits) of the quotient, and the final remainer consisiting of 2 "digit"s (64-bits).
1190+
* Then append the last "digit" of A to the intermediate remainder and divide that value (96_bits) by the two "digit"s (64-bits) of B,
1191+
* returning the second "digit" (low 32-bits) of the quotient, and the final remainder consisiting of 2 "digit"s (64-bits).
11921192
*/
11931193
div_mod_96_64(&ql, &r, r, al, b);
11941194
simplicity_write32(dst, qh);

src/simplicity/primitive/elements/env.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ static void copyOutput(sigOutput* result, opcode** allocation, size_t* allocatio
260260

261261
/* Tally a sorted list of feeOutputs
262262
*
263-
* Given a sorted array of feeOutput pointers, tally all the (explict) amounts of the entries with the same asset id,
263+
* Given a sorted array of feeOutput pointers, tally all the (explicit) amounts of the entries with the same asset id,
264264
* which are all necessarily next to each other, into the assetFee field of the first entry of the bunch.
265265
*
266266
* Discard all entries other than the first one of each bunch.
267-
* Return 'ret_value', the number of remaning entries in the array after these discards.
267+
* Return 'ret_value', the number of remaining entries in the array after these discards.
268268
*
269269
* Note: the array is not re-allocated, so there will be "junk" values in the array past the end of 'ret_value'.
270270
*
@@ -497,7 +497,7 @@ extern transaction* simplicity_elements_mallocTransaction(const rawTransaction*
497497
uint_fast32_t ix_fee = 0;
498498

499499
/* perm is a temporary array the same length (numFees) and size as feeOutputs.
500-
* perm is used to initalize feeOutputs and is not used afterward.
500+
* perm is used to initialize feeOutputs and is not used afterward.
501501
* This makes it safe for perm to use the same memory allocation as feeOutputs.
502502
*/
503503
static_assert(sizeof(const sha256_midstate*) == sizeof(sigOutput*), "Pointers (to structures) ought to have the same size.");
@@ -528,8 +528,8 @@ extern transaction* simplicity_elements_mallocTransaction(const rawTransaction*
528528
/* Initialize the feeOutputs array from the perm array.
529529
* Because the perm array entries are the same size as the feeOutputs array entries, it is safe to initialize one by one.
530530
*
531-
* In practical C implementations, the feeOutputs array entires are initalized to the same value as the perm array entries.
532-
* In practical C implementations, this is a no-op, and generally compiliers are able to see this fact and eliminate this loop.
531+
* In practical C implementations, the feeOutputs array entries are initialized to the same value as the perm array entries.
532+
* In practical C implementations, this is a no-op, and generally compilers are able to see this fact and eliminate this loop.
533533
*
534534
* We keep the loop in the code just to be pedantic.
535535
*/
@@ -652,7 +652,7 @@ extern void simplicity_elements_freeTapEnv(tapEnv* env) {
652652
simplicity_free(env);
653653
}
654654

655-
/* Contstruct a txEnv structure from its components.
655+
/* Construct a txEnv structure from its components.
656656
* This function will precompute any cached values.
657657
*
658658
* Precondition: NULL != tx

src/simplicity/primitive/elements/primitive.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ typedef struct tapEnv {
248248
unsigned char leafVersion;
249249
} tapEnv;
250250

251-
/* The 'txEnv' structure used by the Elements application of Simplcity.
251+
/* The 'txEnv' structure used by the Elements application of Simplicity.
252252
*
253253
* It includes
254254
* + the transaction data, which may be shared when Simplicity expressions are used for multiple inputs in the same transaction),
@@ -263,7 +263,7 @@ typedef struct txEnv {
263263
uint_fast32_t ix;
264264
} txEnv;
265265

266-
/* Contstruct a txEnv structure from its components.
266+
/* Construct a txEnv structure from its components.
267267
* This function will precompute any cached values.
268268
*
269269
* Precondition: NULL != tx

0 commit comments

Comments
 (0)