Talk: Incentive-compatible Fees on L2

Secureum Talks · 19:49

Kelvin from Optimism explains why charging users fairly on a layer 2 is still an unsolved design problem. Layer 2 transaction cost is dominated by calldata posted to layer 1, so its price moves independently of execution. The talk compares converting layer 1 cost into layer 2 gas with charging users directly, and recalls an earlier approach that encoded limits in gas price bits. It then suggests reusing the max fee per blob field proposed for EIP-4844, and calls for layer 2 teams to coordinate.

Topics

From Secureum Talks; community: Secureum.

Transcript

[Music] um okay so hi i'm kelvin i work at optimism and i'm gonna be talking a little bit about how to handle fees on layer two and this is uh an interesting problem because it's sort of one of the last remaining annoying problems on layer two that has

at the moment no perfect solution right so i think almost every single problem on layer 2 is kind of a solved one this one has a reasonable solution but none of them are great and so i want to talk to you about that and then i want to talk to you about the next steps so where i want to go with this all right so aka why the heck rfe is so hard to deal with on layer two so uh the big question is no um how should fees be charged on layer two and this sounds like you know it sounds like a pretty straightforward question i don't mean like you know how do you decide what the gas price is gonna be

nothing like that just literally how do you charge the user fees and the goals if you're going to design a layer 2 the goals of a system like this should be number one it should feel like ethereum because because we like ethereum because people are used to the ethereum developer experience and because changing ethereum creates headaches so if i've learned a single lesson from designing layer twos it's that if you anytime you slightly modify the evm you're going to break someone's workflow it's like that that xkcd you know where someone's relying on like the fan overheating to do something any small behavior of the evm is

something that somebody somewhere relies on and so when you make changes three months down the line somebody's going to complain and they're going to say you broke my my server because uh you know some rpc doesn't work perfectly like it does on ethereum so these are the goals it should feel like ethereum but of course it should also be incentive compatible i should actually be able to charge people accurately for the resources that they are using on layer two otherwise people can just get away with using resources that they're not actually paying for so these are these are important goals but you have these sort of big issues

and and essentially the problem is that layer two is not the same as layer one as much as it's similar it's not exactly the same and importantly the cost of call data is quite different right on layer on layer one you have this relationship between the cost of call data and the cost of execution and this relationship remains mostly fixed most of the time right we have currently per non-zero byte of gol of call data you pay 16 gas this is a fixed number it just stays there and over time we've reduced this slightly to reflect changes in in sort of requirements and hardware

but generally this relationship for periods of months or years stays the same and so um on layer two this this changes immediately right because you can if you think on layer two the majority of the cost for a transaction actually comes from your call data this is not the case for many transactions on layer one so the immediate relationship between gas and call data is broken but not only is it is it broken it's broken in this way where you can't just take call data and suddenly charge you know 2 000 gas per byte because actually the cost of call data is constantly fluctuating with the

price of gas on layer one because we have to post these transactions to layer one so you have this problem where call data is now this dynamic value that fluctuates independently from execution on layer two and so we can't just port over the way that the evm handles gas on there too right so this is sort of the if you want to naively fix this problem you just change the cost of the call data op code or zero not opcode sorry you change the cost uh per byte of call data right but like i just said um you the the issue with this is that the the cost is not like a sort of constant sized increase

over the current cost of quality it's this constantly fluctuating value right when there's an nft drop on there one all of a sudden it costs 10 times more to post your transactions to your layer two transactions to layer one so we have some models for fixing this problem and i think there's sort of um the main ideas is quite simple you want to charge dynamically for the data that your transaction uses right that's that's the goal we want to achieve and as l2s we've kind of settled on two ways to handle this problem the first way is that you can take the cost of a transaction in terms

of layer one gas and you translate this into a certain amount of layer two gas right so if it costs me you know cost me 100 ether this is a totally arbitrary value never going to cost you this much but if it costs you 100 ether to publish a transaction on layer one and you know it's gonna it's gonna cost you that much money then on layer two what you can say is okay i'm going to look at the current layer 2 gas price and i'm going to charge the user a certain amount of layer 2 gas such that the amount of gas used times the current layer 2 gas price gives you 100 ether right and you can kind of imagine why this works it's pretty

