Skip to content

Commit

Permalink
Rename to fork_block
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Apr 4, 2024
1 parent a1e8052 commit 50b7fae
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pyrevm.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class EVM:
cls: Type["EVM"],
env: Optional[Env] = None,
fork_url: Optional[str] = None,
fork_block_number: Optional[str] = None,
fork_block: Optional[str] = None,
gas_limit: int = 2**64 - 1,
tracing: bool = False,
spec_id="SHANGHAI",
Expand All @@ -145,7 +145,7 @@ class EVM:
Creates a new EVM instance.
:param env: The environment.
:param fork_url: The fork URL.
:param fork_block_number: The fork block number. Either a block hash starting with 0x or a block number:
:param fork_block: The fork block number. Either a block hash starting with 0x or a block number:
Supported block numbers: Latest, Finalized, Safe, Earliest, Pending
:param gas_limit: The gas limit.
:param tracing: Whether to enable tracing.
Expand Down
4 changes: 2 additions & 2 deletions pytest/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

KWARG_CASES = [
{"fork_url": fork_url},
{"fork_url": fork_url, "tracing": False, "fork_block_number": "latest"},
{"fork_url": fork_url, "tracing": False, "fork_block": "latest"},
{},
]

Expand Down Expand Up @@ -105,7 +105,7 @@ def test_balances():


def test_balances_fork():
evm = EVM(fork_url=fork_url, fork_block_number="0x3b01f793ed1923cd82df5fe345b3e12211aedd514c8546e69efd6386dc0c9a97")
evm = EVM(fork_url=fork_url, fork_block="0x3b01f793ed1923cd82df5fe345b3e12211aedd514c8546e69efd6386dc0c9a97")

vb_before = evm.basic(address)
assert vb_before.balance == 955628344913799071315
Expand Down
4 changes: 2 additions & 2 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ impl DB {
DB::Memory(MemDB::new(EmptyDBWrapper::default()))
}

pub(crate) fn new_fork(fork_url: &str, fork_block_number: Option<&str>) -> PyResult<Self> {
pub(crate) fn new_fork(fork_url: &str, fork_block: Option<&str>) -> PyResult<Self> {
let provider = Provider::<Http>::try_from(fork_url).map_err(pyerr)?;
let block = fork_block_number
let block = fork_block
.map(BlockId::from_str)
.map_or(Ok(None), |v| v.map(Some))
.map_err(pyerr)?;
Expand Down
6 changes: 3 additions & 3 deletions src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ pub struct EVM {
impl EVM {
/// Create a new EVM instance.
#[new]
#[pyo3(signature = (env = None, fork_url = None, fork_block_number = None, gas_limit = 18446744073709551615, tracing = false, spec_id = "LATEST"))]
#[pyo3(signature = (env = None, fork_url = None, fork_block = None, gas_limit = 18446744073709551615, tracing = false, spec_id = "LATEST"))]
fn new(
env: Option<Env>,
fork_url: Option<&str>,
fork_block_number: Option<&str>,
fork_block: Option<&str>,
gas_limit: u64,
tracing: bool,
spec_id: &str,
) -> PyResult<Self> {
let spec = SpecId::from(spec_id);
let env = env.unwrap_or_default().into();
let db = fork_url
.map(|url| DB::new_fork(url, fork_block_number))
.map(|url| DB::new_fork(url, fork_block))
.unwrap_or(Ok(DB::new_memory()))?;

let Evm { context, .. } = Evm::builder().with_env(Box::new(env)).with_db(db).build();
Expand Down

0 comments on commit 50b7fae

Please sign in to comment.