Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I120 remove registry #139

Closed
wants to merge 12 commits into from
Closed
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
12 changes: 8 additions & 4 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ jobs:
- ubuntu-latest
# - macos-latest
toolchain:
- 1.72
- 1.75
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout sources
uses: actions/checkout@main
with:
submodules: true
submodules: false
# submodules: true // we do not need submodules, if we are not running the JSON tests.
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -32,9 +33,12 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --locked --all --release --features "json-tests" --verbose --no-run
#args: deactivated JSON Tests, so we do not run out of quota on CI tests for merge intesive time. --locked --all --release --features "json-tests" --verbose --no-run
args: --locked --all --release --verbose --no-run
- name: Run tests for ${{ matrix.platform }}
uses: actions-rs/cargo@v1
with:
command: test
args: --locked --all --release --features "json-tests" --verbose
#args: deactivated JSON Tests --locked --all --release --features "json-tests" --verbose
args: --locked --all --release --verbose

4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/concensus/miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ common-types = { path = "../../ethcore/types" }
error-chain = "0.12"
ethabi = "12.0.0"
ethabi-derive = { git = 'https://github.com/rimrakhimov/ethabi', branch = 'rimrakhimov/remove-syn-export-span' }
ethabi-contract = "11.0.0"
ethabi-contract = "16.0.0"
ethcore-call-contract = { path = "../../vm/call-contract" }
ethereum-types = "0.9.2"
futures = "0.1"
Expand Down
36 changes: 13 additions & 23 deletions crates/concensus/miner/src/service_transaction_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ use call_contract::{CallContract, RegistryInfo};
use ethabi::FunctionOutputDecoder;
use ethereum_types::Address;
use parking_lot::RwLock;
use std::{collections::HashMap, mem, sync::Arc};
use std::{collections::HashMap, mem, str::FromStr, sync::Arc};
use types::{ids::BlockId, transaction::SignedTransaction};

use_contract!(
service_transaction,
"res/contracts/service_transaction.json"
);

const SERVICE_TRANSACTION_CONTRACT_REGISTRY_NAME: &'static str = "service_transaction_checker";

