-
Notifications
You must be signed in to change notification settings - Fork 71
feat: forester: multiple trees + rollover support #998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d3d13a4
to
0742fa0
Compare
f7ffdd6
to
7abd47a
Compare
forester/src/config.rs
Outdated
#[derive(Debug, Clone)] | ||
pub struct TreeSyncMetadata { | ||
pub last_synced_at: DateTime<Utc>, | ||
pub last_synced_root: [u8; 32], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the conceptual idea behind this?
how often do you sync trees?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed it for now.
I sync the trees on every start, but that's obviously not enough, and syncing on every rollover is not enough either.
I see 2 options:
- Separate thread that would subscribe to account_compression account changes and do a sync on each change.
- Just a cron job, every N minutes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The forester epochs and slots will change this a bit. (Foresters are only eligible to forest during their own slots.)
It’s probably enough to sync the tree leading up and during the slot.
forester/src/main.rs
Outdated
async fn run_subscribe_addresses<R: RpcConnection>( | ||
config: Arc<ForesterConfig>, | ||
rpc_pool: RpcPool<R>, | ||
tree_data: TreeData, | ||
rollover_state: Arc<RolloverState>, | ||
) { | ||
let indexer_rpc = init_rpc(config.clone(), false).await; | ||
let indexer = Arc::new(tokio::sync::Mutex::new(PhotonIndexer::new( | ||
config.external_services.indexer_url.to_string(), | ||
indexer_rpc, | ||
))); | ||
|
||
subscribe_addresses(config.clone(), rpc_pool, indexer).await; | ||
subscribe_addresses(config.clone(), rpc_pool, indexer, tree_data, rollover_state).await; | ||
} | ||
|
||
async fn run_nullify_state<R: RpcConnection>(config: Arc<ForesterConfig>, rpc_pool: RpcPool<R>) { | ||
async fn run_nullify_addresses<R: RpcConnection>( | ||
config: Arc<ForesterConfig>, | ||
rpc_pool: RpcPool<R>, | ||
tree_data: TreeData, | ||
rollover_state: Arc<RolloverState>, | ||
) { | ||
let indexer_rpc = init_rpc(config.clone(), false).await; | ||
let indexer = Arc::new(tokio::sync::Mutex::new(PhotonIndexer::new( | ||
config.external_services.indexer_url.to_string(), | ||
indexer_rpc, | ||
))); | ||
|
||
nullify_state(config.clone(), rpc_pool, indexer).await; | ||
nullify_addresses(config.clone(), rpc_pool, indexer, tree_data, rollover_state).await; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how much but it feels like there is some duplicate code in this file.
It can probably be unified more or redundant functions removed.
forester/src/rollover/operations.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really would like to move code like this which is duplicate in forester and test-utils into a forester-utils crate which forester and test-utils depend on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started to extract duplicated code from forester & test-utils, and I think it would be better to make it in different PR, too many changes there.
3367e25
to
65c73c4
Compare
65c73c4
to
a63c02a
Compare
No description provided.