diem/diem · error
Failed to generate txn effects
Error message
Failed to generate txn effects
What it means
In the e2e test executor's exec(), after executing a function in a Move session, session.finish() is unwrapped with this panic message. It fires when the session cannot produce a changeset (e.g. the transaction aborted mid-execution leaving inconsistent state, or resource/enum deserialization problems).
Source
Thrown at language/testing-infra/e2e-tests/src/executor.rs:512
let remote_view = RemoteStorage::new(&self.data_store);
let mut session = vm.new_session(&remote_view);
session
.execute_function(
&Self::module(module_name),
&Self::name(function_name),
type_params,
args,
&mut gas_status,
)
.unwrap_or_else(|e| {
panic!(
"Error calling {}.{}: {}",
module_name,
function_name,
e.into_vm_status()
)
});
let (changeset, events) = session.finish().expect("Failed to generate txn effects");
let (writeset, _events) = convert_changeset_and_events(changeset, events)
.expect("Failed to generate writeset");
writeset
};
self.data_store.add_write_set(&write_set);
}
pub fn try_exec(
&mut self,
module_name: &str,
function_name: &str,
type_params: Vec<TypeTag>,
args: Vec<Vec<u8>>,
) -> Result<WriteSet, VMStatus> {
let mut gas_status = GasStatus::new_unmetered();
let vm = MoveVM::new(diem_vm::natives::diem_natives()).unwrap();
let remote_view = RemoteStorage::new(&self.data_store);
let mut session = vm.new_session(&remote_view);View on GitHub (pinned to fc4714a8ea)
Solutions
- Check the preceding 'Error calling module.function' log message to find the abort cause and fix the called Move code or test inputs.
- Use try_exec (which maps errors to VMStatus) instead of exec for transactions expected to fail.
- Ensure the data store state is fresh/valid (e.g. don't re-initialize an already initialized chain).
Example fix
// before
executor.exec(initialize_script, ...); // aborts -> panic in session.finish()
// after
executor.try_exec(initialize_script, ...).expect("init should succeed"); Defensive patterns
Strategy: try-catch
Validate before calling
// prefer try_exec when a transaction may abort let result = executor.try_exec(&script, ty_args, args);
Try / catch
match std::panic::catch_unwind(|| executor.exec(...)) {
Ok(ws) => use(ws),
Err(p) if panic_msg_contains(p, "Failed to generate txn effects") =>
eprintln!("check the 'Error calling module.function' log above"),
Err(p) => resume_unwind(p),
} Prevention
- Use try_exec instead of exec for transactions that might abort.
- Read the preceding 'Error calling <module>.<function>' message to identify the root cause.
- Don't re-run initialization transactions on already-initialized chain state.
When it happens
Trigger: Calling exec (used by test_diem_initialize, publish_and_register_new_currency, etc.) when the underlying MoveVM session finish() returns an error — typically an aborted transaction or invalid state update.
Common situations: Tests that call exec with scripts/functions that abort, or data store state inconsistent with what the session expects (e.g. initializing Diem twice).
Related errors
- Failed to generate writeset
- Input value has too small of a fractional part 1/{}, but sma
- Input value is too big: {:?}, max: {:?}
- invalid value
- Aborted command
AI-assisted analysis of diem/diem@fc4714a8ea (2026-09-04).
Data as JSON: /api/errors/88881ebc805e664c.
Report an issue: GitHub.