Skip to content

Commit

Permalink
Merge commit '6e07786ebeccb0d527045a71d75da47f1a77f5df'
Browse files Browse the repository at this point in the history
  • Loading branch information
ynohtna92 committed Dec 2, 2023
2 parents 0052f28 + 6e07786 commit 4b8b2d5
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

[0.12.2](https://github.com/ordinals/ord/releases/tag/0.12.2) - 2023-11-29
--------------------------------------------------------------------------

### Added
- Bless cursed inscriptions after Jubilee height (#2656)

### Misc
- Hide /content/<INSCRIPTION_ID> HTML inscriptions (#2778)

[0.12.1](https://github.com/ordinals/ord/releases/tag/0.12.1) - 2023-11-29
--------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ord-litecoin"
description = "◉ Ordinal wallet and block explorer for litecoin"
version = "0.12.1"
version = "0.12.2"
license = "CC0-1.0"
edition = "2021"
autotests = false
Expand Down
1 change: 0 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ prepare-release revision='master':
git checkout -b release-$VERSION
git add -u
git commit -m "Release $VERSION"
git tag -a $VERSION -m "Release $VERSION"
gh pr create --web
publish-release revision='master':
Expand Down
9 changes: 9 additions & 0 deletions src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ impl Chain {
}
}

pub(crate) fn jubilee_height(self) -> u32 {
match self {
Self::Mainnet => 2608704,
Self::Regtest => 110,
Self::Signet => 3096576,
Self::Testnet => 3096576,
}
}

pub(crate) fn genesis_block(self) -> Block {
bitcoin::blockdata::constants::genesis_block(self.network())
}
Expand Down
57 changes: 57 additions & 0 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3050,6 +3050,63 @@ mod tests {
}
}

#[test]
fn inscriptions_are_uncursed_after_jubilee() {
for context in Context::configurations() {
context.mine_blocks(108);

let witness = envelope(&[
b"ord",
&[1],
b"text/plain;charset=utf-8",
&[1],
b"text/plain;charset=utf-8",
]);

let txid = context.rpc_server.broadcast_tx(TransactionTemplate {
inputs: &[(1, 0, 0, witness.clone())],
..Default::default()
});

let inscription_id = InscriptionId { txid, index: 0 };

context.mine_blocks(1);

assert_eq!(context.rpc_server.height(), 109);

assert_eq!(
context
.index
.get_inscription_entry(inscription_id)
.unwrap()
.unwrap()
.inscription_number,
-1
);

let txid = context.rpc_server.broadcast_tx(TransactionTemplate {
inputs: &[(2, 0, 0, witness)],
..Default::default()
});

let inscription_id = InscriptionId { txid, index: 0 };

context.mine_blocks(1);

assert_eq!(context.rpc_server.height(), 110);

assert_eq!(
context
.index
.get_inscription_entry(inscription_id)
.unwrap()
.unwrap()
.inscription_number,
0
);
}
}

#[test]
fn duplicate_field_inscriptions_are_cursed() {
for context in Context::configurations() {
Expand Down
1 change: 1 addition & 0 deletions src/index/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ impl<'index> Updater<'_> {

let mut inscription_updater = InscriptionUpdater {
blessed_inscription_count,
chain: self.index.options.chain(),
cursed_inscription_count,
flotsam: Vec::new(),
height: self.height,
Expand Down
5 changes: 4 additions & 1 deletion src/index/updater/inscription_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum Origin {

pub(super) struct InscriptionUpdater<'a, 'db, 'tx> {
pub(super) blessed_inscription_count: u64,
pub(super) chain: Chain,
pub(super) cursed_inscription_count: u64,
pub(super) flotsam: Vec<Flotsam>,
pub(super) height: u32,
Expand Down Expand Up @@ -135,7 +136,9 @@ impl<'a, 'db, 'tx> InscriptionUpdater<'a, 'db, 'tx> {

let inscribed_offset = inscribed_offsets.get(&offset);

let curse = if inscription.payload.unrecognized_even_field {
let curse = if self.height >= self.chain.jubilee_height() {
None
} else if inscription.payload.unrecognized_even_field {
Some(Curse::UnrecognizedEvenField)
} else if inscription.payload.duplicate_field {
Some(Curse::DuplicateField)
Expand Down
34 changes: 34 additions & 0 deletions src/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ impl Inscription {
}

pub(crate) fn hidden(&self) -> bool {
lazy_static! {
static ref CONTENT: Regex = Regex::new(r"^\s*/content/[[:xdigit:]]{64}i\d+\s*$").unwrap();
}

let Some(content_type) = self.content_type() else {
return true;
};
Expand All @@ -320,6 +324,16 @@ impl Inscription {
return true;
}

if content_type.starts_with("text/html")
&& self
.body()
.and_then(|body| str::from_utf8(body).ok())
.map(|body| CONTENT.is_match(body))
.unwrap_or_default()
{
return true;
}

false
}
}
Expand Down Expand Up @@ -796,6 +810,26 @@ mod tests {
case(Some("text/plain;charset=utf-8"), Some("foo"), true);
case(Some("text/plain;charset=cn-big5"), Some("foo"), true);
case(Some("application/json"), Some("foo"), true);
case(
Some("text/markdown"),
Some("/content/09a8d837ec0bcaec668ecf405e696a16bee5990863659c224ff888fb6f8f45e7i0"),
false,
);
case(
Some("text/html"),
Some("/content/09a8d837ec0bcaec668ecf405e696a16bee5990863659c224ff888fb6f8f45e7i0"),
true,
);
case(
Some("text/html;charset=utf-8"),
Some("/content/09a8d837ec0bcaec668ecf405e696a16bee5990863659c224ff888fb6f8f45e7i0"),
true,
);
case(
Some("text/html"),
Some(" /content/09a8d837ec0bcaec668ecf405e696a16bee5990863659c224ff888fb6f8f45e7i0 \n"),
true,
);

assert!(Inscription {
content_type: Some("text/plain".as_bytes().into()),
Expand Down
4 changes: 4 additions & 0 deletions test-bitcoincore-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ impl Handle {
self.state().broadcast_tx(template)
}

pub fn height(&self) -> u64 {
u64::try_from(self.state().blocks.len()).unwrap() - 1
}

pub fn invalidate_tip(&self) -> BlockHash {
self.state().pop_block()
}
Expand Down

0 comments on commit 4b8b2d5

Please sign in to comment.