Backport commits to beta (#1763)
* Don't try to sync to ancient blocks * Parallel block body download * Fixed reading chunked EIP8 handshake (#1712) * Fixed reading chunked EIP8 handshake * Added missing break * Disconnect peers on a fork * Updated json-ipc-server * Combine mining queue and enabled into single locked datum (#1749) * Combine mining queue and enabled into single locked datum Additional tracing. * Fix bug uncovered by test. * Fix typo * Remove unneeded log initialisation in test. * fix failing test (#1756) * Fixed test * Suicides tracing (#1688) * tracing suicide * fixed #1635 * fixed typo * Stackoverflow #1686 (#1698) * flat trace serialization * tracing finds transaction which creates contract * flatten traces before inserting them to the db * Trace other types of calls (#1727) * Trace through DELEGATECALL and CALLCODE Add them to the JSON output and RLP database store. * Fix tests. * Fix all tests. * Fix one more test. * filtering transactions toAddress includes contract creation (#1697) * tracing finds transaction which creates contract * comma cleanup Remove when following `}`s, add to final entries. * Various improvements to tracing & diagnostics. (#1707) * Various improvements to tracing & diagnostics. - Manage possibility of `Account` not having code for `PodAccount` - New RPC: `trace_sendRawTransaction` - See raw transaction dump when inspecting over RPC * Fix test * Remove one of the dupe error messages * Remove unneeded `&`s * Reformat and extremely minor optimisation * Minor optimisation * Remove unneeded let * Fix tests. * Additional fix. * Minor rename. * Bowing to the pressure. * Stackoverflow fix (#1742) * executive tracer builds flat traces without intermediate struct * temporarilt commented out tests for traces * fixed new way of building trace address * fixed new way of building trace address * updating state tests with flat tracing in progress * fixed flat tracing tests * fixed compiling ethcore-rpc with new flat traces * removed warnings from ethcore module * remove unused data structures
This commit is contained in:
committed by
Gav Wood
parent
429c83f92f
commit
8017daf47c
@@ -77,7 +77,7 @@ impl<Socket: GenericSocket> GenericConnection<Socket> {
|
||||
/// Readable IO handler. Called when there is some data to be read.
|
||||
pub fn readable(&mut self) -> io::Result<Option<Bytes>> {
|
||||
if self.rec_size == 0 || self.rec_buf.len() >= self.rec_size {
|
||||
warn!(target:"network", "Unexpected connection read");
|
||||
return Ok(None);
|
||||
}
|
||||
let sock_ref = <Socket as Read>::by_ref(&mut self.socket);
|
||||
loop {
|
||||
|
||||
@@ -128,31 +128,27 @@ impl Handshake {
|
||||
/// Readable IO handler. Drives the state change.
|
||||
pub fn readable<Message>(&mut self, io: &IoContext<Message>, host: &HostInfo) -> Result<(), UtilError> where Message: Send + Clone {
|
||||
if !self.expired() {
|
||||
match self.state {
|
||||
HandshakeState::New => {}
|
||||
HandshakeState::ReadingAuth => {
|
||||
if let Some(data) = try!(self.connection.readable()) {
|
||||
while let Some(data) = try!(self.connection.readable()) {
|
||||
match self.state {
|
||||
HandshakeState::New => {},
|
||||
HandshakeState::StartSession => {},
|
||||
HandshakeState::ReadingAuth => {
|
||||
try!(self.read_auth(io, host.secret(), &data));
|
||||
};
|
||||
},
|
||||
HandshakeState::ReadingAuthEip8 => {
|
||||
if let Some(data) = try!(self.connection.readable()) {
|
||||
},
|
||||
HandshakeState::ReadingAuthEip8 => {
|
||||
try!(self.read_auth_eip8(io, host.secret(), &data));
|
||||
};
|
||||
},
|
||||
HandshakeState::ReadingAck => {
|
||||
if let Some(data) = try!(self.connection.readable()) {
|
||||
},
|
||||
HandshakeState::ReadingAck => {
|
||||
try!(self.read_ack(host.secret(), &data));
|
||||
};
|
||||
},
|
||||
HandshakeState::ReadingAckEip8 => {
|
||||
if let Some(data) = try!(self.connection.readable()) {
|
||||
},
|
||||
HandshakeState::ReadingAckEip8 => {
|
||||
try!(self.read_ack_eip8(host.secret(), &data));
|
||||
};
|
||||
},
|
||||
HandshakeState::StartSession => {
|
||||
},
|
||||
}
|
||||
if self.state == HandshakeState::StartSession {
|
||||
io.clear_timer(self.connection.token).ok();
|
||||
},
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@@ -178,9 +174,9 @@ impl Handshake {
|
||||
|
||||
/// Parse, validate and confirm auth message
|
||||
fn read_auth<Message>(&mut self, io: &IoContext<Message>, secret: &Secret, data: &[u8]) -> Result<(), UtilError> where Message: Send + Clone {
|
||||
trace!(target:"network", "Received handshake auth from {:?}", self.connection.remote_addr_str());
|
||||
trace!(target: "network", "Received handshake auth from {:?}", self.connection.remote_addr_str());
|
||||
if data.len() != V4_AUTH_PACKET_SIZE {
|
||||
debug!(target:"net", "Wrong auth packet size");
|
||||
debug!(target: "network", "Wrong auth packet size");
|
||||
return Err(From::from(NetworkError::BadProtocol));
|
||||
}
|
||||
self.auth_cipher = data.to_vec();
|
||||
@@ -197,7 +193,7 @@ impl Handshake {
|
||||
// Try to interpret as EIP-8 packet
|
||||
let total = (((data[0] as u16) << 8 | (data[1] as u16)) as usize) + 2;
|
||||
if total < V4_AUTH_PACKET_SIZE {
|
||||
debug!(target:"net", "Wrong EIP8 auth packet size");
|
||||
debug!(target: "network", "Wrong EIP8 auth packet size");
|
||||
return Err(From::from(NetworkError::BadProtocol));
|
||||
}
|
||||
let rest = total - data.len();
|
||||
@@ -209,7 +205,7 @@ impl Handshake {
|
||||
}
|
||||
|
||||
fn read_auth_eip8<Message>(&mut self, io: &IoContext<Message>, secret: &Secret, data: &[u8]) -> Result<(), UtilError> where Message: Send + Clone {
|
||||
trace!(target:"network", "Received EIP8 handshake auth from {:?}", self.connection.remote_addr_str());
|
||||
trace!(target: "network", "Received EIP8 handshake auth from {:?}", self.connection.remote_addr_str());
|
||||
self.auth_cipher.extend_from_slice(data);
|
||||
let auth = try!(ecies::decrypt(secret, &self.auth_cipher[0..2], &self.auth_cipher[2..]));
|
||||
let rlp = UntrustedRlp::new(&auth);
|
||||
@@ -224,9 +220,9 @@ impl Handshake {
|
||||
|
||||
/// Parse and validate ack message
|
||||
fn read_ack(&mut self, secret: &Secret, data: &[u8]) -> Result<(), UtilError> {
|
||||
trace!(target:"network", "Received handshake ack from {:?}", self.connection.remote_addr_str());
|
||||
trace!(target: "network", "Received handshake ack from {:?}", self.connection.remote_addr_str());
|
||||
if data.len() != V4_ACK_PACKET_SIZE {
|
||||
debug!(target:"net", "Wrong ack packet size");
|
||||
debug!(target: "network", "Wrong ack packet size");
|
||||
return Err(From::from(NetworkError::BadProtocol));
|
||||
}
|
||||
self.ack_cipher = data.to_vec();
|
||||
@@ -240,7 +236,7 @@ impl Handshake {
|
||||
// Try to interpret as EIP-8 packet
|
||||
let total = (((data[0] as u16) << 8 | (data[1] as u16)) as usize) + 2;
|
||||
if total < V4_ACK_PACKET_SIZE {
|
||||
debug!(target:"net", "Wrong EIP8 ack packet size");
|
||||
debug!(target: "network", "Wrong EIP8 ack packet size");
|
||||
return Err(From::from(NetworkError::BadProtocol));
|
||||
}
|
||||
let rest = total - data.len();
|
||||
@@ -252,7 +248,7 @@ impl Handshake {
|
||||
}
|
||||
|
||||
fn read_ack_eip8(&mut self, secret: &Secret, data: &[u8]) -> Result<(), UtilError> {
|
||||
trace!(target:"network", "Received EIP8 handshake auth from {:?}", self.connection.remote_addr_str());
|
||||
trace!(target: "network", "Received EIP8 handshake auth from {:?}", self.connection.remote_addr_str());
|
||||
self.ack_cipher.extend_from_slice(data);
|
||||
let ack = try!(ecies::decrypt(secret, &self.ack_cipher[0..2], &self.ack_cipher[2..]));
|
||||
let rlp = UntrustedRlp::new(&ack);
|
||||
@@ -265,7 +261,7 @@ impl Handshake {
|
||||
|
||||
/// Sends auth message
|
||||
fn write_auth<Message>(&mut self, io: &IoContext<Message>, secret: &Secret, public: &Public) -> Result<(), UtilError> where Message: Send + Clone {
|
||||
trace!(target:"network", "Sending handshake auth to {:?}", self.connection.remote_addr_str());
|
||||
trace!(target: "network", "Sending handshake auth to {:?}", self.connection.remote_addr_str());
|
||||
let mut data = [0u8; /*Signature::SIZE*/ 65 + /*H256::SIZE*/ 32 + /*Public::SIZE*/ 64 + /*H256::SIZE*/ 32 + 1]; //TODO: use associated constants
|
||||
let len = data.len();
|
||||
{
|
||||
@@ -292,7 +288,7 @@ impl Handshake {
|
||||
|
||||
/// Sends ack message
|
||||
fn write_ack<Message>(&mut self, io: &IoContext<Message>) -> Result<(), UtilError> where Message: Send + Clone {
|
||||
trace!(target:"network", "Sending handshake ack to {:?}", self.connection.remote_addr_str());
|
||||
trace!(target: "network", "Sending handshake ack to {:?}", self.connection.remote_addr_str());
|
||||
let mut data = [0u8; 1 + /*Public::SIZE*/ 64 + /*H256::SIZE*/ 32]; //TODO: use associated constants
|
||||
let len = data.len();
|
||||
{
|
||||
@@ -311,7 +307,7 @@ impl Handshake {
|
||||
|
||||
/// Sends EIP8 ack message
|
||||
fn write_ack_eip8<Message>(&mut self, io: &IoContext<Message>) -> Result<(), UtilError> where Message: Send + Clone {
|
||||
trace!(target:"network", "Sending EIP8 handshake ack to {:?}", self.connection.remote_addr_str());
|
||||
trace!(target: "network", "Sending EIP8 handshake ack to {:?}", self.connection.remote_addr_str());
|
||||
let mut rlp = RlpStream::new_list(3);
|
||||
rlp.append(self.ecdhe.public());
|
||||
rlp.append(&self.nonce);
|
||||
|
||||
Reference in New Issue
Block a user