Bläddra i källkod

params: Updated finalized gascosts for ECMUL/MODEXP (#15135)

* params: Updated finalized gascosts for ECMUL/MODEXP

* core,tests: Updates pending new tests

* tests: Updated with new tests

* core: revert state transition bugfix

* tests: Add expected failures due to  #15119
Martin Holst Swende 8 år sedan
förälder
incheckning
9be07de539
5 ändrade filer med 15 tillägg och 9 borttagningar
  1. 3 3
      core/vm/evm.go
  2. 2 2
      params/protocol_params.go
  3. 0 2
      tests/block_test.go
  4. 9 1
      tests/state_test.go
  5. 1 1
      tests/testdata

+ 3 - 3
core/vm/evm.go

@@ -299,9 +299,6 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
 
 // Create creates a new contract using code as deployment code.
 func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error) {
-	if evm.vmConfig.NoRecursion && evm.depth > 0 {
-		return nil, common.Address{}, gas, nil
-	}
 
 	// Depth check execution. Fail if we're trying to execute above the
 	// limit.
@@ -334,6 +331,9 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I
 	contract := NewContract(caller, AccountRef(contractAddr), value, gas)
 	contract.SetCallCode(&contractAddr, crypto.Keccak256Hash(code), code)
 
+	if evm.vmConfig.NoRecursion && evm.depth > 0 {
+		return nil, contractAddr, gas, nil
+	}
 	ret, err = run(evm, snapshot, contract, nil)
 	// check whether the max code size has been exceeded
 	maxCodeSizeExceeded := evm.ChainConfig().IsEIP158(evm.BlockNumber) && len(ret) > params.MaxCodeSize

+ 2 - 2
params/protocol_params.go

@@ -64,9 +64,9 @@ const (
 	Ripemd160PerWordGas     uint64 = 120    // Per-word price for a RIPEMD160 operation
 	IdentityBaseGas         uint64 = 15     // Base price for a data copy operation
 	IdentityPerWordGas      uint64 = 3      // Per-work price for a data copy operation
-	ModExpQuadCoeffDiv      uint64 = 100    // Divisor for the quadratic particle of the big int modular exponentiation
+	ModExpQuadCoeffDiv      uint64 = 20     // Divisor for the quadratic particle of the big int modular exponentiation
 	Bn256AddGas             uint64 = 500    // Gas needed for an elliptic curve addition
-	Bn256ScalarMulGas       uint64 = 2000   // Gas needed for an elliptic curve scalar multiplication
+	Bn256ScalarMulGas       uint64 = 40000  // Gas needed for an elliptic curve scalar multiplication
 	Bn256PairingBaseGas     uint64 = 100000 // Base price for an elliptic curve pairing check
 	Bn256PairingPerPointGas uint64 = 80000  // Per-point price for an elliptic curve pairing check
 )

+ 0 - 2
tests/block_test.go

@@ -32,8 +32,6 @@ func TestBlockchain(t *testing.T) {
 	bt.skipLoad(`^bcTotalDifficultyTest/(lotsOfLeafs|lotsOfBranches|sideChainWithMoreTransactions)`)
 	// Constantinople is not implemented yet.
 	bt.skipLoad(`(?i)(constantinople)`)
-	// Expected failures:
-	bt.fails(`^TransitionTests/bcHomesteadToDao/DaoTransactions(|_UncleExtradata|_EmptyTransactionAndForkBlocksAhead)\.json`, "issue in test")
 
 	// Still failing tests
 	bt.skipLoad(`^bcWalletTest.*_Byzantium$`)

+ 9 - 1
tests/state_test.go

@@ -39,6 +39,13 @@ func TestState(t *testing.T) {
 	st.fails(`^stRevertTest/RevertPrefoundEmptyOOG\.json/EIP158`, "bug in test")
 	st.fails(`^stRevertTest/RevertPrecompiledTouch\.json/Byzantium`, "bug in test")
 	st.fails(`^stRevertTest/RevertPrefoundEmptyOOG\.json/Byzantium`, "bug in test")
+	st.fails( `^stRandom/randomStatetest645\.json/EIP150/.*`, "known bug #15119")
+	st.fails( `^stRandom/randomStatetest645\.json/Frontier/.*`, "known bug #15119")
+	st.fails( `^stRandom/randomStatetest645\.json/Homestead/.*`, "known bug #15119")
+	st.fails( `^stRandom/randomStatetest644\.json/EIP150/.*`, "known bug #15119")
+	st.fails( `^stRandom/randomStatetest644\.json/Frontier/.*`, "known bug #15119")
+	st.fails( `^stRandom/randomStatetest644\.json/Homestead/.*`, "known bug #15119")
+
 
 	st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
 		for _, subtest := range test.Subtests() {
@@ -59,7 +66,8 @@ func TestState(t *testing.T) {
 }
 
 // Transactions with gasLimit above this value will not get a VM trace on failure.
-const traceErrorLimit = 400000
+//const traceErrorLimit = 400000
+const traceErrorLimit = 0
 
 func withTrace(t *testing.T, gasLimit uint64, test func(vm.Config) error) {
 	err := test(vm.Config{})

+ 1 - 1
tests/testdata

@@ -1 +1 @@
-Subproject commit 1d30b4795664f64b1b157971754e14a10cfd9115
+Subproject commit ca41e906351209481bce3a1b35501f25a79023c5