From 29bc3345a652f13da6a1a923c14886fb3c7f9439 Mon Sep 17 00:00:00 2001 From: Elias Tazartes <66871571+Eikix@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:37:58 -0300 Subject: [PATCH] Deployment/kakarot v0 6 2 (#946) * fix protocol nonce edge case * fix linter --- src/eth_provider/provider.rs | 7 +++++++ src/eth_provider/starknet/kakarot_core.rs | 1 + 2 files changed, 8 insertions(+) diff --git a/src/eth_provider/provider.rs b/src/eth_provider/provider.rs index 836841a28..42668d77f 100644 --- a/src/eth_provider/provider.rs +++ b/src/eth_provider/provider.rs @@ -337,6 +337,13 @@ where } let nonce = maybe_nonce.map_err(KakarotError::from)?.nonce; + // Get the protocol nonce as well, in edge cases where the protocol nonce is higher than the account nonce. + // This can happen when an underlying Starknet transaction reverts => Account storage changes are reverted, + // but the protocol nonce is still incremented. + let protocol_nonce = + self.starknet_provider.get_nonce(starknet_block_id, address).await.map_err(KakarotError::from)?; + let nonce = nonce.max(protocol_nonce); + Ok(into_via_wrapper!(nonce)) } diff --git a/src/eth_provider/starknet/kakarot_core.rs b/src/eth_provider/starknet/kakarot_core.rs index 3de3b7881..4d2faac99 100644 --- a/src/eth_provider/starknet/kakarot_core.rs +++ b/src/eth_provider/starknet/kakarot_core.rs @@ -32,6 +32,7 @@ pub mod core { use super::*; abigen_legacy!(KakarotCore, "./.kakarot/artifacts/kakarot.json"); + #[derive(Debug)] pub struct CallInput { pub(crate) nonce: FieldElement, pub(crate) from: FieldElement,