/// Service transactions checker.
#[derive(Default, Clone)]
pub struct ServiceTransactionChecker {
Expand Down Expand Up @@ -67,12 +65,8 @@ impl ServiceTransactionChecker {
{
return Ok(*allowed);
}
let contract_address = client
.registry_address(
SERVICE_TRANSACTION_CONTRACT_REGISTRY_NAME.to_owned(),
BlockId::Latest,
)
.ok_or_else(|| "Certifier contract is not configured")?;
let x = Address::from_str("5000000000000000000000000000000000000001".into()).unwrap();
let contract_address = x;
self.call_contract(client, contract_address, sender)
.and_then(|allowed| {
if let Some(mut cache) = self.certified_addresses_cache.try_write() {
Expand All @@ -95,21 +89,17 @@ impl ServiceTransactionChecker {
HashMap::default(),
);

if let Some(contract_address) = client.registry_address(
SERVICE_TRANSACTION_CONTRACT_REGISTRY_NAME.to_owned(),
BlockId::Latest,
) {
let addresses: Vec<_> = cache.keys().collect();
let mut cache: HashMap<Address, bool> = HashMap::default();
for address in addresses {
let allowed = self.call_contract(client, contract_address, *address)?;
cache.insert(*address, allowed);
}
*self.certified_addresses_cache.write() = cache;
Ok(true)
} else {
Ok(false)
let contract_address =
Address::from_str("5000000000000000000000000000000000000001".into()).unwrap();

let addresses: Vec<_> = cache.keys().collect();
let mut cache: HashMap<Address, bool> = HashMap::default();
for address in addresses {
let allowed = self.call_contract(client, contract_address, *address)?;
cache.insert(*address, allowed);
}
*self.certified_addresses_cache.write() = cache;
Ok(true)
}

fn call_contract<C: CallContract + RegistryInfo>(
Expand Down
2 changes: 1 addition & 1 deletion crates/ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ eip-152 = { version = "0.1", path = "../util/EIP-152" }
env_logger = { version = "0.5", optional = true }
error-chain = { version = "0.12", default-features = false }
ethabi = "12.0.0"
ethabi-contract = "11.0.0"
ethabi-contract = "16.0.0"
ethabi-derive = { git = 'https://github.com/rimrakhimov/ethabi', branch = 'rimrakhimov/remove-syn-export-span' }
ethash = { path = "../concensus/ethash" }
ethcore-blockchain = { path = "./blockchain" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ mod tests {
let signer = from_keypair(key1);

//let signer = Box::new(Signer (key1));
let signer_lock = Arc::new(RwLock::new(Some(signer)));
let signer_lock = std::sync::Arc::new(RwLock::new(Some(signer)));

let own_id = NodeId::default();
fork_manager.initialize(own_id, 8, vec![test_fork]);
Expand Down
17 changes: 10 additions & 7 deletions crates/ethcore/src/engines/hbbft/hbbft_peers_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#[derive(Clone, Debug)]
struct ValidatorConnectionData {
// mining_address: Address,
staking_address: Address,
socket_addr: SocketAddr,
public_key: NodeId,
// staking_address: Address,
// socket_addr: SocketAddr,
// public_key: NodeId,
peer_string: String,
mining_address: Address,
}
Expand All @@ -40,7 +40,9 @@
}
}

/// connections are not always required
/// connections are not always required.
/// - during syncing
/// - if not validator address specified.
fn should_not_connect(&self, client: &dyn BlockChainClient) -> bool {
// don't do any connections while the network is syncing.
// the connection is not required yet, and might be outdated.
Expand Down Expand Up @@ -299,7 +301,7 @@
/// because those should be current validators by now.
/// Make sure to connect to the new current validators,
/// before disconnecting from the pending validators.
pub fn disconnect_pending_validators(

Check warning on line 304 in crates/ethcore/src/engines/hbbft/hbbft_peers_management.rs

View workflow job for this annotation

GitHub Actions / Check

method `disconnect_pending_validators` is never used

Check warning on line 304 in crates/ethcore/src/engines/hbbft/hbbft_peers_management.rs

View workflow job for this annotation

GitHub Actions / Check

method `disconnect_pending_validators` is never used

Check warning on line 304 in crates/ethcore/src/engines/hbbft/hbbft_peers_management.rs

View workflow job for this annotation

GitHub Actions / Check

method `disconnect_pending_validators` is never used

Check warning on line 304 in crates/ethcore/src/engines/hbbft/hbbft_peers_management.rs

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest, 1.75)

method `disconnect_pending_validators` is never used
&mut self,
client: &dyn BlockChainClient,
) -> Result<usize, String> {
Expand Down Expand Up @@ -542,14 +544,15 @@
info!(target: "engine", "adding reserved peer: {}", peer_string);
if let Err(err) = peers_management.add_reserved_peer(&peer_string) {
warn!(target: "engine", "failed to adding reserved: {} : {}", peer_string, err);
return None;
}

return Some(ValidatorConnectionData {
staking_address: staking_address,
//staking_address: staking_address,
//mining_address: *address,
socket_addr: socket_addr,
//socket_addr: socket_addr,
peer_string,
public_key: node_id.clone(),
//public_key: node_id.clone(),
mining_address: Address::zero(), // all caller of this function will set this value.
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/net/node-filter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ log = "0.4"
parking_lot = "0.11.1"
ethabi = "12.0.0"
ethabi-derive = { git = 'https://github.com/rimrakhimov/ethabi', branch = 'rimrakhimov/remove-syn-export-span' }
ethabi-contract = "11.0.0"
ethabi-contract = "16.0.0"
lru-cache = "0.1"

[dev-dependencies]
Expand Down
Loading