mirror of
https://github.com/status-im/ethereumj-personal.git
synced 2025-02-19 15:14:14 +00:00
eth:49 adaption:
+ SHA3 new cost calc
This commit is contained in:
parent
8320c53d40
commit
6cfcb83476
@ -43,7 +43,7 @@ import static org.ethereum.net.message.StaticMessages.GET_TRANSACTIONS_MESSAGE;
|
|||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
public class EthHandler extends SimpleChannelInboundHandler<EthMessage> {
|
public class EthHandler extends SimpleChannelInboundHandler<EthMessage> {
|
||||||
|
|
||||||
public final static byte VERSION = 48;
|
public final static byte VERSION = 49;
|
||||||
public final static byte NETWORK_ID = 0x0;
|
public final static byte NETWORK_ID = 0x0;
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger("net");
|
private final static Logger logger = LoggerFactory.getLogger("net");
|
||||||
|
@ -12,8 +12,8 @@ public class GasCost {
|
|||||||
public static int STEP = 1;
|
public static int STEP = 1;
|
||||||
/** Cost 20 gas */
|
/** Cost 20 gas */
|
||||||
public static int BALANCE = 20;
|
public static int BALANCE = 20;
|
||||||
/** Cost 20 gas */
|
/** Cost 10 gas */
|
||||||
public static int SHA3 = 20;
|
public static int SHA3 = 10;
|
||||||
/** Cost 20 gas */
|
/** Cost 20 gas */
|
||||||
public static int SLOAD = 20;
|
public static int SLOAD = 20;
|
||||||
/** Cost 0 gas */
|
/** Cost 0 gas */
|
||||||
|
@ -135,6 +135,13 @@ public class VM {
|
|||||||
case SHA3:
|
case SHA3:
|
||||||
gasCost = GasCost.SHA3;
|
gasCost = GasCost.SHA3;
|
||||||
newMemSize = memNeeded(stack.peek(), stack.get(stack.size()-2));
|
newMemSize = memNeeded(stack.peek(), stack.get(stack.size()-2));
|
||||||
|
|
||||||
|
DataWord size = stack.get(stack.size()-2);
|
||||||
|
long chunkUsed = (size.longValue() + 31) / 32;
|
||||||
|
gasCost += chunkUsed * GasCost.SHA3;
|
||||||
|
|
||||||
|
//todo: calc how much bytes for sha3(): sha3 / 32 * 10
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CALLDATACOPY:
|
case CALLDATACOPY:
|
||||||
copySize = stack.get(stack.size()-3).longValue();
|
copySize = stack.get(stack.size()-3).longValue();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user