Skip to content

Commit 2f05dc8

Browse files
committed
precompiles: Remove cache layer and JSON stubs
1 parent dffed13 commit 2f05dc8

File tree

7 files changed

+6
-954
lines changed

7 files changed

+6
-954
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,12 @@ To build the evmone EVMC module (shared library), test, and benchmark:
9191

9292
### Precompiles
9393

94-
Ethereum Precompiled Contracts (_precompiles_ for short) are not directly supported by evmone.
94+
Ethereum Precompiled Contracts (_precompiles_ for short) are only partly supported by evmone.
9595

9696
However, there are options to enable limited precompiles support for testing.
9797

98-
1. The [test/state/precompiles_stub.json](./test/state/precompiles_stub.json) contains
99-
precompiles execution results for inputs commonly used in tests.
100-
You can use the precompiles STUB by setting the environment variable
101-
`EVMONE_PRECOMPILES_STUB=./test/state/precompiles_stub.json`.
98+
1. For precompiles with missing implementation stubs are enabled by default.
99+
They will correctly respond to known inputs.
102100
2. The CMake option `EVMONE_PRECOMPILES_SILKPRE=1` enables building of
103101
the [silkpre] third party library with the implementation of the precompiles.
104102
This library also requires [GMP] (e.g. libgmp-dev) library for building and execution.

circle.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,11 @@ jobs:
410410
name: "Execution spec tests (blockchain_tests)"
411411
working_directory: ~/build
412412
command: >
413-
EVMONE_PRECOMPILES_STUB=~/project/test/state/precompiles_stub.json
414413
bin/evmone-blockchaintest ~/spec-tests/fixtures/blockchain_tests
415414
- run:
416415
name: "Execution spec tests (state_tests)"
417416
working_directory: ~/build
418417
command: >
419-
EVMONE_PRECOMPILES_STUB=~/project/test/state/precompiles_stub.json
420418
bin/evmone-statetest ~/spec-tests/fixtures/state_tests
421419
422420
- download_execution_tests:
@@ -427,31 +425,27 @@ jobs:
427425
name: "State tests"
428426
working_directory: ~/build
429427
command: >
430-
EVMONE_PRECOMPILES_STUB=~/project/test/state/precompiles_stub.json
431428
bin/evmone-statetest
432429
~/tests/GeneralStateTests
433430
~/tests/LegacyTests/Constantinople/GeneralStateTests
434431
- run:
435432
name: "Blockchain tests (GeneralStateTests)"
436433
working_directory: ~/build
437434
command: >
438-
EVMONE_PRECOMPILES_STUB=~/project/test/state/precompiles_stub.json
439435
bin/evmone-blockchaintest
440436
--gtest_filter='*:-VMTests/vmPerformance.*:*.*Call50000_sha256:*.CALLBlake2f_MaxRounds'
441437
~/tests/BlockchainTests/GeneralStateTests
442438
- run:
443439
name: "Blockchain tests (ValidBlocks)"
444440
working_directory: ~/build
445441
command: >
446-
EVMONE_PRECOMPILES_STUB=~/project/test/state/precompiles_stub.json
447442
bin/evmone-blockchaintest
448443
--gtest_filter='*:-bcMultiChainTest.*:bcTotalDifficultyTest.*:bcForkStressTest.ForkStressTest:bcGasPricerTest.RPC_API_Test:bcValidBlockTest.SimpleTx3LowS'
449444
~/tests/BlockchainTests/ValidBlocks
450445
- run:
451446
name: "Blockchain tests (EIPs)"
452447
working_directory: ~/build
453448
command: >
454-
EVMONE_PRECOMPILES_STUB=~/project/test/state/precompiles_stub.json
455449
bin/evmone-blockchaintest
456450
--gtest_filter='-*StateTests/stEOF/*.*'
457451
~/tests/EIPTests/BlockchainTests/

test/state/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ target_sources(
2424
mpt_hash.cpp
2525
precompiles.hpp
2626
precompiles.cpp
27-
precompiles_cache.hpp
28-
precompiles_cache.cpp
2927
precompiles_internal.hpp
3028
precompiles_stubs.hpp
3129
precompiles_stubs.cpp

test/state/precompiles.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
#include "precompiles.hpp"
6-
#include "precompiles_cache.hpp"
76
#include "precompiles_internal.hpp"
87
#include "precompiles_stubs.hpp"
98
#include <evmone_precompiles/blake2b.hpp>
109
#include <evmone_precompiles/bn254.hpp>
1110
#include <evmone_precompiles/ripemd160.hpp>
1211
#include <evmone_precompiles/secp256k1.hpp>
1312
#include <intx/intx.hpp>
13+
#include <array>
1414
#include <bit>
1515
#include <cassert>
16-
#include <iostream>
1716
#include <limits>
18-
#include <unordered_map>
1917

2018
#ifdef EVMONE_PRECOMPILES_SILKPRE
2119
#include "precompiles_silkpre.hpp"
2220
#endif
2321

2422
namespace evmone::state
2523
{
24+
using evmc::bytes;
25+
using evmc::bytes_view;
2626
using namespace evmc::literals;
2727

2828
namespace
@@ -357,10 +357,6 @@ evmc::Result call_precompile(evmc_revision rev, const evmc_message& msg) noexcep
357357
if (gas_left < 0)
358358
return evmc::Result{EVMC_OUT_OF_GAS};
359359

360-
static Cache cache;
361-
if (auto r = cache.find(static_cast<PrecompileId>(id), input, gas_left); r.has_value())
362-
return std::move(*r);
363-
364360
// Buffer for the precompile's output.
365361
// Big enough to handle all "expmod" tests, but in case does not match the size requirement
366362
// from analysis, the result will likely be incorrect.
@@ -374,8 +370,6 @@ evmc::Result call_precompile(evmc_revision rev, const evmc_message& msg) noexcep
374370
evmc::Result result{
375371
status_code, status_code == EVMC_SUCCESS ? gas_left : 0, 0, output_buf, output_size};
376372

377-
cache.insert(static_cast<PrecompileId>(id), input, result);
378-
379373
return result;
380374
}
381375
} // namespace evmone::state

test/state/precompiles_cache.cpp

Lines changed: 0 additions & 102 deletions
This file was deleted.

test/state/precompiles_cache.hpp

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)