Skip to content

Commit

Permalink
Merge #242: update libsimplicity to 121b2951d8cca3d73dccd6fcbe721f219…
Browse files Browse the repository at this point in the history
…5025067

c9e70ed update libsimplicity to 121b2951d8cca3d73dccd6fcbe721f2195025067 (Andrew Poelstra)

Pull request description:

  This update renames a bunch of symbols from x to simplicity_x. This commit has a small number of non-mechanical changes to address that.

  The one "judgement call" was to update wrapper.h in accordance with BlockstreamResearch/simplicity#248 (comment) to cover all the jet wrapper renames.

Top commit has no ACKs.

Tree-SHA512: 5aed096de52aac26651f627f4754e02ebcc3394e846e524f03024c75a75e3af7739d69b243427bfac1c86448dbcfa479347b05104daf6892471c507daed88596
  • Loading branch information
apoelstra committed Aug 8, 2024
2 parents e42b267 + c9e70ed commit f2c7bd0
Show file tree
Hide file tree
Showing 55 changed files with 6,381 additions and 6,363 deletions.
2 changes: 1 addition & 1 deletion simplicity-sys/depend/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ void c_set_txEnv(txEnv *result, const transaction *tx, const tapEnv *taproot, co
{
sha256_midstate genesis;
sha256_toMidstate(genesis.s, genesisHash);
*result = build_txEnv(tx, taproot, &genesis, ix);
*result = simplicity_build_txEnv(tx, taproot, &genesis, ix);
}
2 changes: 1 addition & 1 deletion simplicity-sys/depend/simplicity-HEAD-revision.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This file has been automatically generated.
714b44dafd66ab5d164c9247a0f793c320272162
121b2951d8cca3d73dccd6fcbe721f2195025067
14 changes: 7 additions & 7 deletions simplicity-sys/depend/simplicity/bitstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Precondition: NULL != stream
*/
simplicity_err closeBitstream(bitstream* stream) {
simplicity_err simplicity_closeBitstream(bitstream* stream) {
if (1 < stream->len) return SIMPLICITY_ERR_BITSTREAM_TRAILING_BYTES; /* If there is more than one byte remaining. */
if (1 == stream->len) {
if (0 == stream->offset) return SIMPLICITY_ERR_BITSTREAM_TRAILING_BYTES; /* If there is one byte remaining */
Expand All @@ -30,7 +30,7 @@ simplicity_err closeBitstream(bitstream* stream) {
* Precondition: 0 <= n < 32
* NULL != stream
*/
int32_t readNBits(int n, bitstream* stream) {
int32_t simplicity_readNBits(int n, bitstream* stream) {
simplicity_assert(0 <= n && n < 32);

uint32_t result = 0;
Expand Down Expand Up @@ -109,7 +109,7 @@ static int32_t decodeUpto3Bits(int32_t* result, bitstream* stream) {
} else {
int32_t n = decodeUpto3(stream);
if (0 <= n) {
*result = readNBits(n, stream);
*result = simplicity_readNBits(n, stream);
if (*result < 0) return *result;
}
return n;
Expand Down Expand Up @@ -153,7 +153,7 @@ static int32_t decodeUpto15Bits(int32_t* result, bitstream* stream) {
} else {
int32_t n = decodeUpto15(stream);
if (0 <= n) {
*result = readNBits(n, stream);
*result = simplicity_readNBits(n, stream);
if (*result < 0) return *result;
}
return n;
Expand Down Expand Up @@ -184,7 +184,7 @@ static int32_t decodeUpto65535(bitstream* stream) {
*
* Precondition: NULL != stream
*/
int32_t decodeUptoMaxInt(bitstream* stream) {
int32_t simplicity_decodeUptoMaxInt(bitstream* stream) {
int32_t bit = read1Bit(stream);
if (bit < 0) return bit;
if (0 == bit) {
Expand All @@ -194,7 +194,7 @@ int32_t decodeUptoMaxInt(bitstream* stream) {
if (n < 0) return n;
if (30 < n) return SIMPLICITY_ERR_DATA_OUT_OF_RANGE;
{
int32_t result = readNBits(n, stream);
int32_t result = simplicity_readNBits(n, stream);
if (result < 0) return result;
return ((1 << n) | result);
}
Expand All @@ -211,7 +211,7 @@ int32_t decodeUptoMaxInt(bitstream* stream) {
* n <= 2^31
* NULL != stream
*/
simplicity_err readBitstring(bitstring* result, size_t n, bitstream* stream) {
simplicity_err simplicity_readBitstring(bitstring* result, size_t n, bitstream* stream) {
static_assert(0x80000000u + 2*(CHAR_BIT - 1) <= SIZE_MAX, "size_t needs to be at least 32-bits");
simplicity_assert(n <= 0x80000000u);
size_t total_offset = n + stream->offset;
Expand Down
10 changes: 5 additions & 5 deletions simplicity-sys/depend/simplicity/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static inline bitstream initializeBitstream(const unsigned char* arr, size_t len
*
* Precondition: NULL != stream
*/
simplicity_err closeBitstream(bitstream* stream);
simplicity_err simplicity_closeBitstream(bitstream* stream);

/* Fetches up to 31 bits from 'stream' as the 'n' least significant bits of return value.
* The 'n' bits are set from the MSB to the LSB.
Expand All @@ -45,15 +45,15 @@ simplicity_err closeBitstream(bitstream* stream);
* Precondition: 0 <= n < 32
* NULL != stream
*/
int32_t readNBits(int n, bitstream* stream);
int32_t simplicity_readNBits(int n, bitstream* stream);

/* Returns one bit from 'stream', 0 or 1.
* Returns 'SIMPLICITY_ERR_BITSTREAM_EOF' if no bits are available.
*
* Precondition: NULL != stream
*/
static inline int32_t read1Bit(bitstream* stream) {
return readNBits(1, stream);
return simplicity_readNBits(1, stream);
}

/* Decode an encoded number between 1 and 2^31 - 1 inclusive.
Expand All @@ -64,7 +64,7 @@ static inline int32_t read1Bit(bitstream* stream) {
*
* Precondition: NULL != stream
*/
int32_t decodeUptoMaxInt(bitstream* stream);
int32_t simplicity_decodeUptoMaxInt(bitstream* stream);

/* Fills a 'bitstring' containing 'n' bits from 'stream'.
* Returns 'SIMPLICITY_ERR_BITSTREAM_EOF' if not enough bits are available.
Expand All @@ -76,5 +76,5 @@ int32_t decodeUptoMaxInt(bitstream* stream);
* n <= 2^31
* NULL != stream
*/
simplicity_err readBitstring(bitstring* result, size_t n, bitstream* stream);
simplicity_err simplicity_readBitstring(bitstring* result, size_t n, bitstream* stream);
#endif
8 changes: 4 additions & 4 deletions simplicity-sys/depend/simplicity/cmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ bool simplicity_computeCmr( simplicity_err* error, unsigned char* cmr

bitstream stream = initializeBitstream(program, program_len);
dag_node* dag = NULL;
int32_t dag_len = decodeMallocDag(&dag, NULL, &stream);
int_fast32_t dag_len = simplicity_decodeMallocDag(&dag, NULL, &stream);
if (dag_len <= 0) {
simplicity_assert(dag_len < 0);
*error = dag_len;
*error = (simplicity_err)dag_len;
} else {
simplicity_assert(NULL != dag);
simplicity_assert((size_t)dag_len <= DAG_LEN_MAX);
*error = closeBitstream(&stream);
simplicity_assert((uint_fast32_t)dag_len <= DAG_LEN_MAX);
*error = simplicity_closeBitstream(&stream);
sha256_fromMidstate(cmr, dag[dag_len-1].cmr.s);
}

Expand Down
Loading

0 comments on commit f2c7bd0

Please sign in to comment.