Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add transaction serialization check
- Add max transaction size check
- Add from_block & to_block params to `full_moonlight_history` in archive [#3613]

## [1.2.0] - 2025-03-20

Expand Down Expand Up @@ -48,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- First `dusk-node` release

<!-- Issues -->
[#3613]: https://github.com/dusk-network/rusk/issues/3613
[#3491]: https://github.com/dusk-network/rusk/issues/3491
[#3359]: https://github.com/dusk-network/rusk/issues/3359
[#3407]: https://github.com/dusk-network/rusk/issues/3407
Expand Down
47 changes: 34 additions & 13 deletions node/src/archive/moonlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,22 +250,24 @@ impl Archive {
&self,
pk: AccountPublicKey,
ord: Option<Order>,
from_block: Option<u64>,
to_block: Option<u64>,
) -> Result<Option<Vec<MoonlightGroup>>> {
let order = ord.unwrap_or(Order::Ascending);

let inflows = self.fetch_moonlight_history(
Some(pk),
None,
None,
None,
from_block,
to_block,
None,
None,
)?;
let outflows = self.fetch_moonlight_history(
None,
Some(pk),
None,
None,
from_block,
to_block,
None,
None,
)?;
Expand Down Expand Up @@ -1039,7 +1041,10 @@ mod tests {
let archive = Archive::create_or_open(path).await;

let pk = AccountPublicKey::default();
assert!(archive.full_moonlight_history(pk, None).unwrap().is_none());
assert!(archive
.full_moonlight_history(pk, None, None, None, None)
.unwrap()
.is_none());

let block_events = block_events();

Expand All @@ -1064,8 +1069,10 @@ mod tests {
fetched_moonlight_tx.dedup();
assert_eq!(fetched_moonlight_tx.len(), 6);

let fetched_events =
archive.full_moonlight_history(pk, None).unwrap().unwrap();
let fetched_events = archive
.full_moonlight_history(pk, None, None, None, None)
.unwrap()
.unwrap();
assert_eq!(fetched_events.len(), 6);

for moonlight_events in fetched_events {
Expand Down Expand Up @@ -1123,7 +1130,10 @@ mod tests {
let path = test_dir();
let archive = Archive::create_or_open(path).await;
let pk = AccountPublicKey::default();
assert!(archive.full_moonlight_history(pk, None).unwrap().is_none());
assert!(archive
.full_moonlight_history(pk, None, None, None, None)
.unwrap()
.is_none());

let block_events = block_events();
let event_groups = transformer::group_by_origins(block_events, 1);
Expand Down Expand Up @@ -1173,7 +1183,7 @@ mod tests {
assert_eq!(fetched_tx1[0].origin(), &[4; 32]);
fetched_tx1[0].events().iter().for_each(|e| {
assert_eq!(e.topic, "moonlight");
assert_eq!(e.target, usk_core::transfer::TRANSFER_CONTRACT);
assert_eq!(e.target, dusk_core::transfer::TRANSFER_CONTRACT);

let moonlight_event =
rkyv::from_bytes::<MoonlightTransactionEvent>(&e.data).unwrap();
Expand Down Expand Up @@ -1458,7 +1468,10 @@ mod tests {
let archive = Archive::create_or_open(path).await;

let pk = AccountPublicKey::default();
assert!(archive.full_moonlight_history(pk, None).unwrap().is_none());
assert!(archive
.full_moonlight_history(pk, None, None, None, None)
.unwrap()
.is_none());

let block_events = block_events();

Expand All @@ -1483,12 +1496,20 @@ mod tests {
fetched_moonlight_tx.dedup();
assert_eq!(fetched_moonlight_tx.len(), 6);

let mut fetched_events =
archive.full_moonlight_history(pk, None).unwrap().unwrap();
let mut fetched_events = archive
.full_moonlight_history(pk, None, None, None, None)
.unwrap()
.unwrap();
assert_eq!(fetched_events.len(), 6);

let fetched_events_reverse_order = archive
.full_moonlight_history(pk, Some(super::Order::Descending))
.full_moonlight_history(
pk,
Some(super::Order::Descending),
None,
None,
None,
)
.unwrap()
.unwrap();

Expand Down
2 changes: 2 additions & 0 deletions rusk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add transaction serialization check
- Add max transaction size check
- Add `/on/driver:<contract>/<method>:<target>` endpoint
- Add from_block & to_block params to `full_moonlight_history` in gql [#3613]

### Changed

Expand Down Expand Up @@ -369,6 +370,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add build system that generates keys for circuits and caches them.

<!-- Issues -->
[#3613]: https://github.com/dusk-network/rusk/issues/3613
[#3512]: https://github.com/dusk-network/rusk/issues/3512
[#3507]: https://github.com/dusk-network/rusk/issues/3507
[#3494]: https://github.com/dusk-network/rusk/issues/3494
Expand Down
4 changes: 3 additions & 1 deletion rusk/src/lib/http/chain/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ impl Query {
ctx: &Context<'_>,
address: String,
ord: Option<String>,
from_block: Option<u64>,
to_block: Option<u64>,
) -> OptResult<MoonlightTransfers> {
full_moonlight_history(ctx, address, ord).await
full_moonlight_history(ctx, address, ord, from_block, to_block).await
}

/// Retrieves raw events from transactions where at least one event within a
Expand Down
6 changes: 5 additions & 1 deletion rusk/src/lib/http/chain/graphql/archive/moonlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub async fn full_moonlight_history(
ctx: &Context<'_>,
address: String,
ordering: Option<String>,
from_block: Option<u64>,
to_block: Option<u64>,
) -> OptResult<MoonlightTransfers> {
let (_, archive) = ctx.data::<DBContext>()?;
let v = bs58::decode(address).into_vec()?;
Expand All @@ -36,7 +38,9 @@ pub async fn full_moonlight_history(
_ => None,
};

if let Some(moonlight_events) = archive.full_moonlight_history(pk, ord)? {
if let Some(moonlight_events) =
archive.full_moonlight_history(pk, ord, from_block, to_block)?
{
Ok(Some(MoonlightTransfers(moonlight_events)))
} else {
Ok(None)
Expand Down
Loading