Skip to content

Commit ba12fc5

Browse files
committed
all the changes to make aave work
1 parent 7b6c490 commit ba12fc5

File tree

8 files changed

+97
-25
lines changed

8 files changed

+97
-25
lines changed

.vscode/launch.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@
2727
},
2828
"cwd": "${workspaceFolder}"
2929
},
30+
{
31+
"type": "lldb",
32+
"request": "launch",
33+
"name": "Debug era_test_node at 8545",
34+
"cargo": {
35+
"args": [
36+
"build",
37+
"--bin=era_test_node",
38+
"--package=era_test_node"
39+
],
40+
"filter": {
41+
"name": "era_test_node",
42+
"kind": "bin"
43+
}
44+
},
45+
"args": [
46+
"--port",
47+
"8545",
48+
"run",
49+
],
50+
"env": {
51+
"CARGO_PROFILE_DEV": "true"
52+
},
53+
"cwd": "${workspaceFolder}"
54+
},
3055
{
3156
"type": "lldb",
3257
"request": "launch",

Cargo.lock

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WORK.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,24 @@ Simulate works now, but still the gas estimate doesn't properly handle the cost
109109

110110
Cleaned up the diff - so now we have nice interface.
111111
The main issue currently is with the tracers - as they require a different 'flow' for old VM vs new.
112+
113+
114+
## AAve issues
115+
116+
[TODO]- 'call' to deployment should return the bytecode.
117+
118+
119+
120+
Issues found:
121+
* EIP161 - nonce for create should start with '1'
122+
* should increase nonce on Create2 too.
123+
* issues with bad 'frame' rollbacks on preimages (when we failed in constructor)
124+
* out of gas - had to add -g 400 to increase the multiplier
125+
* bad ordering - had to add '--slow' to make it run one-by-one
126+
* delegateStatic issue - when 'static' method was doing delegation call (we read from wrong place).
127+
* not closing frame - causing error
128+
129+
130+
131+
132+
call methods creating a 'deadlock' in era test node.

src/config/constants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ pub const DEFAULT_FAIR_PUBDATA_PRICE: u64 = 13_607_659_111;
99
/// Scale factor for estimating L1 gas prices
1010
pub const DEFAULT_ESTIMATE_GAS_PRICE_SCALE_FACTOR: f64 = 2.0;
1111
/// Scale factor for estimating gas limits
12-
pub const DEFAULT_ESTIMATE_GAS_SCALE_FACTOR: f32 = 1.3;
12+
pub const DEFAULT_ESTIMATE_GAS_SCALE_FACTOR: f32 = 5.3;
1313
/// Default port for the test node server
1414
pub const NODE_PORT: u16 = 8011;
1515
/// Network ID for the test node
1616
#[cfg(feature = "zkos")]
1717
// For ZK os - hardcoded to 37 for now.
18-
pub const TEST_NODE_NETWORK_ID: u32 = 37;
18+
pub const TEST_NODE_NETWORK_ID: u32 = 31337;
1919
#[cfg(not(feature = "zkos"))]
2020
pub const TEST_NODE_NETWORK_ID: u32 = 260;
2121
/// Default derivation path for the test node

src/formatter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ pub fn print_transaction_summary(
844844

845845
tracing::info!("{} [{}] Hash: {:?}", emoji, status, tx.hash());
846846
tracing::info!("Initiator: {:?}", tx.initiator_account());
847+
tracing::info!("Nonce: {:?}", tx.nonce());
847848
tracing::info!("Payer: {:?}", tx.payer());
848849
tracing::info!(
849850
"Gas Limit: {} | Used: {} | Refunded: {}",

src/node/eth.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ impl<S: ForkSource + std::fmt::Debug + Clone + Send + Sync + 'static> EthNamespa
276276
block_number: BlockNumber,
277277
full_transactions: bool,
278278
) -> RpcResult<Option<Block<TransactionVariant>>> {
279+
tracing::warn!("get_block_by_number: {:?}", block_number);
279280
let inner = self.get_inner().clone();
280281

281282
Box::pin(async move {
@@ -314,7 +315,7 @@ impl<S: ForkSource + std::fmt::Debug + Clone + Send + Sync + 'static> EthNamespa
314315
})
315316
};
316317

317-
match maybe_block {
318+
let res = match maybe_block {
318319
Some(mut block) => {
319320
let block_hash = block.hash;
320321
block.transactions = block
@@ -344,7 +345,9 @@ impl<S: ForkSource + std::fmt::Debug + Clone + Send + Sync + 'static> EthNamespa
344345
Ok(Some(block))
345346
}
346347
None => Ok(None),
347-
}
348+
};
349+
//tracing::warn!("get_block_by_number: {:?}", res);
350+
res
348351
})
349352
}
350353

