This commit is contained in:
silentcicero 2019-05-13 17:42:21 +01:00
parent 07d2d83c31
commit 069a21d972
5 changed files with 24 additions and 0 deletions

View file

@ -365,6 +365,10 @@ func gasSLoad(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, me
return gt.SLoad, nil return gt.SLoad, nil
} }
func gasSLoadExt(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
return gt.SLoad, nil
}
func gasExp(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) { func gasExp(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
expByteLen := uint64((stack.data[stack.len()-2].BitLen() + 7) / 8) expByteLen := uint64((stack.data[stack.len()-2].BitLen() + 7) / 8)

View file

@ -633,6 +633,15 @@ func opSload(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory
return nil, nil return nil, nil
} }
func opSloadExt(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
addr := common.BigToAddress(stack.pop())
loc := stack.pop()
val := interpreter.evm.StateDB.GetState(addr, common.BigToHash(loc))
loc.SetBytes(val.Bytes())
return nil, nil
}
func opSstore(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { func opSstore(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
loc := common.BigToHash(stack.pop()) loc := common.BigToHash(stack.pop())
val := stack.pop() val := stack.pop()

View file

@ -513,6 +513,13 @@ func newFrontierInstructionSet() [256]operation {
maxStack: maxStack(1, 1), maxStack: maxStack(1, 1),
valid: true, valid: true,
}, },
SLOADEXT: {
execute: opSload,
dynamicGas: gasSLoad,
minStack: minStack(2, 1),
maxStack: maxStack(2, 1),
valid: true,
},
SSTORE: { SSTORE: {
execute: opSstore, execute: opSstore,
dynamicGas: gasSStore, dynamicGas: gasSStore,

View file

@ -110,6 +110,7 @@ const (
MSTORE MSTORE
MSTORE8 MSTORE8
SLOAD SLOAD
SLOADEXT
SSTORE SSTORE
JUMP JUMP
JUMPI JUMPI
@ -286,6 +287,7 @@ var opCodeToString = map[OpCode]string{
MSTORE: "MSTORE", MSTORE: "MSTORE",
MSTORE8: "MSTORE8", MSTORE8: "MSTORE8",
SLOAD: "SLOAD", SLOAD: "SLOAD",
SLOADEXT: "SLOADEXT",
SSTORE: "SSTORE", SSTORE: "SSTORE",
JUMP: "JUMP", JUMP: "JUMP",
JUMPI: "JUMPI", JUMPI: "JUMPI",
@ -449,6 +451,7 @@ var stringToOp = map[string]OpCode{
"MSTORE": MSTORE, "MSTORE": MSTORE,
"MSTORE8": MSTORE8, "MSTORE8": MSTORE8,
"SLOAD": SLOAD, "SLOAD": SLOAD,
"SLOADEXT": SLOADEXT,
"SSTORE": SSTORE, "SSTORE": SSTORE,
"JUMP": JUMP, "JUMP": JUMP,
"JUMPI": JUMPI, "JUMPI": JUMPI,

View file

@ -26,6 +26,7 @@ const (
MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis. MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis.
ExpByteGas uint64 = 10 // Times ceil(log256(exponent)) for the EXP instruction. ExpByteGas uint64 = 10 // Times ceil(log256(exponent)) for the EXP instruction.
SloadGas uint64 = 50 // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. SloadGas uint64 = 50 // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added.
SloadExtGas uint64 = 50 // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added.
CallValueTransferGas uint64 = 9000 // Paid for CALL when the value transfer is non-zero. CallValueTransferGas uint64 = 9000 // Paid for CALL when the value transfer is non-zero.
CallNewAccountGas uint64 = 25000 // Paid for CALL when the destination address didn't exist prior. CallNewAccountGas uint64 = 25000 // Paid for CALL when the destination address didn't exist prior.
TxGas uint64 = 21000 // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions. TxGas uint64 = 21000 // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions.