Skip to content

Commit 9d66aa9

Browse files
authored
Merge pull request #1495 from psgreco/elem-23.3.1-rc2
Prepare 23.3.1rc2
2 parents aebe4e8 + ec67e56 commit 9d66aa9

Some content is hidden

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

64 files changed

+714
-359
lines changed

build_msvc/libelementssimplicity/libelementssimplicity.vcxproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
</PropertyGroup>
1010
<ItemGroup>
1111
<ClCompile Include="..\..\src\simplicity\bitstream.c" />
12-
<ClCompile Include="..\..\src\simplicity\cmr.c" />
1312
<ClCompile Include="..\..\src\simplicity\dag.c" />
1413
<ClCompile Include="..\..\src\simplicity\deserialize.c" />
1514
<ClCompile Include="..\..\src\simplicity\eval.c" />
@@ -20,11 +19,13 @@
2019
<ClCompile Include="..\..\src\simplicity\sha256.c" />
2120
<ClCompile Include="..\..\src\simplicity\type.c" />
2221
<ClCompile Include="..\..\src\simplicity\typeInference.c" />
23-
<ClCompile Include="..\..\src\simplicity\primitive\elements\env.c" />
24-
<ClCompile Include="..\..\src\simplicity\primitive\elements\exec.c" />
25-
<ClCompile Include="..\..\src\simplicity\primitive\elements\elementsJets.c" />
26-
<ClCompile Include="..\..\src\simplicity\primitive\elements\ops.c" />
27-
<ClCompile Include="..\..\src\simplicity\primitive\elements\primitive.c" />
22+
<ClCompile Include="..\..\src\simplicity\elements\cmr.c" />
23+
<ClCompile Include="..\..\src\simplicity\elements\env.c" />
24+
<ClCompile Include="..\..\src\simplicity\elements\exec.c" />
25+
<ClCompile Include="..\..\src\simplicity\elements\elementsJets.c" />
26+
<ClCompile Include="..\..\src\simplicity\elements\ops.c" />
27+
<ClCompile Include="..\..\src\simplicity\elements\primitive.c" />
28+
<ClCompile Include="..\..\src\simplicity\elements\txEnv.c" />
2829
</ItemGroup>
2930
<ItemDefinitionGroup>
3031
<ClCompile>

ci/test/04_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if [[ $QEMU_USER_CMD == qemu-s390* ]]; then
1111
fi
1212

1313
if [ "$CI_OS_NAME" == "macos" ]; then
14-
sudo -H pip3 install --upgrade --break-system-packages pip
14+
sudo -H pip3 install --upgrade --break-system-packages --ignore-installed pip
1515
# shellcheck disable=SC2086
1616
IN_GETOPT_BIN="$(brew --prefix gnu-getopt)/bin/getopt" ${CI_RETRY_EXE} pip3 install --user $PIP_PACKAGES
1717
fi

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, 1)
5-
define(_CLIENT_VERSION_RC, 1)
5+
define(_CLIENT_VERSION_RC, 2)
66
define(_CLIENT_VERSION_IS_RELEASE, true)
77
define(_COPYRIGHT_YEAR, 2025)
88
define(_COPYRIGHT_HOLDERS,[The %s developers])

doc/tapscript_opcodes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Taproot already increases a lot of resource limitations from segwitv0, so there
1717
1. **Streaming Opcodes for streaming hashes**: There is an existing limitation of `MAX_SCRIPT_ELEMENT_SIZE`(520 bytes) because of which we cannot operate hash functions like `OP_SHA256` on messages more than 520 bytes. This allows hashing on more than 520 bytes while still preserving the existing security against resource exhaustion attacks. The proposal for this by Russell O'Connor can be found in the description [here](https://github.com/ElementsProject/elements/pull/817).
1818
1. Define `OP_SUCCESS196` as `OP_SHA256INITIALIZE` which pops a bytestring and push SHA256 context creating by adding the bytestring to the initial SHA256 context.
1919
1. Define `OP_SUCCESS197` as `OP_SHA256UPDATE` which first pops a bytestring followed by another pop for SHA256 context and pushes an updated context by adding the bytestring to the data stream being hashed.
20-
1. Define `OP_SUCCESS198` as `OP_SHA256FINALIZE` which first pops a pops a bytestring followed by another pop for SHA256 context and finally pushes a SHA256 hash value after adding the bytestring and completing the padding.
20+
1. Define `OP_SUCCESS198` as `OP_SHA256FINALIZE` which first pops a bytestring followed by another pop for SHA256 context and finally pushes a SHA256 hash value after adding the bytestring and completing the padding.
2121

2222