straightforward you get this dynamic charge but you can also sort of start to imagine the the difficulties that this creates all of a sudden the same transaction when executed at different times is actually going to cost different amounts of gas and this creates developer experience problems right so some people will rely on hard-coded gas limits and if you use this methodology then hard-coded gas limits won't always work and so you either need to start pushing everybody to use gas estimation and most people already do that so it's not a huge problem but then there are certain people who simply can't do this and you can kind of get away with it by setting a very high gas limit um that you know it's so high that it's

sort of never going to you're never going to run into this issue but you create this weird discrepancy between the way that layer 1 and layer 2 works and it creates any time you have a discrepancy like that it creates mental overhead for developers so you really don't want this sort of discrepancy the other option which is it also has its own issues is to sort of directly charge for gas on layer two you don't or sorry directly charged for the cost of publishing your transaction from the user's account on layer two um so you can imagine or the way that this would work is just if if you compute that it's gonna cost you a hundred east to to publish a transaction to layer one then you simply just deduct 100 each

from the user's account on layer 2. but this also has its own sort of major problem which is that with the current transaction formats there's no way to limit how big that charge is going to be and so you can do things like sort of do the smoothing on what the layer one gas price is but ultimately if if sort of the estimated layer one cost goes up very very very high the user is just going to get charged whatever that number is when their transaction gets executed right so you suddenly have this problem in practice it's not it's not a massive issue but in theory it is a security problem that we need to address so these things none of these things are ideal you know you're trading off somewhere in

the you know in developer experience in security in in it's just not none of these solutions are fantastic you can also do this deranged thing that we did at optimism a long time ago which was a terrible idea and we moved away from it but was a lot of fun where we wanted to reflect the layer one gas limit somehow we wanted to let people pick a maximum for what they were going to get charged on there on there too for this layer one gas so something like this direct charge and so we said what's somewhere in the transaction where we can encode this information and so we realize that the gas price is a very big number right usually you have a gas price

that's somewhat like it's like you know three grey whatever and it turns out there's a lot of lower bits in there and so you can just start encoding information into the lower bits of the gas price and say well the upper bits of the gas price are going to be the layer one gas price and the lower bits of the gas price are going to be the layer two gas price and now all of a sudden you need to go to wallets and you need to get them to this crazy gas gas pricing thing and um it was a lot of fun it was a terrible idea uh and we sort of realized that you want you want simplicity at the end of the day you do something deranged like this every wallet is gonna hate you and they're gonna want you to change it so

we changed it but it was fun or we just get ethereum to fix it for us so a few days ago there was a workshop the sort of layer 1 layer 2 ef workshop and we talked about this problem and um it was brought up that that there might actually be a really convenient fix uh pretty soon and the better answer is that we are there's this if you haven't heard of it i mean you're at a layer two sort of event ish kind of um the eip4844 is this fantastic eip to introduce this idea of sort of data

blobs on there one so they're sort of just this area for you to publish large amounts of transaction data to layer one very cheaply and it has the same problem you have these blobs that are now sort of separate from standard ethereum transaction gas and you need to figure out how are you going to charge for these blobs to very different resource and it has the exact same problem and so it's looking like we're going to need to introduce a new transaction type for 4844 and that it will probably have this convenient field called max fee per blob which it's going to use you know a similar mechanism where you get your your account gets charged directly for

the cost of your blob transaction data and this is the same thing that we just described in roll-up land except now it's with blobs and users need to be able to supply a maximum fee per blob so you can imagine a universe where you co-opt this and you you come up with like a standardized rule and you say something like if a user submits a blob transaction but there is no blob data then we're going to treat it as a special layer 2 transaction you don't do this on layer 1. you only do this on layer 2.

you can say we're going to treat this as a special transaction type on layer 2 where instead of max fee per blob being applied to the amount of eth that you're going to get charged for your blob data because there are there is no blob data you take max fee per blob and you use it as the limit for the amount that you're going to get charged for layer 2 data so we sort of started to solve this problem with a convenient uh a convenient parallel to layer one very exciting i guess the question now perfect the question now is um how do we actually get to this nirvana realistically we need we need

