Skip to content

Commit 5f28e91

Browse files
authored
Merge pull request #26 from holaplex/dev
v0.6.1 Release
2 parents 56b0ef2 + d58e763 commit 5f28e91

File tree

5 files changed

+70
-29
lines changed

5 files changed

+70
-29
lines changed

crates/plugin/sample_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw"
3434
],
3535
"pubkeys": [],
36+
"mints": [],
3637
"startup": false
3738
},
3839
"instructions": {

crates/plugin/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ pub struct Accounts {
5757
#[serde(default)]
5858
pub pubkeys: HashSet<String>,
5959

60+
#[serde(default)]
61+
pub mints: HashSet<String>,
62+
6063
/// Filter for changing how to interpret the `is_startup` flag.
6164
///
6265
/// This option has three states:

crates/plugin/src/plugin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ impl GeyserPlugin for GeyserPluginRabbitMq {
181181
.await
182182
.map_err(custom_err(&metrics.errs))?;
183183

184-
if acct_sel.screen_tokens() {
185-
acct_sel.init_tokens(
184+
if acct_sel.screen_token_registry() {
185+
acct_sel.init_token_registry(
186186
Self::load_token_reg()
187187
.await
188188
.map_err(custom_err(&metrics.errs))?,

crates/plugin/src/selectors.rs

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ use crate::{
1414
pub struct AccountSelector {
1515
owners: HashSet<[u8; 32]>,
1616
pubkeys: HashSet<[u8; 32]>,
17+
mints: HashSet<Pubkey>,
1718
startup: Option<bool>,
18-
token_addresses: Option<HashSet<Pubkey>>,
19+
token_reg: Option<HashSet<Pubkey>>,
1920
}
2021

2122
impl AccountSelector {
@@ -24,6 +25,7 @@ impl AccountSelector {
2425
owners,
2526
all_tokens,
2627
pubkeys,
28+
mints,
2729
startup,
2830
} = config;
2931

@@ -39,23 +41,37 @@ impl AccountSelector {
3941
.collect::<Result<_, _>>()
4042
.context("Failed to parse account pubkeys")?;
4143

42-
Ok(Self {
44+
let mints = mints
45+
.into_iter()
46+
.map(|s| s.parse())
47+
.collect::<Result<_, _>>()
48+
.context("Failed to parse token account mint addresses")?;
49+
50+
let mut ret = Self {
4351
owners,
4452
pubkeys,
53+
mints,
4554
startup,
46-
token_addresses: if all_tokens {
55+
token_reg: if all_tokens {
4756
None
4857
} else {
4958
Some(HashSet::new())
5059
},
51-
})
60+
};
61+
62+
// Don't screen tokens if we're never going to return them
63+
if !ret.owners.contains(TOKEN_KEY.as_ref()) {
64+
ret.token_reg = None;
65+
}
66+
67+
Ok(ret)
5268
}
5369

5470
/// Lazy-load the token addresses. Fails if token addresses are not wanted
5571
/// or if they have already been loaded.
56-
pub fn init_tokens(&mut self, addrs: HashSet<Pubkey>) {
57-
assert!(self.token_addresses.as_ref().unwrap().is_empty());
58-
self.token_addresses = Some(addrs);
72+
pub fn init_token_registry(&mut self, addrs: HashSet<Pubkey>) {
73+
assert!(self.token_reg.as_ref().unwrap().is_empty());
74+
self.token_reg = Some(addrs);
5975
}
6076

6177
#[inline]
@@ -64,30 +80,44 @@ impl AccountSelector {
6480
}
6581

6682
#[inline]
67-
pub fn screen_tokens(&self) -> bool {
68-
self.token_addresses.is_some()
83+
pub fn screen_token_registry(&self) -> bool {
84+
self.token_reg.is_some()
6985
}
7086

7187
#[inline]
7288
pub fn is_selected(&self, acct: &ReplicaAccountInfo, is_startup: bool) -> bool {
7389
let ReplicaAccountInfo { owner, data, .. } = *acct;
7490

75-
if self.startup.map_or(false, |s| is_startup != s)
76-
|| !(self.owners.contains(owner) || self.pubkeys.contains(acct.pubkey))
77-
{
91+
if self.startup.map_or(false, |s| is_startup != s) {
7892
return false;
7993
}
8094

81-
if owner == TOKEN_KEY.as_ref() && data.len() == TokenAccount::get_packed_len() {
82-
if let Some(ref addrs) = self.token_addresses {
83-
let token_account = TokenAccount::unpack_from_slice(data);
95+
if self.pubkeys.contains(acct.pubkey) {
96+
return true;
97+
}
8498

85-
if let Ok(token_account) = token_account {
86-
if token_account.amount > 1 || addrs.contains(&token_account.mint) {
87-
return false;
88-
}
89-
}
90-
}
99+
let token = if (self.token_reg.is_some() || !self.mints.is_empty())
100+
&& owner == TOKEN_KEY.as_ref()
101+
&& data.len() == TokenAccount::get_packed_len()
102+
{
103+
TokenAccount::unpack_from_slice(data).ok()
104+
} else {
105+
None
106+
};
107+
108+
if token.map_or(false, |t| self.mints.contains(&t.mint)) {
109+
return true;
110+
}
111+
112+
if !self.owners.contains(owner) {
113+
return false;
114+
}
115+
116+
if token
117+
.zip(self.token_reg.as_ref())
118+
.map_or(false, |(t, r)| t.amount > 1 || r.contains(&t.mint))
119+
{
120+
return false;
91121
}
92122

93123
true
@@ -113,10 +143,17 @@ impl InstructionSelector {
113143
.collect::<Result<_, _>>()
114144
.context("Failed to parse instruction program keys")?;
115145

116-
Ok(Self {
146+
let mut ret = Self {
117147
programs,
118148
screen_tokens: !all_token_calls,
119-
})
149+
};
150+
151+
// Don't screen token calls if we're never going to return them
152+
if !ret.programs.contains(&TOKEN_KEY) {
153+
ret.screen_tokens = false;
154+
}
155+
156+
Ok(ret)
120157
}
121158

122159
#[inline]

crates/rabbitmq/src/geyser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ impl QueueType {
124124
queue,
125125
binding: Binding::Fanout,
126126
prefetch: 4096,
127-
max_len_bytes: if suffix.is_debug() || matches!(startup_type, StartupType::Normal) {
128-
512 * 1024 * 1024 // 512 MiB
129-
} else {
130-
12 * 1024 * 1024 * 1024 // 12 GiB
127+
max_len_bytes: match (suffix.is_debug(), startup_type) {
128+
(true, _) => 100 * 1024 * 1024, // 100 MiB
129+
(false, StartupType::Normal) => 4 * 1024 * 1024 * 1024, // 4 GiB
130+
(false, _) => 12 * 1024 * 1024 * 1024, // 12 GiB
131131
},
132132
auto_delete: suffix.is_debug(),
133133
retry: Some(RetryProps {

0 commit comments

Comments
 (0)