Nested settlement
Settle a call that runs through several Gas Killer contracts in one transaction.
When a tracked function calls another Gas Killer contract, the whole call chain
can settle under one signature. If A calls B and B calls C, each contract
applies its own signed state changes instead of B and C running their code
on-chain.
When to use it
Without nesting, a call into another contract is replayed by running it, so you pay that contract's full cost on-chain. Nesting removes that cost when the callee is itself expensive and is a Gas Killer contract.
Avoid nesting into a contract with heavy direct traffic. The signature covers every contract in the chain at its current state, so a transaction that changes any one of them before you settle invalidates the whole payload.
Opting in
Inherit GasKillerNestedSDK instead of GasKillerSDK in every contract in the
chain. It adds about 4 KB of bytecode, so contracts that never nest should stay
on GasKillerSDK.
import {GasKillerNestedSDK} from "gas-killer-sdk/GasKillerNestedSDK.sol";
import {DepositVault} from "./DepositVault.sol"; // also a GasKillerNestedSDK contract
contract DepositGateway is GasKillerNestedSDK {
DepositVault public immutable vault;
constructor(address avs, address schnorrRegistry, uint256 receiptRounds) {
_setAvsAddress(avs);
_setSchnorrRegistry(schnorrRegistry);
vault = new DepositVault(avs, schnorrRegistry, receiptRounds);
}
function deposit(address account) external payable trackState {
vault.deposit{value: msg.value}(account);
}
}Every contract in the chain must:
- Inherit
GasKillerNestedSDK. A call into any other contract runs natively, as it would without nesting. - Be wired to the same registry, the one published on
GET /avs-metadata. - Mark the called function
trackStateand make no storage write or external call before it in that function.
Confirm a deployment can take part:
cast call "$TARGET" "supportsInterface(bytes4)(bool)" 0x78481874 --rpc-url "$RPC_URL"What changes for you
Nothing in the API. Submit, poll and settle as usual, and send the payload
as-is. Its data calls verifyAndUpdateTree rather than verifyAndUpdate.
ETH forwarded along the chain works as it does natively, and every hop is bound by the signature. See Value-bearing transitions.
Examples
nested-deposit: a gateway that forwards ETH to a vault.nested-chain: three contracts deep.nested-cycle: a chain that calls back into its first contract.
If a nested settlement reverts, see Nested settlement reverts.
