bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 13쪽 중 5쪽
r commits batches via
Rollup.commitBatch
. That batch bundles the L2 transactions that execute the queued deposits; on L1, the rollup consumes the corresponding hashes via
consumeNextSentMessage
or
advanceSentMessageCursor
. Persistent semantics apply: consumed slots are not deleted — only the cursor moves forward. If a later
revertBatches
rewinds the rollup,
rewindSentMessageCursor
moves the bridge cursor backward to match, and the replacement batch re-consumes the same hashes.
On L2,
RELAYER_ROLE
calls
L2FluentBridge.receiveMessage(...)
. The bridge enforces the next expected
receivedNonce
, reconstructs the message hash, and refuses duplicates. Then it checks the committed
validUntilBlockNumber
against the latest L1 block number read from
L1BlockOracle
. If the deadline has passed, the bridge marks the message
Failed
, emits
RollbackMessage
(which becomes part of the L2 block's
withdrawalRoot
), and returns without executing. Otherwise it forwards the call to the gateway via
ExcessivelySafeCall
, bounded by
executeGasLimit
. On Fluent L2, native ETH for inbound messages is minted by the chain's consensus layer before execution and burned on failure — the bridge balance is sufficient by protocol invariant.
If execution reverts for any other reason — gateway bug, recipient contract revert, ERC-20 callback failure — the message status becomes
Failed
. Anyone can call
receiveFailedMessage
later to retry, which runs the same flow but with full
gasleft()
instead of the capped limit. The message can transition
Failed → Success
exactly once; it cannot go back to
None
.
L2 → L1: the withdrawal lifecycle
A user calls a gateway on L2. The gateway checks the blacklist and forwards
msg.value
(including the bridge fee) to
L2FluentBridge.sendMessage
. The bridge charges an outbound fee derived from the L1 gas oracle:
fee = l1GasLimit * ((l1GasPrice * scalar / 1e18) + overhead)
The fee transfers to the configured
feeTreasury
in a call that happens
after
the message parameters have been snapshotted — so a malicious treasury can't observe or influence pre-snapshot state. The message hash is emitted in
SentMessage
and becomes part of the L2 block's
withdrawalRoot
, which is itself committed into the rollup's batch root at the next
commitBatch
.
Once the originating batch reaches
Preconfirmed
(TEE-signed, Stage C of the
rollup pipeline
) or
Finalized
, a relayer calls
L1FluentBridge.receiveMessageWithProof(batchIndex, blockHeader, ..., withdrawalProof, blockProof)
. The bridge runs two Merkle checks: the block header must be a leaf of the batch's
batchRoot
, and the message hash must be a leaf of the block's
withdrawalRoot
. Any failure reverts with
InvalidBlockProof
or
InvalidWithdrawalProof
.
If the batch is still
Preconfirmed
rather than
Finalized
, the withdrawal enters the
optimistic path
: before releasing funds, the gateway consults the
FastWithdrawalList
rate-cap registry (covered below). If the batch is already
Finalized
, no rate limit applies.
Gateways
A gateway does three things on top of the bridge:
Owns the token side of the transfer.
Locks on the origin chain, releases or mints on the destination — the exact mechanics depend on the asset and whether it uses a pegged or native representation.
Verifies cross-chain origin.
During an in-flight receive,
bridge.getNativeSender()
returns the address that sent the message on the other chain. Gateways require this to match their configured
otherSideGateway
— otherwise the receive reverts with
MessageFromWrongGateway
. The value is cleared at the end of the receive, so it can't be observed outside an in-flight call.
Delegates to the optimistic-withdrawal gate.
Every gateway receive calls
_consumeLimit(tokenKey, amount)
before releasing funds. The gate is a no-op unless the withdrawal is optimistic.
Only the configured local bridge can call a gateway's receive functions (
onlyFluentBridge
). The bridge's
executeGasLimit
caps gas on first delivery; retries via
receiveFailedMessage
run with the caller's full transaction gas.
Two optional safety registries sit alongside the gateways:
Blacklist
is a UUPS-upgradeable denylist with an ERC-7201 storage namespace. Gateways consult it on outbound deposits: if either
msg.sender
or the recipient is blacklisted, the gateway reverts with
AddressBlacklisted
. A separate instance is deployed on each chain;
setBlacklistRegistry(address(0))
disables enforcement per gateway.
FastWithdrawalList
is the rate-cap registry for optimistic withdrawals, described next.
Optimistic withdrawals and FastWithdrawalList
Preconfirmation gives withdrawals fast user-perceived finality — the batch is TEE-signed, the signing key is PCR0-bound via SP1 — but the batch is not yet cryptographically finalized. A later challenge can revert it. Releasing arbitrary amounts during the preconfirmation window is economically dangerous; releasing them after finalization is not.
FastWithdrawalList
is a per-chain, per-token rate-cap registry. Admin registers tokens with packed-
uint96
hourly and daily limits. The gateway, acting as
CONSUMER_ROLE
, calls
consumeUsage(token, amount)
on every optimistic-path withdrawal. Rolling windows are keyed by
block.timestamp / 1 hours
and
block.timestamp / 1 days
— a new window resets the counter for that token.
Tokens can alias into a shared bucket: e.g. ETH and WETH registered under one canonical key, so an attacker cannot drain the cap twice by exploiting both parallel gateways. The alias is set by admin via
setAlias
and is enforced at consume time.
The gate in
GatewayBase._consumeLimit
has four states:
whitelistEnabled
Batch status
Result
false
any
no-op
true
Finalized or no batch context
no-op
true
Preconfirmed, token
not
registered
revert
FastWithdrawalNotAllowed
true
Preconfirmed, token registered
consumeUsage
(rate-limited)
The "which batch is my withdrawal from" signal uses EIP-1153 transient storage:
L1FluentBridge.receiveMessageWithProof
writes the originating
batchIndex
into
_currentBatchIndex
for the duration of the receive, and
isCurrentBatchPreconfirmed()
reads it. Transient semantics mean the context auto-clears at transaction end and cannot leak into a subsequent call — no manual reset, no stale state.
The
_whitelistEnabled
toggle is structurally tied to the registry address:
setWhitelistEnabled(true)
reverts if
_fastWithdrawalList
is unset, and clearing the registry (
setFastWithdrawalList(address(0))
) reverts while the whitelist is enabled. The "enabled but no list" misconfiguration is unreachable.
Safety boundaries
The bridge has several consensus-grade invariants. Breaking any of them is either a protocol error or a path to fund loss.
Frozen per-message deadlines.
validUntilBlockNumber
and
_sentMessageProcessByBlock[slot]
are snapshotted at send time. Admin updates to
receiveMessageDeadline
or
depositProcessingWindow
never retroactively affect in-flight messages.
Deposit liveness signals rollup corruption.
L1FluentBridge.isOldestUnconsumedExpired()
returns true if the head of the queue missed its processing deadline. The rollup's
isRollupCorrupted()
consults this: if the sequencer stops processing deposits, the rollup halts.
Permissionless escape hatch — currently pauser-gated.
skipExpiredDeposits
advances the cursor past expired head slots. It is guarded by
PAUSER_ROLE
in this release and explicitly marked temporary: each skipped slot is a permanently lost deposit until it is replaced by a user-initiated cancel/refund path. The interface comment reads
"TEMPORARY. Each skipped slot represents a permanently lost user deposit until the user-initiated cancel/refund mechanism replaces this function."
⚠️
Warning
L1FluentBridge.rollbackMessageWithProof
is
not implemented in this release
. It currently reverts with
"NOT_IMPLEMENTED"
. The full flow (chainId guard, two Merkle proofs, ETH refund) is preserved in git history and will be restored in a future release together with the user-initiated cancel/refund path that replaces
skipExpiredDeposits
. Integrators should not assume L1 → L2 message rollback is available today.
Gateway whitelist is part of message authority.
Both
sendMessage
destinations and receive targets must be on the bridge's gateway whitelist. Deregistering a gateway stops further sends and rejects inbound messages targeting it; outbound messages already enqueued are unaffected.
Bounded execution.
ExcessivelySafeCall
caps gas and return-data size on every cross-chain call. No griefing via huge return buffers, no unbounded gas drain. Receive functions use
nonReentrant
, and
to == address(this)
is rejected at both send and receive with
ForbiddenSelfCall
/
InvalidDestinationAddress
.
Rollup rebind is queue-safe.
setRollup
reverts with
QueueNotEmpty
if the sent-message queue is non-empty. You cannot point the bridge at a new rollup while deposits are pending — the new rollup would have no knowledge of them.
One-shot message status.
Each message hash has exactly one terminal outcome per direction.
Failed → Success
is allowed (via
receiveFailedMessage
);
Success → anything
is not. Duplicate receive attempts revert with
MessageAlreadyReceived
.
Roles and operational expectations
DEFAULT_ADMIN_ROLE
configures the rollup binding, oracles, gas price config, window parameters, and the gateway whitelist on the bridge.
PAUSER_ROLE
can pause or unpause the bridge and call
skipExpiredDeposits
on L1.
RELAYER_ROLE
is the only role allowed to call
receiveMessage
(L2) and
receiveMessageWithProof
(L1). It is not required on the send path — user sends are permissionless through the gateway.
Gateways
have their own
Ownable2Step
owners for per-gateway config (blacklist, fast list, remote pairing, bridge address).
A few practical notes for operators:
L1BlockOracle
and
L1GasOracle
are liveness dependencies of the L2 bridge. Stale oracles break expiry checks (risk of stranded or prematurely expired messages) and fee calculations. Monitor their freshness.
feeTreasury
must accept plain ETH transfers. The L2 outbound fee transfer uses a bare
call
— if the treasury address reverts on receive,
sendMessage
reverts with
FailedToDeductFee
and the user cannot bridge.
Rotate
RELAYER_ROLE
through the same operational process as the sequencer key. A compromised relayer cannot forge messages (the hash and proofs are public), but it can censor delivery order on L2 by stalling
receiveMessage
.
UUPS upgrades on the bridges, gateways, and safety registries are consensus-grade in the same sense as runtime upgrades (see
Runtime Upgrade
): deterministic artifacts, multisig authority, and coherent rollout.
Mainnet addresses
Most bridge contracts use CREATE2 deterministic deployment — the same salt and bytecode produce the same address on L1 and L2. Implementations behind UUPS proxies are upgrade-target infrastructure and are not listed here.
L1 (Ethereum)
Contract
Address
FluentBridge
0x9CAcf613fC29015893728563f423fD26dCdB8Ddc
Native gateway
0x8976Ca4E0c8467097Da675399fB7DB454a1b56dd
ERC-20 gateway
0xFD4C62647A34FF6d6802092F5fbe176099223B61
Token factory
0xF6d49E874Cb64b8ee56D6F99BD340134B30AB225
Token factory beacon (UUPS)
0xdd283a04cc711ab9c08d79e665835821beef710b
WETH gateway (proxy)
0x1e1f5Df9D48e8E88C037e9255a769e77c9fe587b
FastWithdrawalList (proxy)
0x3eFc3c84ecf259Da36E33692f2a107A0AB88D30E
Blacklist (proxy)
0x05C5d46a5e6f92fB9CdA9A8b03E4440A175D1484
L2 (Fluent, chainId 25363)
Contract
Address
FluentBridge
0x9CAcf613fC29015893728563f423fD26dCdB8Ddc
Native gateway
0x8976Ca4E0c8467097Da675399fB7DB454a1b56dd
ERC-20 gateway
0xFD4C62647A34FF6d6802092F5fbe176099223B61
Token factory
0xF6d49E874Cb64b8ee56D6F99BD340134B30AB225
L1BlockOracle
0x19e1b30C792E417BC1827f5E2F288052b5c05e8F
L1GasOracle
0x207FBb4AC5227Ab598B8072BdC1E150dF687AC5B
WETH gateway (proxy)
0x1e1f5Df9D48e8E88C037e9255a769e77c9fe587b
The L2 FluentBridge address coincides with
PRECOMPILE_ROLLUP_BRIDGE
(see
Precompiles
) — the bridge is genesis-deployed on Fluent via
PRECOMPILE_ROLLUP_BRIDGE_DEPLOYER
using the same CREATE2 salt as the L1 deployment.
Pegged tokens minted by the ERC-20 gateway on Fluent L2 use the
Universal Token runtime
(
PRECOMPILE_UNIVERSAL_TOKEN_RUNTIME = 0x0000000000000000000000000000000000520008
) as their implementation — each pegged token is an ownable account pointing at that runtime.
Operator EOAs
Role
Address
Relayer (
RELAYER_ROLE
)
0x4A0e88275dC08a15Bad0d12e7805574Ca0853A48
L1BlockOracle submitter
0xf1af41d33CfFdc8d08107713c0c2DF5De7f2Bd5c
L1GasOracle submitter
0x1Bee0BD77E76aD9692F6A3b4388DdE371b69fdD7
Layered model
L1 → L2: the deposit lifecycle
L2 → L1: the withdrawal lifecycle
Gateways
Optimistic withdrawals and FastWithdrawalList
Safety boundaries
Roles and operational expectations
Mainnet addresses
L1 (Ethereum)
L2 (Fluent, chainId 25363)
Operator EOAs
## /gblend
On this page
gblend Overview
gblend
is a specialized Foundry forge wrapper designed for hybrid Solidity and WebAssembly (WASM) smart contract development on Fluent Network. It seamlessly integrates Rust-based WASM contracts with traditional Solidity development workflows.
🎨
Key Features
Rust to WASM Compilation
- Compile Rust smart contracts to WebAssembly
Hybrid Development
- Seamlessly work with both Solidity and WASM contracts
Reproducible Builds
- Docker-based compilation ensures consistent WASM builds
Full Verification Support
- Verify both Solidity and WASM contracts on-chain
Foundry Compatible
- Maintains full compatibility with existing Foundry projects
The CLI usage is nearly identical to standard Forge, with a few Fluent-specific extensions. For example, to verify WASM contracts, you must pass the
--wasm
flag.
💡
Prefer working with Hardhat?
Although
gblend
is forked from Foundry's forge and works really well within the Foundry dev environment, it's also possible to use Hardhat if that's your preferred dev environment.
Please refer to the
Foundry documentation on integrating Hardhat and Foundry
and use the same strategy when using Fluent's
gblend
.
Additional Resources
Foundry Book
gblend Repository
Example Projects
Next up
Installation
: Installation instructions for
gblend
.
Using
gblend
: Learn the basic commands to start building with
gblend
.
Troubleshooting
: Find the most common issues and best practices.
Developer guides
: Find out further how to use
gblend
by following along with the developer guides.
gblend Overview
Additional Resources
Next up
## /gblend/installation
On this page
gblend
Installation
🧱
Required dependencies
Docker
- Required for reproducible WASM builds
# macOS
brew
install
--cask
docker
# Linux
sudo
apt-get
install
docker.io
# Verify installation
docker
--version
Installation
Quick Install (Recommended)
# Install gblendup installer
curl
-sSL
https://raw.githubusercontent.com/fluentlabs-xyz/gblend/refs/tags/latest/gblendup/install
|
bash
# Restart terminal or source your shell configuration
source
~/.bashrc
# or ~/.zshrc
# Install gblend
gblendup
# Verify installation
gblend
--version
⚠️
Important Migration Note
If you have an older version of gblend installed via Cargo, you must uninstall it first:
# Remove old Cargo-installed version
cargo
uninstall gblend
The new version is distributed via a shell installer script, not through Cargo.
Updating gblend
To update gblend to the latest version:
# Simply run gblendup again
gblendup
gblend
Installation
Installation
Quick Install (Recommended)
Updating gblend
## /gblend/usage
On this page
Using
gblend
gblend
is a specialized Foundry forge wrapper designed for hybrid Solidity and WebAssembly (WASM) smart contract development on Fluent Network. It seamlessly integrates Rust-based WASM contracts with traditional Solidity development workflows.
The CLI usage is nearly identical to standard Forge, with a few Fluent-specific extensions. For example, to verify WASM contracts, you must pass the
--wasm
flag.
💡
Differences from Standard Forge
WASM Support
: Native support for WASM contract compilation and deployment
Enhanced Verification
:
--wasm
flag for verifying WASM contracts
Custom REVM
: Support for the fluentbase REVM implementation.
Getting Started
1. Create a New Project
# Create a hybrid Solidity + WASM project
gblend init my-project
# Navigate to project
cd
my-project
When creating a new project without using any
custom template
, the CLI tool will scaffold the
counter + powercalculator
example. This is an extension to the default Forge counter example when using
forge init
, adding blended execution.
2. Project Structure
As in Foundry projects, the default source for Foundry to fetch your contracts is the
src
folder (unless otherwise specified in
foundry.toml
). Organise your contracts like so:
my-project/
├── src/
│ ├── BlendedCounter.sol # Solidity contract
│ └── power-calculator/ # Rust/WASM module
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs
├── test/ # Forge tests
├── script/ # Deployment scripts
└── foundry.toml # Configuration
🏆
Best Practice: Bigger projects
When you're working on bigger projects with a large set of contracts, it is recommended to add more structure to your code base by using folders and nested structures to group related contracts. When building your contracts (refer to below in step 3),
gblend
will recursively look for contract source code within the
src
directory.
3. Build Contracts
Build all contracts (Solidity + Rust WASM)
⚠️
Warning
Note: the first build might take a few minutes and should take a few seconds after the first run.
gblend build
Note
: First build may take longer as Docker downloads the container image.
The build command will create build artifacts in the
/out
directory or otherwise specified in
foundry.toml
.
These build artificats can be neatly removed from the project by running the clean command:
# Clean build artifacts
gblend clean
4. Run Tests
# Run all tests
gblend
test
# Run specific test with gas reporting
gblend
test
--match-test testIncrementByPowerOfTwo --gas-report
Configuration
foundry.toml
gblend
uses the same configuration foundations as Foundry forge. Create (it should already be there if you used
gblend
or regular
forge
to create your project) or update a
foundry.toml
file in your project root:
[
profile.default
]
src
=
"src"
out
=
"out"
libs
=
[
"lib"
]
optimizer
=
true
optimizer_runs
=
200
[
rpc_endpoints
]
fluent_testnet
=
"https://rpc.testnet.fluent.xyz"
Rust Configuration (Cargo.toml)
Every Fluentbase WASM contract will be its own package and have a
Cargo.toml
like so:
[
package
]
name
=
"power-calculator"
version
=
"0.1.0"
edition
=
"2021"
[
lib
]
crate-type
=
[
"cdylib"
]
[
dependencies
]
fluentbase-sdk
=
{
git
=
"https://github.com/fluentlabs-xyz/fluentbase"
,
tag
=
"v0.4.0-dev"
}
Working with WASM Contracts
When building Fluentbase contracts in Rust by using the
Fluentbase SDK
, the contracts will be compiled to WASM executables.
🔍
Naming Convention
WASM contract artifacts follow a specific naming pattern:
Package name
: Convert from
snake-case
to
PascalCase
Extension
: Add
.wasm
suffix
Example:
power-calculator
→
PowerCalculator.wasm
Building WASM Contracts
When you run
gblend build
, the tool:
Compiles Rust contracts inside a Docker container
Generates Solidity interfaces in
out/PowerCalculator.wasm/interface.sol
Creates deployment artifacts in
out/PowerCalculator.wasm/foundry.json
Using WASM in Solidity
Fluentbase SDK is designed to make it easy for developers to develop blended applications that have seamless cross-VM composability.
Developers can call Fluentbase WASM contracts from Solidity:
// Import the generated interface
import
"../out/PowerCalculator.wasm/interface.sol프로젝트로 돌아가기