2323
2. **Transaction Introspection codes**: Transaction introspection is already possible in elements script by use of `OP_CHECKSIGFROMSTACKVERIFY`, however the current solutions are really expensive in applications like [covenants](https://github.com/sanket1729/covenants-demo). Therefore, we are not adding any new functionality by supporting introspection, only making it easier to use. The warning still remains the same as with covenants, if the user is inspecting data from parts of the transaction that are not signed, the script can cause unexpected behavior.

src/chainparams.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ class CMainParams : public CChainParams {
227227
consensus.connect_genesis_outputs = false;
228228
consensus.subsidy_asset = CAsset();
229229
anyonecanspend_aremine = false;
230+
accept_unlimited_issuances = false;
230231
enforce_pak = false;
231232
multi_data_permitted = false;
232233
accept_discount_ct = false;
@@ -374,6 +375,7 @@ class CTestNetParams : public CChainParams {
374375
consensus.subsidy_asset = CAsset();
375376
anyonecanspend_aremine = false;
376377
enforce_pak = false;
378+
accept_unlimited_issuances = false;
377379
multi_data_permitted = false;
378380
accept_discount_ct = false;
379381
create_discount_ct = false;
@@ -538,6 +540,7 @@ class SigNetParams : public CChainParams {
538540
consensus.subsidy_asset = CAsset();
539541
anyonecanspend_aremine = false;
540542
enforce_pak = false;
543+
accept_unlimited_issuances = false;
541544
multi_data_permitted = false;
542545
accept_discount_ct = false;
543546
create_discount_ct = false;
@@ -641,6 +644,7 @@ class CRegTestParams : public CChainParams {
641644
consensus.subsidy_asset = CAsset();
642645
anyonecanspend_aremine = false;
643646
enforce_pak = false;
647+
accept_unlimited_issuances = false;
644648
multi_data_permitted = false;
645649
accept_discount_ct = false;
646650
create_discount_ct = false;
@@ -909,6 +913,8 @@ class CCustomParams : public CRegTestParams {
909913

910914
enforce_pak = args.GetBoolArg("-enforce_pak", false);
911915

916+
accept_unlimited_issuances = args.GetBoolArg("-acceptunlimitedissuances", accept_unlimited_issuances);
917+
912918
// Allow multiple op_return outputs by relay policy
913919
multi_data_permitted = args.GetBoolArg("-multi_data_permitted", enforce_pak);
914920

@@ -1167,6 +1173,8 @@ class CLiquidV1Params : public CChainParams {
11671173

11681174
enforce_pak = true;
11691175

1176+
accept_unlimited_issuances = false;
1177+
11701178
multi_data_permitted = true;
11711179
create_discount_ct = args.GetBoolArg("-creatediscountct", false);
11721180
accept_discount_ct = args.GetBoolArg("-acceptdiscountct", true) || create_discount_ct;
@@ -1525,6 +1533,8 @@ class CLiquidV1TestParams : public CLiquidV1Params {
15251533

15261534
enforce_pak = args.GetBoolArg("-enforce_pak", enforce_pak);
15271535

1536+
accept_unlimited_issuances = args.GetBoolArg("-acceptunlimitedissuances", accept_unlimited_issuances);
1537+
15281538
multi_data_permitted = args.GetBoolArg("-multi_data_permitted", multi_data_permitted);
15291539
create_discount_ct = args.GetBoolArg("-creatediscountct", create_discount_ct);
15301540
accept_discount_ct = args.GetBoolArg("-acceptdiscountct", accept_discount_ct) || create_discount_ct;

src/chainparams.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class CChainParams
134134
const std::string& ParentBech32HRP() const { return parent_bech32_hrp; }
135135
const std::string& ParentBlech32HRP() const { return parent_blech32_hrp; }
136136
bool GetEnforcePak() const { return enforce_pak; }
137+
bool GetAcceptUnlimitedIssuances() const { return accept_unlimited_issuances; }
137138
bool GetMultiDataPermitted() const { return multi_data_permitted; }
138139
bool GetAcceptDiscountCT() const { return accept_discount_ct; }
139140
bool GetCreateDiscountCT() const { return create_discount_ct; }
@@ -168,6 +169,7 @@ class CChainParams
168169
std::string parent_bech32_hrp;
169170
std::string parent_blech32_hrp;
170171
bool enforce_pak;
172+
bool accept_unlimited_issuances;
171173
bool multi_data_permitted;
172174
bool accept_discount_ct;
173175
bool create_discount_ct;

src/chainparamsbase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
6161
argsman.AddArg("-total_valid_epochs", "Per-chain parameter that sets how long a particular fedpegscript is in effect for.", ArgsManager::ALLOW_ANY, OptionsCategory::ELEMENTS);
6262
argsman.AddArg("-evbparams=deployment:start:end:period:threshold", "Use given start/end times for specified version bits deployment (regtest or custom only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::ELEMENTS);
6363
argsman.AddArg("-con_start_p2wsh_script", "Create p2wsh addresses when starting in dynafed mode (regtest or custom only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::ELEMENTS);
64+
argsman.AddArg("-acceptunlimitedissuances", "Allow unblinded issuance amounts to exceed 21 million units", ArgsManager::ALLOW_ANY, OptionsCategory::ELEMENTS);
6465
// END ELEMENTS
6566
//
6667
}

src/confidential_validation.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
#include <chainparams.h>
23
#include <confidential_validation.h>
34
#include <issuance.h>
45
#include <pegins.h>
@@ -30,8 +31,9 @@ bool HasValidFee(const CTransaction& tx) {
3031
CAmount fee = 0;
3132
if (tx.vout[i].IsFee()) {
3233
fee = tx.vout[i].nValue.GetAmount();
33-
if (fee == 0 || !MoneyRange(fee))
34+
if (fee == 0 || !MoneyRange(fee)) {
3435
return false;
36+
}
3537
totalFee[tx.vout[i].nAsset.GetAsset()] += fee;
3638
if (!MoneyRange(totalFee)) {
3739
return false;
@@ -102,14 +104,13 @@ static bool VerifyIssuanceAmount(secp256k1_pedersen_commitment& value_commit, se
102104

103105
// Build value commitment
104106
if (value.IsExplicit()) {
105-
if (!MoneyRange(value.GetAmount()) || value.GetAmount() == 0) {
107+
if ((asset == Params().GetConsensus().pegged_asset && !MoneyRange(value.GetAmount())) || value.GetAmount() <= 0) {
106108
return false;
107109
}
108110
if (!rangeproof.empty()) {
109111
return false;
110112
}
111113

112-
113114
ret = secp256k1_pedersen_commit(secp256k1_ctx_verify_amounts, &value_commit, explicit_blinds, value.GetAmount(), &asset_gen);
114115
// The explicit_blinds are all 0, and the amount is not 0. So secp256k1_pedersen_commit does not fail.
115116
assert(ret == 1);

src/key_io.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,14 @@ CTxDestination DecodeDestination(const std::string& str, const CChainParams& par
152152
uint160 hash;
153153
error_str = "";
154154

155+
bool is_bech32 = !(bech32::Decode(str).encoding == bech32::Encoding::INVALID);
156+
bool is_blech32 = !(blech32::Decode(str).encoding == blech32::Encoding::INVALID);
157+
155158
// Note this will be false if it is a valid Bech32 address for a different network
156-
bool is_bech32 = (ToLower(str.substr(0, params.Bech32HRP().size())) == params.Bech32HRP());
157-
bool is_blech32 = (ToLower(str.substr(0, params.Blech32HRP().size())) == params.Blech32HRP());
159+
bool is_bech32_hrp = (ToLower(str.substr(0, params.Bech32HRP().size())) == params.Bech32HRP());
160+
bool is_blech32_hrp = (ToLower(str.substr(0, params.Blech32HRP().size())) == params.Blech32HRP());
158161

159-
if (!is_bech32 && !is_blech32 && DecodeBase58Check(str, data, 55)) {
162+
if (!is_bech32 && !is_blech32 && !is_bech32_hrp && !is_blech32_hrp && DecodeBase58Check(str, data, 55)) {
160163
// base58-encoded Bitcoin addresses.
161164
// Public-key-hash-addresses have version 0 (or 111 testnet).
162165
// The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key.
@@ -206,14 +209,14 @@ CTxDestination DecodeDestination(const std::string& str, const CChainParams& par
206209
error_str = "Invalid prefix for Base58-encoded address";
207210
}
208211
return CNoDestination();
209-
} else if (!is_bech32 && !is_blech32) {
212+
} else if (!is_bech32 && !is_blech32 && !is_bech32_hrp && !is_blech32_hrp) {
210213
// Try Base58 decoding without the checksum, using a much larger max length
211214
if (!DecodeBase58(str, data, 100)) {
212215
error_str = "Not a valid Bech32 or Base58 encoding";
213216
} else {
214217
error_str = "Invalid checksum or length of Base58 address";
215218
}
216-
// return CNoDestination(); // ELEMENTS: FIXME
219+
return CNoDestination();
217220
}
218221

219222
data.clear();

src/policy/policy.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,20 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
308308
return true;
309309
}
310310

311+
bool IsIssuanceInMoneyRange(const CTransaction& tx)
312+
{
313+
for (size_t i = 0; i < tx.vin.size(); ++i) {
314+
const CAssetIssuance& issuance = tx.vin[i].assetIssuance;
315+
if (issuance.IsNull()) {
316+
continue;
317+
}
318+
if (issuance.nAmount.IsExplicit() && !MoneyRange(issuance.nAmount.GetAmount())) {
319+
return false;
320+
}
321+
}
322+
return true;
323+
}
324+
311325
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
312326
{
313327
return (std::max(nWeight, nSigOpCost * bytes_per_sigop) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR;

0 commit comments

Comments
 (0)