Skip to content

Commit ced5fd9

Browse files
authored
Merge pull request #1367 from psgreco/elem-23.2.4-rc1
Prepare 23.2.4 rc1
2 parents e29fd0a + bcf3a37 commit ced5fd9

File tree

5 files changed

+45
-24
lines changed

5 files changed

+45
-24
lines changed

configure.ac

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

src/core_write.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,12 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
239239
entry.pushKV("version", static_cast<int64_t>(static_cast<uint32_t>(tx.nVersion)));
240240
entry.pushKV("size", (int)::GetSerializeSize(tx, PROTOCOL_VERSION));
241241
entry.pushKV("vsize", (GetTransactionWeight(tx) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR);
242+
entry.pushKV("weight", GetTransactionWeight(tx));
242243
// ELEMENTS: add discountvsize
243244
if (Params().GetAcceptDiscountCT()) {
244245
entry.pushKV("discountvsize", GetDiscountVirtualTransactionSize(tx));
246+
entry.pushKV("discountweight", GetDiscountTransactionWeight(tx));
245247
}
246-
entry.pushKV("weight", GetTransactionWeight(tx));
247248
entry.pushKV("locktime", (int64_t)tx.nLockTime);
248249

249250
UniValue vin{UniValue::VARR};

src/policy/discount.h

+14-6
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
#include <version.h>
1313

1414
/**
15-
* Calculate a smaller virtual size for discounted Confidential Transactions.
15+
* Calculate a smaller weight for discounted Confidential Transactions.
1616
*/
17-
static inline int64_t GetDiscountVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost = 0, unsigned int bytes_per_sig_op = 0)
17+
static inline int64_t GetDiscountTransactionWeight(const CTransaction& tx, int64_t nSigOpCost = 0, unsigned int bytes_per_sig_op = 0)
1818
{
1919
int64_t size_bytes = ::GetSerializeSize(tx, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(tx, PROTOCOL_VERSION);
2020
int64_t sigop_bytes = nSigOpCost * bytes_per_sig_op;
2121

2222
int64_t weight = std::max(size_bytes, sigop_bytes);
2323

24-
// for each confidential output
2524
for (size_t i = 0; i < tx.vout.size(); ++i) {
2625
const CTxOut& output = tx.vout[i];
2726
if (i < tx.witness.vtxoutwit.size()) {
@@ -32,16 +31,25 @@ static inline int64_t GetDiscountVirtualTransactionSize(const CTransaction& tx,
3231
}
3332
if (output.nValue.IsCommitment()) {
3433
// subtract the weight difference of amount commitment (33) vs explicit amount (9)
35-
weight -= (33 - 9);
34+
// weighted as part of the base transaction
35+
weight -= (33 - 9) * WITNESS_SCALE_FACTOR;
3636
}
3737
if (output.nNonce.IsCommitment()) {
3838
// subtract the weight difference of nonce commitment (33) vs no nonce (1)
39-
weight -= 32;
39+
// weighted as part of the base transaction
40+
weight -= 32 * WITNESS_SCALE_FACTOR;
4041
}
4142
}
4243
assert(weight > 0);
44+
return weight;
45+
}
4346

44-
size_t discountvsize = (weight + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR;
47+
/**
48+
* Calculate a smaller virtual size for discounted Confidential Transactions.
49+
*/
50+
static inline int64_t GetDiscountVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost = 0, unsigned int bytes_per_sig_op = 0)
51+
{
52+
size_t discountvsize = (GetDiscountTransactionWeight(tx, nSigOpCost, bytes_per_sig_op) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR;
4553

4654
assert(discountvsize > 0);
4755
return discountvsize;

test/functional/feature_discount_ct.py

+22-10
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ def run_test(self):
7979
assert_equal(len(vout), 3)
8080
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00000326'))
8181
assert_equal(decoded['vsize'], 326)
82+
assert_equal(decoded['weight'], 1302)
8283
self.generate(node0, 1)
8384
tx = node1.getrawtransaction(txid, True)
85+
assert_equal(tx['discountweight'], 1302)
8486
assert_equal(tx['discountvsize'], 326)
8587

8688
self.log.info("Send confidential tx to node 0")
@@ -95,9 +97,11 @@ def run_test(self):
9597
assert_equal(len(vout), 3)
9698
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00002575'))
9799
assert_equal(decoded['vsize'], 2575)
100+
assert_equal(decoded['weight'], 10300)
98101
self.generate(node0, 1)
99102
tx = node1.getrawtransaction(txid, True)
100-
assert_equal(tx['discountvsize'], 410) # node1 has discountvsize
103+
assert_equal(tx['discountweight'], 1302)
104+
assert_equal(tx['discountvsize'], 326) # node1 has discountvsize
101105

102106
self.log.info("Send explicit tx to node 1")
103107
addr = node1.getnewaddress()
@@ -111,8 +115,10 @@ def run_test(self):
111115
assert_equal(len(vout), 3)
112116
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00000326'))
113117
assert_equal(decoded['vsize'], 326)
118+
assert_equal(decoded['weight'], 1302)
114119
self.generate(node0, 1)
115120
tx = node1.getrawtransaction(txid, True)
121+
assert_equal(tx['discountweight'], 1302)
116122
assert_equal(tx['discountvsize'], 326)
117123

118124
self.log.info("Send confidential (undiscounted) tx to node 1")
@@ -127,9 +133,11 @@ def run_test(self):
127133
assert_equal(len(vout), 3)
128134
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00002575'))
129135
assert_equal(decoded['vsize'], 2575)
136+
assert_equal(decoded['weight'], 10300)
130137
self.generate(node0, 1)
131138
tx = node1.getrawtransaction(txid, True)
132-
assert_equal(tx['discountvsize'], 410) # node1 has discountvsize
139+
assert_equal(tx['discountweight'], 1302)
140+
assert_equal(tx['discountvsize'], 326) # node1 has discountvsize
133141

134142
self.log.info("Send confidential (discounted) tx to node 1")
135143
bitcoin = 'b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23'
@@ -148,11 +156,13 @@ def run_test(self):
148156
assert_equal(len(vin), 2)
149157
assert_equal(len(vout), 3)
150158
if 'bitcoin' in decoded['fee']:
151-
assert_equal(decoded['fee']['bitcoin'], Decimal('-0.00000410'))
159+
assert_equal(decoded['fee']['bitcoin'], Decimal('-0.00000326'))
152160
else:
153-
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000410'))
161+
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000326'))
154162
assert_equal(decoded['vsize'], 2575)
155-
assert_equal(decoded['discountvsize'], 410)
163+
assert_equal(decoded['weight'], 10300)
164+
assert_equal(decoded['discountweight'], 1302)
165+
assert_equal(decoded['discountvsize'], 326)
156166

157167
# node0 only has vsize
158168
tx = node0.getrawtransaction(txid, True)
@@ -176,11 +186,13 @@ def run_test(self):
176186
assert_equal(len(vin), 2)
177187
assert_equal(len(vout), 3)
178188
if 'bitcoin' in decoded['fee']:
179-
assert_equal(decoded['fee']['bitcoin'], Decimal('-0.00000041'))
189+
assert_equal(decoded['fee']['bitcoin'], Decimal('-0.00000033'))
180190
else:
181-
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000041'))
191+
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000033'))
182192
assert_equal(decoded['vsize'], 2575)
183-
assert_equal(decoded['discountvsize'], 410)
193+
assert_equal(decoded['weight'], 10300)
194+
assert_equal(decoded['discountweight'], 1302)
195+
assert_equal(decoded['discountvsize'], 326)
184196
# node0 only has vsize
185197
tx = node0.getrawtransaction(txid, True)
186198
assert_equal(tx['vsize'], 2575)
@@ -207,7 +219,7 @@ def run_test(self):
207219
assert_equal(test[0]["allowed"], True)
208220
txid = node1.sendrawtransaction(signed['hex'])
209221
tx = node1.gettransaction(txid, True, True)
210-
assert_equal(tx['decoded']['discountvsize'], 341)
222+
assert_equal(tx['decoded']['discountvsize'], 257)
211223

212224
for i in range(24):
213225
self.log.info(f"Add package descendant {i+1}")
@@ -231,7 +243,7 @@ def run_test(self):
231243
assert_equal(test[0]["allowed"], True)
232244
txid = node1.sendrawtransaction(hex)
233245
tx = node1.gettransaction(txid, True, True)
234-
assert_equal(tx['decoded']['discountvsize'], 341)
246+
assert_equal(tx['decoded']['discountvsize'], 257)
235247
assert_equal(len(node1.getrawmempool()), i + 2)
236248

237249
assert_equal(len(node1.getrawmempool()), 25)

test/functional/feature_discount_ct_ordering.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def run_test(self):
113113
assert_equal(decoded['vsize'], 2575)
114114
self.sync_mempools([node0, node1])
115115
tx = node1.getrawtransaction(txid, True)
116-
assert_equal(tx['discountvsize'], 410)
116+
assert_equal(tx['discountvsize'], 326)
117117

118118
feerate = 1.0
119119
self.log.info(f"Send confidential (discounted) tx to node 1 at {feerate} sat/vb")
@@ -131,11 +131,11 @@ def run_test(self):
131131
assert_equal(len(vin), 2)
132132
assert_equal(len(vout), 3)
133133
if 'bitcoin' in decoded['fee']:
134-
assert_equal(decoded['fee']['bitcoin'], Decimal('-0.00000410'))
134+
assert_equal(decoded['fee']['bitcoin'], Decimal('-0.00000326'))
135135
else:
136-
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000410'))
136+
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000326'))
137137
assert_equal(decoded['vsize'], 2575)
138-
assert_equal(decoded['discountvsize'], 410)
138+
assert_equal(decoded['discountvsize'], 326)
139139

140140
feerate = 2.0
141141
self.log.info(f"Send confidential (discounted) tx to node 1 at {feerate} sat/vb")
@@ -145,7 +145,7 @@ def run_test(self):
145145
self.sync_mempools([node1, node2])
146146
tx = node1.gettransaction(txid, True, True)
147147
decoded = tx['decoded']
148-
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000820'))
148+
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000652'))
149149

150150
# check that txs in the block template are in decreasing feerate according to their discount size
151151
self.log.info("Check tx ordering in block template")

0 commit comments

Comments
 (0)