collaboration between layer two teams this is an interesting um challenge because wallets wallets don't love to do things for just one project because then you have a code base that you are maintaining slightly different behavior for every single chain and this is really you start to get a whole bunch of if statements and switches and it's not ideal so id you know you want joint action on this um on this front and you don't want to create 10 different solutions so you really do need you need collaboration between layer 2 teams and the reality is that that if you want assist a way to create incentive compatible fees so so sort of safe from the roll-up side and

secure fees so say from the user side without sort of breaking the developer experience there's there's like only really one or two ways of doing this we might as well all the roll-up teams are going to have the same problem this applies whether you're an optimistic roll-up or where you're whether you're a zk roll-up you have the exact same issue with with resource pricing you need to solve this and having a sort of standardized transaction format that we kind of hack on layer two for our own reasons um seems like an ideal path forward as long as we can all agree on it and it's also a really great opportunity for everyone to work together i mean we kind of get to collaborate and can build a process around how we can um

we can work together to do these sort of standards because standards make make everyone's lives easier and it means that you can reuse a bunch of code and it's a clear win right no one everyone i talked to on the layer 2 side has struggled with this problem fees making fees that are incentive compatible and safe for users on layer two is is hard and doing it in a way that doesn't break developer experience is almost impossible so coming up with a standardized way of handling this seems like a really really easy win so i'm excited about this this has kind of been this talk has evolved uh before i got here it was a lot more uh depressing and then the

layer two or the the ef workshop came about and sort of revealed a lot of um a lot of parallel between layer one and layer two in this in this regard so i think we will also get to see more more of these cases where um layer one and layer two sort of have the same problems and we can end up working together to solve them but again if it's ten different layer two teams doing ten different things it's kind of like you know it limits your ability to actually work together and standardize things so yeah that's uh that's the end of my talk this is a very fascinating subject and one that i've been sort of struggling with for the last maybe a year and a half we've overhauled this

three or four times by now so fees on layer two really annoying subject any any questions for kelvin hey ed from arbitrum um we're totally on board for uh working with with our l2 friends on on standards around l1 and l2 pricing and wallet integrations and so on as you know but i wanted to ask about trust and trustlessness in in the fee setting process what is your thinking about

who or what should be trusted in determining what fees are charged to a particular transaction should it be entirely trustless code is there a role for trust in the sequencer or other components what do you think the requirements or goals are as far as that goes good question um i mean ideally it should be as stressless as possible you should be able to get all of your your well okay there's a the i think the easy short-term solution is you could make it very trustless right you can just say you pull uh you pull like l1 base v information automatically from the l1 chain you can

do this very quickly you could essentially you can construct this so that you're getting l1 base v information from every single block on layer one so that gives you like it gives you good uh insight into what fees are looking like on layer one i think there's a little bit of room you know realistically you want if you're just updating fees on layer one immediately you get this weird thing where you know fees on layer one spike and um but you you know you can work around that i know arbitrary does like fee smoothing so that you can you smooth out those layer one basically the blair one base fee um i don't see a huge need at least at least not now for having the sequencer come in and say

i'm going to charge you an additional fee i feel like at least in the short term it should be good enough i don't do you have any specific use cases where you would say the sequencer should be able to come in and let's say charge an additional fee because they see you know they know something about how pricing on layer one is going to be in the near term future um our approach is that we want to trust the sequencer only for sequencing sure and that the sequencer um does not have a way to get a higher fee or reimbursement returns to itself by by manipulation yeah right um that i think that's that's absolutely

the correct target no matter what yeah and for one more question we have a question from twitter if no one else has one here um the question is from carolina would it be possible for optimistic rollups to connect to the bitcoin blockchain too could they improve the current lightning network or maybe even replace it um yes so so sort of the interesting thing with the way that optimistic rollups are going is that if you're building your architecture well um you kind of just like it you know it's it's uh who's john

adler likes to say like wait it's all data availability like um as as long as the data is available somewhere and your sort of validation thing has acts i mean that's the reality of it if your data is available somewhere you can use it and then within that it's just about trust assumptions right if sure we can totally just transfer optimism in the future to use it to you know to point to an arbitrary number of shards on layer one it doesn't even just have to be on one shard chain it can be on ten different shard chains at the same time um and you can sort of just prove that all this data is available and so you have all the input information to the the l2 state so yeah you can i mean you can post this

data absolutely anywhere [Music]

Related talks