Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 14 additions & 7 deletions client/rpc/debug/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ where
Err(internal_err("'pending' blocks are not supported"))
}
RequestBlockId::Hash(eth_hash) => {
match frontier_backend_client::load_hash::<B>(frontier_backend.as_ref(), eth_hash) {
match frontier_backend_client::load_hash::<B, C>(
client.as_ref(),
frontier_backend.as_ref(),
eth_hash,
) {
Ok(Some(id)) => Ok(id),
Ok(_) => Err(internal_err("Block hash not found".to_string())),
Err(e) => Err(e),
Expand Down Expand Up @@ -434,12 +438,15 @@ where
Err(e) => return Err(e),
};

let reference_id =
match frontier_backend_client::load_hash::<B>(frontier_backend.as_ref(), hash) {
Ok(Some(hash)) => hash,
Ok(_) => return Err(internal_err("Block hash not found".to_string())),
Err(e) => return Err(e),
};
let reference_id = match frontier_backend_client::load_hash::<B, C>(
client.as_ref(),
frontier_backend.as_ref(),
hash,
) {
Ok(Some(hash)) => hash,
Ok(_) => return Err(internal_err("Block hash not found".to_string())),
Err(e) => return Err(e),
};
// Get ApiRef. This handle allow to keep changes between txs in an internal buffer.
let api = client.runtime_api();
// Get Blockchain backend
Expand Down
15 changes: 8 additions & 7 deletions client/rpc/finality/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ fn is_block_finalized_inner<B: Block<Hash = H256>, C: HeaderBackend<B> + 'static
client: &C,
raw_hash: H256,
) -> RpcResult<bool> {
let substrate_hash = match frontier_backend_client::load_hash::<B>(backend, raw_hash)? {
// If we find this hash in the frontier data base, we know it is an eth hash
Some(BlockId::Hash(hash)) => hash,
Some(BlockId::Number(_)) => panic!("is_canon test only works with hashes."),
// Otherwise, we assume this is a Substrate hash.
None => raw_hash,
};
let substrate_hash =
match frontier_backend_client::load_hash::<B, C>(client, backend, raw_hash)? {
// If we find this hash in the frontier data base, we know it is an eth hash
Some(BlockId::Hash(hash)) => hash,
Some(BlockId::Number(_)) => panic!("is_canon test only works with hashes."),
// Otherwise, we assume this is a Substrate hash.
None => raw_hash,
};

// First check whether the block is in the best chain
if !is_canon(client, substrate_hash) {
Expand Down
11 changes: 9 additions & 2 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,15 @@ pub fn frontier_database_dir(config: &Configuration, path: &str) -> std::path::P

// TODO This is copied from frontier. It should be imported instead after
// https://github.com/paritytech/frontier/issues/333 is solved
pub fn open_frontier_backend(config: &Configuration) -> Result<Arc<fc_db::Backend<Block>>, String> {
pub fn open_frontier_backend<C>(
client: Arc<C>,
config: &Configuration,
) -> Result<Arc<fc_db::Backend<Block>>, String>
where
C: sp_blockchain::HeaderBackend<Block>,
{
Ok(Arc::new(fc_db::Backend::<Block>::new(
client,
&fc_db::DatabaseSettings {
source: match config.database {
DatabaseSource::RocksDb { .. } => DatabaseSource::RocksDb {
Expand Down Expand Up @@ -401,7 +408,7 @@ where
let filter_pool: Option<FilterPool> = Some(Arc::new(Mutex::new(BTreeMap::new())));
let fee_history_cache: FeeHistoryCache = Arc::new(Mutex::new(BTreeMap::new()));

let frontier_backend = open_frontier_backend(config)?;
let frontier_backend = open_frontier_backend(client.clone(), config)?;

let frontier_block_import =
FrontierBlockImport::new(client.clone(), client.clone(), frontier_backend.clone());
Expand Down
12 changes: 7 additions & 5 deletions tests/util/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ export async function upgradeRuntime(api: ApiPromise, preferences: UpgradePrefer
}
if (options.waitMigration) {
const blockToWait = (await api.rpc.chain.getHeader()).number.toNumber() + 1;
const subBlocks = await api.rpc.chain.subscribeNewHeads(async (header) => {
if (header.number.toNumber() == blockToWait) {
subBlocks();
resolve(blockToWait);
}
await new Promise(async (resolve) => {
const subBlocks = await api.rpc.chain.subscribeNewHeads(async (header) => {
if (header.number.toNumber() == blockToWait) {
subBlocks();
resolve(blockToWait);
}
});
});
}
resolve(blockNumber);
Expand Down