@@ -412,15 +415,17 @@ impl<S: ForkSource + std::fmt::Debug + Clone + Send + Sync + 'static> EthNamespa
412415
#[cfg(feature = "zkos")]
413416
let nonce_key = super::zkos::zkos_get_nonce_key(&address);
414417

415-
match inner.write() {
418+
let res = match inner.write() {
416419
Ok(guard) => match guard.fork_storage.read_value_internal(&nonce_key) {
417420
Ok(result) => Ok(h256_to_u64(result).into()),
418421
Err(error) => Err(report_into_jsrpc_error(error)),
419422
},
420423
Err(_) => Err(into_jsrpc_error(Web3Error::InternalError(
421424
anyhow::Error::msg("Failed to acquire write lock for nonce retrieval"),
422425
))),
423-
}
426+
};
427+
tracing::warn!("get_transaction_count: {:?}", res);
428+
res
424429
})
425430
}
426431

@@ -455,6 +460,7 @@ impl<S: ForkSource + std::fmt::Debug + Clone + Send + Sync + 'static> EthNamespa
455460
.tx_results
456461
.get(&hash)
457462
.map(|info| info.receipt.clone());
463+
tracing::warn!("get_transaction_receipt for {:?}: {:?}", hash, receipt);
458464
Ok(receipt)
459465
})
460466
}
@@ -489,6 +495,7 @@ impl<S: ForkSource + std::fmt::Debug + Clone + Send + Sync + 'static> EthNamespa
489495
hash: zksync_types::H256,
490496
full_transactions: bool,
491497
) -> RpcResult<Option<Block<TransactionVariant>>> {
498+
tracing::warn!("get_block_by_hash: {:?}", hash);
492499
let inner = self.get_inner().clone();
493500

494501
Box::pin(async move {

src/node/in_memory.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ impl<S: ForkSource + std::fmt::Debug + Clone> InMemoryNode<S> {
12771277

12781278
// init vm
12791279

1280-
let (batch_env, _) = inner.create_l1_batch_env(&self.time, storage.clone());
1280+
//let (batch_env, _) = inner.create_l1_batch_env(&self.time, storage.clone());
12811281
let system_env = inner.create_system_env(base_contracts, execution_mode);
12821282

12831283
#[cfg(not(feature = "zkos"))]
@@ -1571,7 +1571,7 @@ impl<S: ForkSource + std::fmt::Debug + Clone> InMemoryNode<S> {
15711571
Ok(TxExecutionOutput {
15721572
result: tx_result.clone(),
15731573
call_traces: call_traces.cloned().unwrap_or_default(),
1574-
bytecodes: tx_result.new_known_factory_deps.unwrap().clone(),
1574+
bytecodes: tx_result.new_known_factory_deps.unwrap_or_default().clone(),
15751575
})
15761576
}
15771577

@@ -1748,6 +1748,7 @@ impl<S: ForkSource + std::fmt::Debug + Clone> InMemoryNode<S> {
17481748

17491749
// Execute transactions and bootloader
17501750
let mut executed_tx_hashes = Vec::with_capacity(tx_hashes.len());
1751+
tracing::error!("==== Starting seal block ==== {:?}", block_ctx);
17511752
for tx in txs {
17521753
// Executing a next transaction means that a previous transaction was either rolled back (in which case its snapshot
17531754
// was already removed), or that we build on top of it (in which case, it can be removed now).
@@ -1762,7 +1763,9 @@ impl<S: ForkSource + std::fmt::Debug + Clone> InMemoryNode<S> {
17621763
executed_tx_hashes.push(hash);
17631764
}
17641765
}
1766+
tracing::error!("==== Finished seal block ====");
17651767
vm.execute(InspectExecutionMode::Bootloader);
1768+
tracing::error!("==== Finished running bootloader mode ====");
17661769

17671770
// Write all the mutated keys (storage slots).
17681771
let mut inner = self

src/node/zkos.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
use std::{alloc::Global, collections::HashMap};
1+
use std::{alloc::Global, collections::HashMap, vec};
22

33
use basic_system::basic_system::simple_growable_storage::TestingTree;
44
use forward_system::run::{
55
test_impl::{InMemoryPreimageSource, InMemoryTree, TxListSource},
66
PreimageType, StorageCommitment,
77
};
8+
use hex::ToHex;
89
use ruint::aliases::B160;
910
use system_hooks::addresses_constants::{
1011
NOMINAL_TOKEN_BALANCE_STORAGE_ADDRESS, NONCE_HOLDER_HOOK_ADDRESS,
1112
};
1213
use zk_ee::{common_structs::derive_flat_storage_key, utils::Bytes32};
1314
use zksync_multivm::interface::{
1415
storage::{StoragePtr, WriteStorage},
15-
ExecutionResult, PushTransactionResult, TxExecutionMode, VmExecutionLogs,
16+
ExecutionResult, InspectExecutionMode, PushTransactionResult, TxExecutionMode, VmExecutionLogs,
1617
VmExecutionResultAndLogs, VmInterface, VmInterfaceHistoryEnabled, VmRevertReason,
1718
};
1819
use zksync_types::{
@@ -347,9 +348,11 @@ pub fn execute_tx_in_zkos<W: WriteStorage>(
347348
forward_system::run::ExecutionResult::Success(output) => match &output {
348349
forward_system::run::ExecutionOutput::Call(data) => data,
349350
forward_system::run::ExecutionOutput::Create(data, address) => {
350-
dbg!(address);
351351
// TODO - pass it to the output somehow.
352-
println!("Deployed to {:?}", address);
352+
println!(
353+
"Deployed to {}",
354+
address.to_be_bytes_vec().encode_hex::<String>()
355+
);
353356
data
354357
}
355358
},
@@ -535,12 +538,23 @@ impl<S: WriteStorage> VmInterface for ZKOsVM<S> {
535538
dispatcher: &mut Self::TracerDispatcher,
536539
execution_mode: zksync_multivm::interface::InspectExecutionMode,
537540
) -> VmExecutionResultAndLogs {
541+
if let InspectExecutionMode::Bootloader = execution_mode {
542+
return VmExecutionResultAndLogs {
543+
result: ExecutionResult::Success { output: vec![] },
544+
logs: Default::default(),
545+
statistics: Default::default(),
546+
refunds: Default::default(),
547+
new_known_factory_deps: Default::default(),
548+
};
549+
}
538550
let simulate_only = match self.execution_mode {
539551
TxExecutionMode::VerifyExecute => false,
540552
TxExecutionMode::EstimateFee => true,
541553
TxExecutionMode::EthCall => true,
542554
};
543555

556+
assert_eq!(1, self.transactions.len());
557+
544558
// FIXME.
545559
let tx = self.transactions[0].clone();
546560
execute_tx_in_zkos(

0 commit comments

Comments
 (0)