Skip to content

Commit 16c0a6b

Browse files
committed
Merge branch 'master' into thlorenz/fix-direct-connection-metric
* master: feat: Execute CommitDiff as BufferTask (#616) refactor(processor): improve transaction processing codebase (#817)
2 parents e128815 + 81b24b7 commit 16c0a6b

31 files changed

Lines changed: 1724 additions & 2268 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

magicblock-api/src/magic_validator.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ use magicblock_ledger::{
5353
use magicblock_metrics::{metrics::TRANSACTION_COUNT, MetricsService};
5454
use magicblock_processor::{
5555
build_svm_env,
56+
loader::load_upgradeable_programs,
5657
scheduler::{state::TransactionSchedulerState, TransactionScheduler},
5758
};
5859
use magicblock_program::{
@@ -213,6 +214,14 @@ impl MagicValidator {
213214
))
214215
});
215216

217+
load_upgradeable_programs(
218+
&accountsdb,
219+
&programs_to_load(&config.programs),
220+
)
221+
.map_err(|err| {
222+
ApiError::FailedToLoadProgramsIntoBank(format!("{:?}", err))
223+
})?;
224+
216225
validator::init_validator_authority(identity_keypair);
217226
let base_fee = config.validator.basefee;
218227
let txn_scheduler_state = TransactionSchedulerState {
@@ -230,12 +239,6 @@ impl MagicValidator {
230239
shutdown: token.clone(),
231240
};
232241
TRANSACTION_COUNT.inc_by(ledger.count_transactions()? as u64);
233-
txn_scheduler_state
234-
.load_upgradeable_programs(&programs_to_load(&config.programs))
235-
.map_err(|err| {
236-
ApiError::FailedToLoadProgramsIntoBank(format!("{:?}", err))
237-
})?;
238-
239242
// Faucet keypair is only used for airdrops, which are not allowed in
240243
// the Ephemeral mode by setting the faucet to None in node context
241244
// (used by the RPC implementation), we effectively disable airdrops

magicblock-committor-service/src/persist/commit_persister.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,14 +587,14 @@ mod tests {
587587
persister.set_commit_id(1, &pubkey, 100).unwrap();
588588

589589
persister
590-
.set_commit_strategy(100, &pubkey, CommitStrategy::Args)
590+
.set_commit_strategy(100, &pubkey, CommitStrategy::StateArgs)
591591
.unwrap();
592592

593593
let updated = persister
594594
.get_commit_status_by_message(1, &pubkey)
595595
.unwrap()
596596
.unwrap();
597-
assert_eq!(updated.commit_strategy, CommitStrategy::Args);
597+
assert_eq!(updated.commit_strategy, CommitStrategy::StateArgs);
598598
}
599599

600600
#[test]

magicblock-committor-service/src/persist/db.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ mod tests {
772772
commit_type: CommitType::DataAccount,
773773
created_at: 1000,
774774
commit_status: CommitStatus::Pending,
775-
commit_strategy: CommitStrategy::Args,
775+
commit_strategy: CommitStrategy::StateArgs,
776776
last_retried_at: 1000,
777777
retries_count: 0,
778778
}
@@ -907,7 +907,7 @@ mod tests {
907907
db.insert_commit_status_rows(std::slice::from_ref(&row))
908908
.unwrap();
909909

910-
let new_strategy = CommitStrategy::FromBuffer;
910+
let new_strategy = CommitStrategy::StateBuffer;
911911
db.set_commit_strategy(100, &row.pubkey, new_strategy)
912912
.unwrap();
913913

magicblock-committor-service/src/persist/types/commit_strategy.rs

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,46 @@ use crate::persist::error::CommitPersistError;
44
pub enum CommitStrategy {
55
/// Args without the use of a lookup table
66
#[default]
7-
Args,
7+
StateArgs,
88
/// Args with the use of a lookup table
9-
ArgsWithLookupTable,
9+
StateArgsWithLookupTable,
1010
/// Buffer and chunks which has the most overhead
11-
FromBuffer,
11+
StateBuffer,
1212
/// Buffer and chunks with the use of a lookup table
13-
FromBufferWithLookupTable,
13+
StateBufferWithLookupTable,
14+
15+
/// Args without the use of a lookup table
16+
DiffArgs,
17+
/// Args with the use of a lookup table
18+
DiffArgsWithLookupTable,
19+
/// Buffer and chunks which has the most overhead
20+
DiffBuffer,
21+
/// Buffer and chunks with the use of a lookup table
22+
DiffBufferWithLookupTable,
1423
}
1524

1625
impl CommitStrategy {
17-
pub fn args(use_lookup: bool) -> Self {
18-
if use_lookup {
19-
Self::ArgsWithLookupTable
20-
} else {
21-
Self::Args
22-
}
23-
}
24-
2526
pub fn as_str(&self) -> &str {
2627
use CommitStrategy::*;
2728
match self {
28-
Args => "Args",
29-
ArgsWithLookupTable => "ArgsWithLookupTable",
30-
FromBuffer => "FromBuffer",
31-
FromBufferWithLookupTable => "FromBufferWithLookupTable",
29+
StateArgs => "StateArgs",
30+
StateArgsWithLookupTable => "StateArgsWithLookupTable",
31+
StateBuffer => "StateBuffer",
32+
StateBufferWithLookupTable => "StateBufferWithLookupTable",
33+
DiffArgs => "DiffArgs",
34+
DiffArgsWithLookupTable => "DiffArgsWithLookupTable",
35+
DiffBuffer => "DiffBuffer",
36+
DiffBufferWithLookupTable => "DiffBufferWithLookupTable",
3237
}
3338
}
3439

3540
pub fn uses_lookup(&self) -> bool {
3641
matches!(
3742
self,
38-
CommitStrategy::ArgsWithLookupTable
39-
| CommitStrategy::FromBufferWithLookupTable
43+
CommitStrategy::StateArgsWithLookupTable
44+
| CommitStrategy::StateBufferWithLookupTable
45+
| CommitStrategy::DiffArgsWithLookupTable
46+
| CommitStrategy::DiffBufferWithLookupTable
4047
)
4148
}
4249
}
@@ -45,10 +52,18 @@ impl TryFrom<&str> for CommitStrategy {
4552
type Error = CommitPersistError;
4653
fn try_from(value: &str) -> Result<Self, CommitPersistError> {
4754
match value {
48-
"Args" => Ok(Self::Args),
49-
"ArgsWithLookupTable" => Ok(Self::ArgsWithLookupTable),
50-
"FromBuffer" => Ok(Self::FromBuffer),
51-
"FromBufferWithLookupTable" => Ok(Self::FromBufferWithLookupTable),
55+
"Args" | "StateArgs" => Ok(Self::StateArgs),
56+
"ArgsWithLookupTable" | "StateArgsWithLookupTable" => {
57+
Ok(Self::StateArgsWithLookupTable)
58+
}
59+
"FromBuffer" | "StateBuffer" => Ok(Self::StateBuffer),
60+
"FromBufferWithLookupTable" | "StateBufferWithLookupTable" => {
61+
Ok(Self::StateBufferWithLookupTable)
62+
}
63+
"DiffArgs" => Ok(Self::DiffArgs),
64+
"DiffArgsWithLookupTable" => Ok(Self::DiffArgsWithLookupTable),
65+
"DiffBuffer" => Ok(Self::DiffBuffer),
66+
"DiffBufferWithLookupTable" => Ok(Self::DiffBufferWithLookupTable),
5267
_ => Err(CommitPersistError::InvalidCommitStrategy(
5368
value.to_string(),
5469
)),

magicblock-committor-service/src/tasks/args_task.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl BaseTask for ArgsTask {
127127
}
128128
}
129129

130-
fn optimize(
130+
fn try_optimize_tx_size(
131131
self: Box<Self>,
132132
) -> Result<Box<dyn BaseTask>, Box<dyn BaseTask>> {
133133
match self.task_type {
@@ -137,16 +137,8 @@ impl BaseTask for ArgsTask {
137137
)))
138138
}
139139
ArgsTaskType::CommitDiff(value) => {
140-
// TODO (snawaz): Currently, we do not support executing CommitDiff
141-
// as BufferTask, which is why we're forcing CommitDiffTask to become CommitTask
142-
// before converting this task into BufferTask. Once CommitDiff is supported
143-
// by BufferTask, we do not have to do this, as it's essentially a downgrade.
144140
Ok(Box::new(BufferTask::new_preparation_required(
145-
BufferTaskType::Commit(CommitTask {
146-
commit_id: value.commit_id,
147-
allow_undelegation: value.allow_undelegation,
148-
committed_account: value.committed_account,
149-
}),
141+
BufferTaskType::CommitDiff(value),
150142
)))
151143
}
152144
ArgsTaskType::BaseAction(_)

0 commit comments

Comments
 (0)