Skip to content

Commit 75a2c94

Browse files
committed
make gas errors non-deterministic for now
1 parent eaae48d commit 75a2c94

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

core/src/subgraph/instance_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ where
763763
.unwrap()
764764
.remove(&ctx.inputs.deployment.id);
765765

766-
error!(logger, "Subgraph failed for non-deterministic error: {}", e;
766+
error!(logger, "Subgraph failed with non-deterministic error: {}", e;
767767
"attempt" => backoff.attempt,
768768
"retry_delay_s" => backoff.delay().as_secs());
769769

graph/src/runtime/gas/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl GasCounter {
9494
.unwrap();
9595
let new = old.saturating_add(amount.0);
9696
if new >= *MAX_GAS_PER_HANDLER {
97-
Err(DeterministicHostError::from(anyhow::anyhow!(
97+
Err(DeterministicHostError::gas(anyhow::anyhow!(
9898
"Gas limit exceeded. Used: {}",
9999
new
100100
)))

graph/src/runtime/mod.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,23 +252,34 @@ impl ToAscObj<u32> for IndexForAscTypeId {
252252
}
253253

254254
#[derive(Debug)]
255-
pub struct DeterministicHostError(Error);
255+
pub enum DeterministicHostError {
256+
Gas(Error),
257+
Other(Error),
258+
}
256259

257260
impl DeterministicHostError {
261+
pub fn gas(e: Error) -> Self {
262+
DeterministicHostError::Gas(e)
263+
}
264+
258265
pub fn inner(self) -> Error {
259-
self.0
266+
match self {
267+
DeterministicHostError::Gas(e) | DeterministicHostError::Other(e) => e,
268+
}
260269
}
261270
}
262271

263272
impl fmt::Display for DeterministicHostError {
264273
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
265-
self.0.fmt(f)
274+
match self {
275+
DeterministicHostError::Gas(e) | DeterministicHostError::Other(e) => e.fmt(f),
276+
}
266277
}
267278
}
268279

269280
impl From<Error> for DeterministicHostError {
270281
fn from(e: Error) -> DeterministicHostError {
271-
DeterministicHostError(e)
282+
DeterministicHostError::Other(e)
272283
}
273284
}
274285

@@ -294,7 +305,11 @@ impl From<anyhow::Error> for HostExportError {
294305

295306
impl From<DeterministicHostError> for HostExportError {
296307
fn from(value: DeterministicHostError) -> Self {
297-
HostExportError::Deterministic(value.0)
308+
match value {
309+
// Until we are confident on the gas numbers, gas errors are not deterministic
310+
DeterministicHostError::Gas(e) => HostExportError::Unknown(e),
311+
DeterministicHostError::Other(e) => HostExportError::Deterministic(e),
312+
}
298313
}
299314
}
300315

0 commit comments

Comments
 (0)