DSS 2026 — Removing the Staking Oracle: Beacon Chain Proofs in Production Clément Moller Source video: https://www.youtube.com/watch?v=KfmX8eSCC3M Automatic captions — not human-reviewed. Complete spoken-audio coverage is unverified. Source language tag: en (English). Source export SHA256: c7a0fe0e3863c7b0c2da6adde68a94a0fa88f3cb1513213bc792cca1f99e1675 [0:04] Okay. [0:05] Hi everyone. Uh thanks a lot for [0:07] attending to this talk. I'm Clement [0:09] Molera. [0:10] I'm um smart contract developer at Ored [0:13] at Origin Protocol for more than two [0:15] years now and I would like to present [0:17] you today the work that we did at Origin [0:19] Protocol. Uh this work has been led by [0:22] Nick Edison Nick Edison [0:24] who is a smart contract engineer [0:26] too. [0:27] Uh so what I would like to show you [0:28] today is how we remove the staking [0:30] oracle on our liquid staking token using [0:33] the beacon chain proofs in production. [0:36] Okay. So [0:43] that's how much is that our liquid [0:45] staking token OIS has in its staking [0:48] validator strategy. [0:52] Think of the last time [0:54] No. [0:55] Before this this is very great because [0:57] for this no one reported this value to [1:00] the contract no one nobody. [1:02] So think of the last time you audited [1:03] the liquid staking token [1:05] uh who say to who say to you there is [1:08] that much ether in this validator. Most [1:11] of the time this is a an external oracle [1:14] that pull the value from from the beacon [1:16] chain [1:17] using off-chain script and pull it [1:19] directly into the [1:22] into the sorry into the oracle. [1:25] Uh why does it matter? It matters [1:27] because it drives the rebase. If you [1:28] make this value too too high then you [1:31] are meeting unbacked liquid stake token [1:33] and then you are wrecked. And the [1:35] subject of this talk is trying to not be [1:37] wrecked. [1:39] Uh before that before that at Origin we [1:41] was using a trust layer so it was really [1:44] easy. It's an off-chain script that [1:46] assumed that every validator held 32 ETH [1:50] and run the accounting and by running [1:51] the accounting every time there is more [1:53] we counting as um [1:56] as reward and every time there is less [1:57] we counting as a slashed event or an [2:00] exit. [2:01] But anyone can prove the [2:04] can prove the value that we have in our [2:06] validator. [2:08] It's pretty easy. It's the sum of three [2:12] three different things. There is first [2:14] the pending deposit which correspond to [2:16] the deposit queue on the beacon chain. [2:18] Then there is the validator on the [2:20] beacon chain too. And then there is the [2:23] if that are in the contractor itself. [2:27] Sorry. So keep this equation in mind. We [2:29] will try to break it during this talk. [2:34] So for those who don't know that much [2:35] how the consensus layer and the beacon [2:37] chain works, here is a quick primer. [2:39] So since the since the merge, Ethereum [2:41] is now two different machine. There is [2:44] on one side on the left side the the [2:46] execution layer that runs the EVM. [2:48] That's most of the time what you use. [2:52] That's this is where you have your [2:53] transaction, your smart contract, your [2:55] balance. That's where you are doing [2:57] DeFi. 90% of the time this is the [2:58] section of Ethereum that you are doing. [3:01] On the other way, you have the beacon [3:02] chain and the consensus layer. This is [3:04] where the proof of stake run. [3:06] On this section, you have the deposit [3:09] queue and the validator's balance. [3:12] There is one issue with this is that Can [3:14] I point? No. [3:16] One issue with this is that the EVM [3:17] cannot talk directly to the beacon [3:19] chain. So if the EVM want to ask, okay, [3:22] beacon chain, tell me how many there is [3:24] in this [3:25] validator that I own, [3:27] this is not possible. [3:29] So how can we do it something like this? [3:31] So thanks to Dan Kuan and the EIP 4788, [3:35] every block on the EVM puts the previous [3:37] beacon root state into a system contract [3:40] on the EVM. I I say it again. Every [3:43] block on the EVM put the previous beacon [3:46] block root into a system contract on the [3:48] EVM. And that's the only way the EVM [3:50] know something about the beacon chain. [3:53] So what is this contract? This contract [3:55] is what we called root 0x000F3 and adds [3:58] with beacon so it's easy to remember. [4:00] You can cast this and you will receive [4:02] 97 97 bytes and that's the whole [4:06] contract. [4:07] You can take the timestamp of this one [4:10] and call it with a you uncode it and you [4:13] use it as an argument when you call this [4:15] and you will receive something that's [4:16] called the beacon proof. [4:19] And that's all mostly. [4:21] If you you have to make it at the exact [4:23] block, if you make it one second later [4:25] or one second before, then it will [4:26] revert. So the rule is pretty simple. If [4:28] there is no block, there is no root. [4:32] What is this contract? This contract is [4:33] a ring buffer of 8,191 [4:36] entries which represent around 27 hours [4:38] of of history. Keep this value in mind. [4:41] We will use it at the end of the talk. [4:44] So what is this beacon doc root? This [4:47] beacon block root basically represents [4:49] the whole beacon state [4:51] the beacon [4:52] chain basically. [4:54] It is one giant merkle tree and there is [4:56] one specificity in this merkle tree is [4:58] that all the position are in a fixed [5:01] position. You cannot mess with it. It's [5:02] at a fixed position. [5:04] So [5:05] you have first the beacon block root, [5:07] then you go a bit down, there is the [5:08] state balances and if you go a bit down [5:10] again, you see the leaves and on the [5:13] leaves you have the validators balance. [5:14] Obviously it's [5:16] it's make it easy. [5:17] So if you are a caller, it's pretty [5:19] simple if you want to recompute it, you [5:21] start from here, then you you hash it [5:23] with its siblings and you do it all the [5:25] way up and that's how you end up with [5:27] the beacon block root. [5:28] On the other hand, if you are a smart [5:29] contract and you want to [5:31] decode it, you can take the beacon block [5:33] root and all the data [5:35] and you can go all the way down using [5:37] your installed node storage to take the [5:39] indexes at where you have to switch from [5:42] one branch to another. [5:44] And that's all basically. So if you are [5:46] the caller, you choose the data where [5:48] you can put any data you want, we don't [5:50] care. The only thing that care is the [5:52] position. The position is not [5:53] negotiable. [5:56] So so yeah, that's it mostly. That's the [5:58] merkle proof. It's one check in one loop [6:01] in around 60 line of solidity code and [6:04] that's it. If that was it, uh it would [6:06] have been a 5-minute talk. Uh that's [6:08] not, so here is the rest. [6:12] Here is the rest. So [6:14] every time we do a snapshot, we do a [6:17] verify, we do something like this on our [6:18] contract. [6:20] This is permissionless. Anyone in this [6:21] room can do it. Anyone can call this [6:23] kind of function. And this is great [6:25] because you can do it with any data you [6:26] like. There is no check. [6:28] Basically no check on the data. You can [6:30] put it any any data you like at any [6:32] time. [6:33] So for the next uh something 9 minutes, [6:36] you guys will be the the attacker. You [6:38] will try Your job today is to make this [6:41] value wrong. [6:42] If you manage to make this wrong, if you [6:44] make it too high, then you are be you [6:46] are able to mint uh unbacked liquid [6:48] stake token and then uh we are wrecked. [6:50] If you make it too low, then some user [6:52] will not receive the yield they deserve [6:54] and they are wrecked too. So I will try [6:57] to show you three ways you can try to [6:59] make this value wrong to wreck everyone [7:01] and uh what stop this. [7:05] Okay, so the first one is is the is the [7:06] simplest one. You can hide the [7:08] validator. So for the remaining of the [7:10] talk, let's assume that you have uh a [7:12] set of validator. [7:14] Okay, uh you have one of the validator [7:16] that just gets slashed. That's sad. [7:19] You have a naive contract that keeps uh [7:21] the last proven balance for every [7:23] validator that you have. [7:24] So you make something simple uh to [7:27] to update this value, you have to prove [7:29] the balance. So you you take all the [7:32] validator except the one that that gets [7:34] slashed. You compute the proof. You [7:36] submit everything. The hash checks out. [7:38] The balance are correct and the proof [7:40] are correct. So that's pretty simple. [7:42] But because you don't account for the [7:43] one that gets slashed, uh it's still [7:46] counted, so you overestimate how much [7:48] does your validator has. And so [7:49] congrats, you are wrecked for the first [7:51] time today. [7:53] How to fix this? [7:54] Um so every time we have to prove [7:56] something, we have to match against the [8:00] validator. So we don't loop against all [8:02] the [8:04] How can I say it? You don't have to loop [8:05] against all the [8:07] the the pool that you receive on your on [8:09] your argument, but you have to loop [8:11] against a list of that you have in your [8:13] own storage. And that's how you avoid [8:15] this kind of issue. So [8:17] the the end of this attack if if you [8:19] have to prove something, prove the whole [8:21] set, not just one element of the set, [8:23] prove the whole set, prove all the [8:24] validator at the same time. [8:26] Okay, so therefore the second attack say [8:29] you can count a deposit twice. [8:31] How does it work? So when you do [8:33] deposit, your ECE is on the depo on the [8:35] deposit queue and have to move to the to [8:37] the validator, pretty simple. Uh but [8:39] there is an issue on the Merkel proof is [8:42] that you cannot some cannot say that [8:43] something is happened from this Merkel [8:45] proof. [8:46] So how do you do it? How do you say [8:48] okay, it's not on the deposit queue [8:49] anymore? [8:50] So you assume that the deposit the the [8:53] beacon chain will go the older slot [8:56] first. And in our situation, so we [8:59] deposited at the slot 100 and the head [9:02] of the queue is now 120, okay, pretty [9:04] simple. Uh so that's mean that our [9:06] deposit should have me should have been [9:08] processed. So it lands now in the [9:12] into the validator, right? It should [9:14] should work like this, right? No? [9:16] Okay, if you have to remember one attack [9:17] from this talk, this one is the good [9:19] one. [9:20] It doesn't work because the the spec of [9:22] the beacon chain itself breaks this [9:24] order. [9:25] So a deposit into a validator that goes [9:28] back uh goes that goes back to the [9:30] queue, it's keep its whole slot. It is [9:33] keeping its whole slot. So let's take [9:36] this situation. We have our own deposit [9:39] that has been deposited at slot 100. So [9:42] it's on the past, it's already created [9:44] to the validator, everyone is happy. [9:46] Then an attacker try to attack us. How [9:48] he do it? He simply deposit into a [9:51] validator that he that he control and [9:53] then he exit it. The exit goes to the to [9:55] the back of the queue and the queue goes [9:57] up up up up up until it reach the head [9:59] of the queue. [10:00] And now what's the situation? [10:03] So the head of the queue is now 90, but [10:06] our deposit is 100. So there is an issue [10:08] because we count our deposit into the [10:12] into the validator on one side, but on [10:14] the other hand now we are counting it as [10:16] pending for the second time and so you [10:19] count your ETH two time. So you are [10:21] wrecked for the second time today. [10:24] How do you fix this? [10:26] You have two way to fix this and we are [10:29] using both. So you can prove the [10:31] balance. You have to prove our validator [10:33] withdrawable epoch into a simple [10:35] question, is it exiting? If this is [10:37] never exiting, then the order holds, [10:40] everything is all right. Is it exiting? [10:42] Then we wait until the head was added at [10:44] or after that epoch. [10:45] First solution. The second one is we [10:48] stop guessing. We don't don't we make no [10:50] guess anymore. [10:53] An inclusion proof for every deposit [10:54] that we still count as pending and like [10:56] this we should avoid double counting. [11:00] So if you must infer absence, name the [11:02] spec rule you depend on. [11:05] Which brings us to time and the third [11:07] attack. [11:08] So when you do a snapshot, you basically [11:09] take a photo of the state and you put it [11:11] into a transaction. So on this one there [11:13] is the ETH that are sitting on the [11:14] contract at the block on the execution [11:16] layer and the beacon node that represent [11:20] that that takes the at the beacon slot [11:23] just before on the consensus layer. Like [11:25] this you should have all the three [11:26] possibility where the ETH could be. [11:28] Could be either on your contract, on [11:30] your deposit [11:31] queue or on the validator. [11:35] But [11:37] there can be an issue. So when [11:40] when you verify a deposit, you don't use [11:42] this snapshot because you can use any [11:45] beacon block that you want at any slot [11:47] that you like. [11:49] So here the see the following situation. [11:52] You take a you take a slot that is after [11:54] the the photo that we take. [11:56] During the meantime the ETH get credited [11:58] from the pending deposit to the [12:00] validator. [12:01] And after this [12:04] after this sorry [12:07] Yeah when when you like to to to verify [12:10] it, then there is an issue because your [12:13] ETH is not counted nowhere. It's not [12:15] counting on the on the pending deposit, [12:17] but it's not counting on it's not [12:19] counted on the validator. So your ETH is [12:21] a bit counted nowhere. And so you are [12:24] underestimating how much do you have, [12:26] and so you are wrecked for the third [12:27] time today. [12:30] Um yep, so deposit can only be marked as [12:32] proceed at or before the snapshot slot. [12:37] And we will end with this. So we have [12:39] 24/7 hours to lend the proof. You [12:41] remember the 24 27 hours from the [12:44] beginning. So because then the number [12:46] ages. There is no fresh freshness check [12:49] on this. So if we are a bit late and we [12:51] are missing rewards, okay, that's fine. [12:53] We will cut them later. [12:55] But if we are a bit late and we are not [12:57] reporting a slashed validator, then our [12:59] someone that is integrating us can uh [13:03] cannot be really accurate. [13:05] So if you have [13:06] to report a value and you have to pin [13:08] every proof to one instant, but you have [13:10] to say how old is this value. You have [13:13] to publish how old is this value. [13:16] Okay, so now we uh dodge the third [13:18] bullet. I will drop you so some numbers. [13:21] So we are still live with [13:23] 13,000 for almost 14k of ETH. So not [13:28] wrecked today. [13:29] Uh we are still using certain [13:31] compounding validators. We are still [13:34] reproving it every 12 hours and we [13:36] computing it at 24 [13:38] 252 time at the moment and zero [13:41] slashing. So let's continue to pray. [13:45] Uh but don't get me wrong. We didn't [13:47] remove the trust at all. We moved it [13:49] somewhere. We moved it to the consensus [13:51] back, which is now our oracle. So we [13:53] have to be sure that we really [13:54] understand how the oracle the the [13:56] consensus back works. We moved it to [13:59] whoever keeps submitting the proof [14:00] because if [14:01] no one submit the proof, then it's not [14:03] accurate anymore. And we are moving it [14:05] to the registrator who first decide [14:09] where we stake the ETH and uh [14:11] then do the first deposit of one ETH [14:13] until we can prove it's really how [14:15] validator. [14:17] So if you have to remember one thing [14:18] from this talk for your next audit that [14:21] on an LST that use the beacon chain [14:24] you can use those three values. [14:26] So ask you three question. [14:28] What force the set to be complete for [14:29] the first attack? Which which absence is [14:32] inferred and from what rule for the [14:33] second attack? And the last one, if you [14:36] prove at one instant, how stale is this [14:38] instant? [clears throat] [14:40] So Merkle proof tells you a lot of [14:42] things. [14:42] It tells you what's in the tree, but it [14:44] doesn't tell you what's missing, doesn't [14:47] tell you what's gone and not when. [14:49] This job is still our job and this job [14:51] is still your job, guys. So thanks a lot [14:53] for your attention. And if you have some [14:55] questions, I would be happy to discuss a [14:57] bit later on. Thanks a lot, guys.