adapting for poc-7 final (eth:46) - one more time
This commit is contained in:
parent
a2c0d28a13
commit
bb1efc4aa5
|
@ -170,7 +170,7 @@ public class BlockchainImpl implements Blockchain {
|
|||
// version of block we already
|
||||
// got on the main chain
|
||||
long gap = bestBlock.getNumber() - block.getNumber();
|
||||
if (hasParentOnTheChain(block) && gap <=0){
|
||||
if (hasParentOnTheChain(block) && gap >=0){
|
||||
|
||||
logger.info("created alt chain by block.hash: [{}] ", block.getShortHash());
|
||||
Chain chain = new Chain();
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.spongycastle.util.encoders.Hex;
|
|||
|
||||
public class Bloom {
|
||||
|
||||
byte[] data = new byte[512];
|
||||
byte[] data = new byte[64];
|
||||
|
||||
|
||||
public Bloom(byte[] data){
|
||||
|
@ -25,7 +25,7 @@ public class Bloom {
|
|||
int mov2 = (toBloom[2] & 1) * 256 + (toBloom[3] & 255);
|
||||
int mov3 = (toBloom[4] & 1) * 256 + (toBloom[5] & 255);
|
||||
|
||||
byte[] data = new byte[512];
|
||||
byte[] data = new byte[64];
|
||||
Bloom bloom = new Bloom(data);
|
||||
|
||||
bloom.setBit(mov1, 1);
|
||||
|
@ -44,7 +44,7 @@ public class Bloom {
|
|||
|
||||
public void setBit(int pos, int val) {
|
||||
|
||||
if (data.length - 1 < pos )
|
||||
if (data.length * 8 < pos )
|
||||
throw new Error("outside bloom limit, pos: " + pos);
|
||||
|
||||
int posByte = (pos - 1) / 8;
|
||||
|
|
|
@ -22,4 +22,5 @@ public interface EthereumListener {
|
|||
public void onPeerDisconnect(String host, long port);
|
||||
public void onPendingTransactionsReceived(Set<Transaction> transactions);
|
||||
public void onSyncDone();
|
||||
public void onNoConnections();
|
||||
}
|
||||
|
|
|
@ -40,4 +40,9 @@ public class EthereumListenerAdapter implements EthereumListener {
|
|||
public void onSyncDone() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNoConnections(){
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,13 @@ public class EthereumListenerWrapper implements EthereumListener{
|
|||
listener.onSyncDone();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onNoConnections(){
|
||||
if (listener != null)
|
||||
listener.onNoConnections();
|
||||
}
|
||||
|
||||
public void addListener(EthereumListener listener){
|
||||
if (listener != null)
|
||||
this.listener = listener;
|
||||
|
|
|
@ -67,12 +67,6 @@ public class Miner {
|
|||
byte[] target = BigIntegers.asUnsignedByteArray(32,
|
||||
max.divide(new BigInteger(1, difficulty)));
|
||||
|
||||
// return timestamp >= _parent.timestamp + 5 ? _parent.difficulty - (_parent.difficulty >> 10) : (_parent.difficulty + (_parent.difficulty >> 10));
|
||||
BigInteger bi = new BigInteger(newBlock.getDifficulty());
|
||||
BigInteger delta = bi.shiftRight(10);
|
||||
newBlock.getHeader().setDifficulty( BigIntegers.asUnsignedByteArray( bi.subtract(delta) ));
|
||||
|
||||
// return max<u256>(125000, (_parent.gasLimit * (1024 - 1) + (_parent.gasUsed * 6 / 5)) / 1024);
|
||||
|
||||
long newGasLimit = Math.max(125000,
|
||||
(newBlock.getGasLimit() * (1024 - 1) + (newBlock.getGasUsed() * 6 / 5)) / 1024);
|
||||
|
|
|
@ -42,7 +42,7 @@ import static org.ethereum.net.message.StaticMessages.GET_TRANSACTIONS_MESSAGE;
|
|||
@Scope("prototype")
|
||||
public class EthHandler extends SimpleChannelInboundHandler<EthMessage> {
|
||||
|
||||
public final static byte VERSION = 45;
|
||||
public final static byte VERSION = 46;
|
||||
public final static byte NETWORK_ID = 0x0;
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger("net");
|
||||
|
|
|
@ -3,10 +3,13 @@ package org.ethereum.net.server;
|
|||
import org.ethereum.core.Block;
|
||||
import org.ethereum.core.Transaction;
|
||||
import org.ethereum.db.ByteArrayWrapper;
|
||||
import org.ethereum.manager.WorldManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -25,9 +28,18 @@ public class ChannelManager {
|
|||
|
||||
Map<ByteArrayWrapper, Block> blockCache = new HashMap<>();
|
||||
|
||||
@Autowired
|
||||
WorldManager worldManager;
|
||||
|
||||
public ChannelManager() {
|
||||
}
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
scheduleChannelCollector();
|
||||
}
|
||||
|
||||
public void recvTransaction(){
|
||||
// ???
|
||||
}
|
||||
|
@ -79,6 +91,10 @@ public class ChannelManager {
|
|||
logger.info("Channel removed: {}", channel.p2pHandler.getHandshakeHelloMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (channels.size() == 0){
|
||||
worldManager.getListener().onNoConnections();
|
||||
}
|
||||
}
|
||||
}, 2000, 5000);
|
||||
}
|
||||
|
|
|
@ -305,11 +305,11 @@ public enum OpCode {
|
|||
CREATE(0xf0, 3), // [in_size] [in_offs] [gas_val] CREATE
|
||||
/** (cxf1) Message-call into an account */
|
||||
CALL(0xf1, 7), // [out_data_size] [out_data_start] [in_data_size] [in_data_start] [value] [to_addr] [gas] CALL
|
||||
/** (0xf2) Halt execution returning output data */
|
||||
RETURN(0xf2, 2),
|
||||
/** (0xf3) Calls self, but grabbing the code from the
|
||||
/** (0xf2) Calls self, but grabbing the code from the
|
||||
* TO argument instead of from one's own address */
|
||||
CALLCODE(0xf3, 7),
|
||||
CALLCODE(0xf2, 7),
|
||||
/** (0xf3) Halt execution returning output data */
|
||||
RETURN(0xf3, 2),
|
||||
/** (0xff) Halt execution and register account for
|
||||
* later deletion */
|
||||
SUICIDE(0xff, 1);
|
||||
|
|
|
@ -821,7 +821,7 @@ public class VM {
|
|||
case JUMP:{
|
||||
DataWord pos = program.stackPop();
|
||||
int nextPC = pos.intValue(); // possible overflow
|
||||
if (nextPC != 0 && program.getOp(nextPC-1) != OpCode.JUMPDEST.val())
|
||||
if (nextPC != 0 && program.getOp(nextPC) != OpCode.JUMPDEST.val())
|
||||
throw program.new BadJumpDestinationException();
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
|
|
|
@ -44,4 +44,14 @@ public class BloomTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test4(){
|
||||
|
||||
byte[] key = SHA3Helper.sha3(Hex.decode("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6"));
|
||||
|
||||
Bloom bloom = Bloom.create(key);
|
||||
System.out.println(bloom);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2404,7 +2404,7 @@ public class VMTest {
|
|||
public void testRETURN_1() {
|
||||
|
||||
VM vm = new VM();
|
||||
program = new Program(Hex.decode("61123460005260206000F2"), invoke);
|
||||
program = new Program(Hex.decode("61123460005260206000F3"), invoke);
|
||||
String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000001234";
|
||||
|
||||
vm.step(program);
|
||||
|
@ -2423,7 +2423,7 @@ public class VMTest {
|
|||
public void testRETURN_2() {
|
||||
|
||||
VM vm = new VM();
|
||||
program = new Program(Hex.decode("6112346000526020601FF2"), invoke);
|
||||
program = new Program(Hex.decode("6112346000526020601FF3"), invoke);
|
||||
String s_expected_1 = "3400000000000000000000000000000000000000000000000000000000000000";
|
||||
|
||||
vm.step(program);
|
||||
|
@ -2442,7 +2442,7 @@ public class VMTest {
|
|||
|
||||
VM vm = new VM();
|
||||
program =
|
||||
new Program(Hex.decode("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B160005260206000F2"),
|
||||
new Program(Hex.decode("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B160005260206000F3"),
|
||||
invoke);
|
||||
String s_expected_1 = "A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1";
|
||||
|
||||
|
@ -2463,7 +2463,7 @@ public class VMTest {
|
|||
|
||||
VM vm = new VM();
|
||||
program =
|
||||
new Program(Hex.decode("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B160005260206010F2"),
|
||||
new Program(Hex.decode("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B160005260206010F3"),
|
||||
invoke);
|
||||
String s_expected_1 = "E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B100000000000000000000000000000000";
|
||||
|
||||
|
|
Loading…
Reference in New Issue