Fix polling loop and implement ERC-20-aware mempool (#184)
This commit fixes a critical bug in the transaction polling loop that was causing premature test failures and implements an ERC-20-aware mempool to eliminate MVCC conflicts through intelligent transaction scheduling.
The polling loop in integration/perf/replay_json_dataset_test.go was incorrectly timing out after approximately 100ms (100 iterations with minimal delay), which was insufficient for transactions to be committed during high-throughput testing. The fix removes the iteration counter and allows the loop to poll indefinitely until the transaction is found or an actual error occurs.
The main enhancement is a new dependency-aware transaction queue in gateway/core/txqueue.go that acts as an intelligent mempool. The queue tracks in-progress participants (both senders and recipients) for all transactions and gates any pending transaction that shares a participant with an in-flight transaction. This ensures transactions touching the same ERC-20 token accounts are properly serialized, preventing concurrent state modifications that cause MVCC conflicts. The implementation extracts participants from both regular transfers and ERC-20 token transfers by parsing the transfer function signature and recipient address from transaction data.
Signed-off-by: Alessandro Sorniotti aso@zurich.ibm.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
fabric-x-evm
fabric-x-evm makes Hyperledger Fabric-x (and Fabric) compatible with the Ethereum ecosystem by providing an Ethereum-style JSON-RPC API and native support for EVM smart contracts within Fabric’s permissioned environment. This integration combines the rich Ethereum tooling and contract ecosystem with Fabric’s robust endorsement and consensus model.
By embedding an Ethereum Virtual Machine (EVM) inside Fabric, developers can deploy and execute existing Ethereum smart contracts without modification, while benefiting from Fabric’s enterprise-grade features including fine-grained access control, privacy, and deterministic consensus. The solution preserves Fabric’s transaction flow, trust guarantees, and high performance while enabling seamless use of the Ethereum development toolchain—including Solidity, Hardhat, Foundry, and MetaMask.
This approach broadens Fabric’s appeal and lowers the barrier for organizations that want to leverage existing Ethereum assets, developer expertise, and tooling in a permissioned, enterprise blockchain setting.
Design
Here
Quick start
Stand up a full Fabric-X EVM network with a block explorer in two commands:
Once the stack is up, open the block explorer at http://localhost:8000 and point any Ethereum tooling to http://localhost:8545 (chain ID
4011). You can now use the system as any other EVM-style chain! Backed by Fabric-X.Deploy a token and interact via MetaMask
You’ll need:
The commands below use built-in test accounts — gas is free so no prefunding is needed. Substitute any address or private key if you prefer your own accounts.
To use MetaMask with the test wallet, import this private key (instructions): open the extension → your account → Add Wallet → Private Key, and enter
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80.Deploy a token
Deploy an ERC-20 token by choosing a name and symbol:
The explorer URL is printed immediately:
Open the URL. Scroll to the bottom and click “Add Fabric-X EVM” to add the network to MetaMask (only needed once):
Then click the MetaMask logo next to the token contract address to add the token to your wallet:
Transfer tokens
Copy your MetaMask address and run:
The transaction URL is printed immediately:
Switch to MetaMask and confirm the tokens arrived. Try sending some back — there’s no gas cost, so experimenting is free.
You’re now running your own Fabric-X EVM network. Deploy your own contracts with tooling you’re familiar with, or explore the architecture, compatibility, and JSON-RPC error codes docs to learn more.
To stop the network and delete the ledger, do:
Reset your Metamask wallet in Settings → Developer tools → Delete activity and nonce data.
Testing
Unit tests
Integration tests
Some integration tests rely on the
ethereum/testscorpus vendored as a git submodule undertestdata/ethereum-tests. Initialize it once before running those tests:Local
The simplest integration tests don’t require a Fabric network, but still exercise the basic functionality of creating read/write sets out of EVM transactions, and subsequently reading them.
Fabric-X
Generate the crypto material once:
Then start the Fabric-X testcontainer and create the namespace, run the integration tests against it, and stop it again:
The container does not keep state.
Fablo
Start the network, run the integration tests, and stop it again:
Compile other smart contracts
Example contracts are provided in the
solidity/directory. Requires solc (brew install solidity).To recompile the
Tokencontract used bymake demo-deploy:License
This repository uses different licenses for different components:
LICENSE.LGPL3)LICENSE.Apache2)SPDX License Expression