diff --git a/go.work.sum b/go.work.sum index 7fb84abf..7006bf01 100644 --- a/go.work.sum +++ b/go.work.sum @@ -44,6 +44,7 @@ cloud.google.com/go/dataform v0.9.1/go.mod h1:pWTg+zGQ7i16pyn0bS1ruqIE91SdL2FDMv cloud.google.com/go/datafusion v1.7.4/go.mod h1:BBs78WTOLYkT4GVZIXQCZT3GFpkpDN4aBY4NDX/jVlM= cloud.google.com/go/datalabeling v0.8.4/go.mod h1:Z1z3E6LHtffBGrNUkKwbwbDxTiXEApLzIgmymj8A3S8= cloud.google.com/go/dataplex v1.14.0/go.mod h1:mHJYQQ2VEJHsyoC0OdNyy988DvEbPhqFs5OOLffLX0c= +cloud.google.com/go/dataproc v1.12.0/go.mod h1:zrF3aX0uV3ikkMz6z4uBbIKyhRITnxvr4i3IjKsKrw4= cloud.google.com/go/dataproc/v2 v2.3.0/go.mod h1:G5R6GBc9r36SXv/RtZIVfB8SipI+xVn0bX5SxUzVYbY= cloud.google.com/go/dataqna v0.8.4/go.mod h1:mySRKjKg5Lz784P6sCov3p1QD+RZQONRMRjzGNcFd0c= cloud.google.com/go/datastore v1.15.0/go.mod h1:GAeStMBIt9bPS7jMJA85kgkpsMkvseWWXiaHya9Jes8= @@ -66,6 +67,7 @@ cloud.google.com/go/gkebackup v1.3.4/go.mod h1:gLVlbM8h/nHIs09ns1qx3q3eaXcGSELgN cloud.google.com/go/gkeconnect v0.8.4/go.mod h1:84hZz4UMlDCKl8ifVW8layK4WHlMAFeq8vbzjU0yJkw= cloud.google.com/go/gkehub v0.14.4/go.mod h1:Xispfu2MqnnFt8rV/2/3o73SK1snL8s9dYJ9G2oQMfc= cloud.google.com/go/gkemulticloud v1.1.0/go.mod h1:7NpJBN94U6DY1xHIbsDqB2+TFZUfjLUKLjUX8NGLor0= +cloud.google.com/go/grafeas v0.3.0/go.mod h1:P7hgN24EyONOTMyeJH6DxG4zD7fwiYa5Q6GUgyFSOU8= cloud.google.com/go/gsuiteaddons v1.6.4/go.mod h1:rxtstw7Fx22uLOXBpsvb9DUbC+fiXs7rF4U29KHM/pE= cloud.google.com/go/iam v1.1.5/go.mod h1:rB6P/Ic3mykPbFio+vo7403drjlgvoWfYpJhMXEbzv8= cloud.google.com/go/iap v1.9.3/go.mod h1:DTdutSZBqkkOm2HEOTBzhZxh2mwwxshfD/h3yofAiCw= @@ -167,7 +169,10 @@ github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8V github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0= +github.com/apache/arrow/go/v12 v12.0.1/go.mod h1:weuTY7JvTG/HDPtMQxEUp7pU73vkLWMLpY67QwZ/WWw= +github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.3.9/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= @@ -348,10 +353,12 @@ github.com/golangci/misspell v0.3.5/go.mod h1:dEbvlSfYbMQDtrpRMQU675gSDLDNa8sCPP github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6/go.mod h1:0AKcRCkMoKvUvlf89F6O7H2LYdhr1zBh736mBItOdRs= github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg8RkN3rCIMLGE9CyYmU9pY2Jer6DgANEnZ/L/cQ= github.com/google/flatbuffers v1.11.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-pkcs11 v0.2.1-0.20230907215043-c6f79328ddf9/go.mod h1:6eQoGcuNJpa7jnd5pMGdkSaQpNDYvPlXWMcjXXThLlY= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -380,6 +387,7 @@ github.com/gostaticanalysis/nilerr v0.1.1/go.mod h1:wZYb6YI5YAxxq0i1+VJbY0s2YONW github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= @@ -423,6 +431,7 @@ github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpT github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOcDo= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/ianlancetaylor/demangle v0.0.0-20220517205856-0058ec4f073c/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/iden3/go-iden3-crypto v0.0.12/go.mod h1:swXIv0HFbJKobbQBtsB50G7IHr6PbTowutSew/iBEoo= @@ -462,11 +471,13 @@ github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.6.2/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw= +github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= @@ -481,9 +492,11 @@ github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4F github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/ldez/gomoddirectives v0.2.3/go.mod h1:cpgBogWITnCfRq2qGoDkKMEVSaarhdBr6g8G04uz6d0= github.com/ldez/tagliatelle v0.3.1/go.mod h1:8s6WJQwEYHbKZDsp/LjArytKOG8qaMrKQQ3mFukHs88= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leonklingele/grouper v1.1.0/go.mod h1:uk3I3uDfi9B6PeUjsCKi6ndcf63Uy7snXgR4yDYQVDY= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lufeee/execinquery v1.2.1/go.mod h1:EC7DrEKView09ocscGHC+apXMIaorh4xqSxS/dy8SbM= +github.com/lyft/protoc-gen-star/v2 v2.0.3/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -520,6 +533,8 @@ github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3N github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= +github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= +github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= @@ -574,6 +589,7 @@ github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d/go.mod h1:3OzsM7 github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo= @@ -681,6 +697,7 @@ github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqri github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA= github.com/ultraware/whitespace v0.0.5/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA= github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/uudashr/gocognit v1.0.6/go.mod h1:nAIUuVBnYU7pcninia3BHOvQkpQCeO76Uscky5BOwcY= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= @@ -693,6 +710,7 @@ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsr github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk= github.com/yeya24/promlinter v0.2.0/go.mod h1:u54lkmBOZrpEbQQ6gox2zWKKLKu2SGe+2KOiextY+IA= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= gitlab.com/bosi/decorder v0.2.3/go.mod h1:9K1RB5+VPNQYtXtTDAzd2OEftsZb1oV0IrJrzChSdGE= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= @@ -711,6 +729,7 @@ go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znn go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= @@ -779,6 +798,7 @@ golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2 golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/tx-submitter/services/rollup.go b/tx-submitter/services/rollup.go index ee47752c..4c64f24f 100644 --- a/tx-submitter/services/rollup.go +++ b/tx-submitter/services/rollup.go @@ -82,6 +82,8 @@ type Rollup struct { bm *l1checker.BlockMonitor eventInfoStorage *event.EventInfoStorage reorgDetector iface.IReorgDetector + + ChainConfigMap types.ChainBlobConfigs } func NewRollup( @@ -126,6 +128,7 @@ func NewRollup( bm: bm, eventInfoStorage: eventInfoStorage, reorgDetector: reorgDetector, + ChainConfigMap: types.ChainConfigMap, } return r } @@ -298,7 +301,7 @@ func (r *Rollup) ProcessTx() error { // Helper function to detect reorgs with retry func (r *Rollup) detectReorgWithRetry() (bool, uint64, error) { var lastErr error - for i := range 3 { // Try up to 3 times + for i := 0; i < 3; i++ { // Try up to 3 times hasReorg, depth, err := r.reorgDetector.DetectReorg(r.ctx) if err == nil { return hasReorg, depth, nil @@ -1240,7 +1243,6 @@ func (r *Rollup) buildSignatureInput(batch *eth.RPCRollupBatch) (*bindings.IRoll } func (r *Rollup) GetGasTipAndCap() (*big.Int, *big.Int, *big.Int, error) { - head, err := r.L1Client.HeaderByNumber(context.Background(), nil) if err != nil { return nil, nil, nil, err @@ -1279,7 +1281,13 @@ func (r *Rollup) GetGasTipAndCap() (*big.Int, *big.Int, *big.Int, error) { // calc blob fee cap var blobFee *big.Int if head.ExcessBlobGas != nil { - blobFee = eip4844.CalcBlobFee(*head.ExcessBlobGas, params.BlobTxBlobGaspriceUpdateFraction) + log.Info("market blob fee info", "excess blob gas", *head.ExcessBlobGas) + blobConfig, exist := r.ChainConfigMap[r.chainId.Uint64()] + if !exist { + blobConfig = types.DefaultBlobConfig + } + blobFeeDenominator := types.GetBlobFeeDenominator(blobConfig, head.Time) + blobFee = eip4844.CalcBlobFee(*head.ExcessBlobGas, blobFeeDenominator.Uint64()) // Set to 3x to handle blob market congestion blobFee = new(big.Int).Mul(blobFee, big.NewInt(3)) } diff --git a/tx-submitter/types/blob_config.go b/tx-submitter/types/blob_config.go new file mode 100644 index 00000000..70dc371a --- /dev/null +++ b/tx-submitter/types/blob_config.go @@ -0,0 +1,156 @@ +package types + +import ( + "math/big" + + "github.com/morph-l2/go-ethereum/log" +) + +// BlobFeeConfig is used to configure blob fee calculation parameters. +type BlobFeeConfig struct { + ChainID *big.Int + + // LondonBlock is the London block number (used for time determination). + LondonBlock *big.Int + + // Timestamps for each EIP upgrade (Unix timestamp, seconds). + CancunTime *uint64 // EIP-4844 (Cancun) + PragueTime *uint64 // Prague + OsakaTime *uint64 // Osaka + BPO1Time *uint64 // BPO1 + BPO2Time *uint64 // BPO2 + BPO3Time *uint64 // BPO3 + BPO4Time *uint64 // BPO4 + BPO5Time *uint64 // BPO5 + + // BlobConfig corresponding to each EIP. + Cancun *BlobConfig + Prague *BlobConfig + Osaka *BlobConfig + BPO1 *BlobConfig + BPO2 *BlobConfig + BPO3 *BlobConfig + BPO4 *BlobConfig + BPO5 *BlobConfig + + Default *BlobConfig +} + +// BlobConfig contains the parameters required for blob fee calculation. +type BlobConfig struct { + // UpdateFraction is the denominator in the fakeExponential function. + UpdateFraction uint64 +} + +// Time determination methods (referencing go-ethereum logic). +// IsCancun returns whether time is either equal to the Cancun fork time or greater. +func (c *BlobFeeConfig) IsCancun(num *big.Int, time uint64) bool { + return c.IsLondon(num) && isTimestampForked(c.CancunTime, time) +} + +// IsPrague returns whether time is either equal to the Prague fork time or greater. +func (c *BlobFeeConfig) IsPrague(num *big.Int, time uint64) bool { + return c.IsLondon(num) && isTimestampForked(c.PragueTime, time) +} + +// IsOsaka returns whether time is either equal to the Osaka fork time or greater. +func (c *BlobFeeConfig) IsOsaka(num *big.Int, time uint64) bool { + return c.IsLondon(num) && isTimestampForked(c.OsakaTime, time) +} + +// IsBPO1 returns whether time is either equal to the BPO1 fork time or greater. +func (c *BlobFeeConfig) IsBPO1(num *big.Int, time uint64) bool { + return c.IsLondon(num) && isTimestampForked(c.BPO1Time, time) +} + +// IsBPO2 returns whether time is either equal to the BPO2 fork time or greater. +func (c *BlobFeeConfig) IsBPO2(num *big.Int, time uint64) bool { + return c.IsLondon(num) && isTimestampForked(c.BPO2Time, time) +} + +// IsBPO3 returns whether time is either equal to the BPO3 fork time or greater. +func (c *BlobFeeConfig) IsBPO3(num *big.Int, time uint64) bool { + return c.IsLondon(num) && isTimestampForked(c.BPO3Time, time) +} + +// IsBPO4 returns whether time is either equal to the BPO4 fork time or greater. +func (c *BlobFeeConfig) IsBPO4(num *big.Int, time uint64) bool { + return c.IsLondon(num) && isTimestampForked(c.BPO4Time, time) +} + +// IsBPO5 returns whether time is either equal to the BPO5 fork time or greater. +func (c *BlobFeeConfig) IsBPO5(num *big.Int, time uint64) bool { + return c.IsLondon(num) && isTimestampForked(c.BPO5Time, time) +} + +// IsLondon returns whether num is either equal to the London fork block or greater. +func (c *BlobFeeConfig) IsLondon(num *big.Int) bool { + return isBlockForked(c.LondonBlock, num) +} + +// GetBlobFeeDenominator returns the corresponding UpdateFraction based on the time. +func GetBlobFeeDenominator(blobFeeConfig *BlobFeeConfig, blockTime uint64) *big.Int { + if blobFeeConfig == nil { + // If not configured, use default value. + log.Warn("BlobFeeConfig not set, using default denominator", + "default", DefaultOsakaBlobConfig) + return new(big.Int).SetUint64(DefaultOsakaBlobConfig.UpdateFraction) + } + + cfg := blobFeeConfig + londonBlock := cfg.LondonBlock // London block number for fork determination. + + // Check in priority order from high to low (BPO5 -> BPO4 -> ... -> Cancun). + var blobConfig *BlobConfig + + // Check BPO5 + if cfg.BPO5Time != nil && cfg.IsBPO5(londonBlock, blockTime) && cfg.BPO5 != nil { + blobConfig = cfg.BPO5 + } else if cfg.BPO4Time != nil && cfg.IsBPO4(londonBlock, blockTime) && cfg.BPO4 != nil { + blobConfig = cfg.BPO4 + } else if cfg.BPO3Time != nil && cfg.IsBPO3(londonBlock, blockTime) && cfg.BPO3 != nil { + blobConfig = cfg.BPO3 + } else if cfg.BPO2Time != nil && cfg.IsBPO2(londonBlock, blockTime) && cfg.BPO2 != nil { + blobConfig = cfg.BPO2 + } else if cfg.BPO1Time != nil && cfg.IsBPO1(londonBlock, blockTime) && cfg.BPO1 != nil { + blobConfig = cfg.BPO1 + } else if cfg.OsakaTime != nil && cfg.IsOsaka(londonBlock, blockTime) && cfg.Osaka != nil { + blobConfig = cfg.Osaka + } else if cfg.PragueTime != nil && cfg.IsPrague(londonBlock, blockTime) && cfg.Prague != nil { + blobConfig = cfg.Prague + } else if cfg.CancunTime != nil && cfg.IsCancun(londonBlock, blockTime) && cfg.Cancun != nil { + blobConfig = cfg.Cancun + } else if cfg.Default != nil { + blobConfig = cfg.Default + } + + if blobConfig == nil { + log.Warn("No blob config found for current time, using default", + "blockTime", blockTime, + "londonBlock", londonBlock, + "default", DefaultOsakaBlobConfig) + return new(big.Int).SetUint64(DefaultOsakaBlobConfig.UpdateFraction) + } + + return new(big.Int).SetUint64(blobConfig.UpdateFraction) +} + +// isBlockForked returns whether a fork scheduled at block s is active at the +// given head block. Whilst this method is the same as isTimestampForked, they +// are explicitly separate for clearer reading. +func isBlockForked(s, head *big.Int) bool { + if s == nil || head == nil { + return false + } + return s.Cmp(head) <= 0 +} + +// isTimestampForked returns whether a fork scheduled at timestamp s is active +// at the given head timestamp. Whilst this method is the same as isBlockForked, +// they are explicitly separate for clearer reading. +func isTimestampForked(s *uint64, head uint64) bool { + if s == nil { + return false + } + return *s <= head +} diff --git a/tx-submitter/types/blob_config_test.go b/tx-submitter/types/blob_config_test.go new file mode 100644 index 00000000..a1a5f3df --- /dev/null +++ b/tx-submitter/types/blob_config_test.go @@ -0,0 +1,258 @@ +package types + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGetBlobFeeDenominator_MainnetChainConfig(t *testing.T) { + // Use MainnetChainConfig directly since map lookup with *big.Int keys requires exact pointer match + config := MainnetChainConfig + assert.NotNil(t, config, "MainnetChainConfig should exist") + + tests := []struct { + name string + blockTime uint64 + expectedResult uint64 + forkName string + }{ + { + name: "Before Cancun", + blockTime: 1710338134, // Before Cancun (1710338135) + expectedResult: DefaultOsakaBlobConfig.UpdateFraction, // Should use Default + forkName: "Default", + }, + { + name: "At Cancun", + blockTime: 1710338135, // Cancun fork time + expectedResult: DefaultCancunBlobConfig.UpdateFraction, + forkName: "Cancun", + }, + { + name: "After Cancun, Before Prague", + blockTime: 1740000000, // Between Cancun and Prague + expectedResult: DefaultCancunBlobConfig.UpdateFraction, + forkName: "Cancun", + }, + { + name: "At Prague", + blockTime: 1746612311, // Prague fork time + expectedResult: DefaultPragueBlobConfig.UpdateFraction, + forkName: "Prague", + }, + { + name: "After Prague", + blockTime: 1746612312, // After Prague + expectedResult: DefaultPragueBlobConfig.UpdateFraction, + forkName: "Prague", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := GetBlobFeeDenominator(config, tt.blockTime) + assert.NotNil(t, result) + assert.Equal(t, tt.expectedResult, result.Uint64(), "Expected %s fork UpdateFraction", tt.forkName) + }) + } +} + +func TestGetBlobFeeDenominator_HoodiChainConfig(t *testing.T) { + // Use HoodiChainConfig directly since map lookup with *big.Int keys requires exact pointer match + config := HoodiChainConfig + assert.NotNil(t, config, "HoodiChainConfig should exist") + + tests := []struct { + name string + blockTime uint64 + expectedResult uint64 + forkName string + }{ + { + name: "At Cancun (0)", + blockTime: 0, // Cancun fork time is 0 + expectedResult: DefaultCancunBlobConfig.UpdateFraction, + forkName: "Cancun", + }, + { + name: "Before Prague", + blockTime: 1742999831, // Before Prague (1742999832) + expectedResult: DefaultCancunBlobConfig.UpdateFraction, + forkName: "Cancun", + }, + { + name: "At Prague", + blockTime: 1742999832, // Prague fork time + expectedResult: DefaultPragueBlobConfig.UpdateFraction, + forkName: "Prague", + }, + { + name: "Before Osaka", + blockTime: 1761677591, // Before Osaka (1761677592) + expectedResult: DefaultPragueBlobConfig.UpdateFraction, + forkName: "Prague", + }, + { + name: "At Osaka", + blockTime: 1761677592, // Osaka fork time + expectedResult: DefaultOsakaBlobConfig.UpdateFraction, + forkName: "Osaka", + }, + { + name: "Before BPO1", + blockTime: 1762365719, // Before BPO1 (1762365720) + expectedResult: DefaultOsakaBlobConfig.UpdateFraction, + forkName: "Osaka", + }, + { + name: "At BPO1", + blockTime: 1762365720, // BPO1 fork time + expectedResult: DefaultBPO1BlobConfig.UpdateFraction, + forkName: "BPO1", + }, + { + name: "Before BPO2", + blockTime: 1762955543, // Before BPO2 (1762955544) + expectedResult: DefaultBPO1BlobConfig.UpdateFraction, + forkName: "BPO1", + }, + { + name: "At BPO2", + blockTime: 1762955544, // BPO2 fork time + expectedResult: DefaultBPO2BlobConfig.UpdateFraction, + forkName: "BPO2", + }, + { + name: "After BPO2", + blockTime: 1762955545, // After BPO2 + expectedResult: DefaultBPO2BlobConfig.UpdateFraction, + forkName: "BPO2", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := GetBlobFeeDenominator(config, tt.blockTime) + assert.NotNil(t, result) + assert.Equal(t, tt.expectedResult, result.Uint64(), "Expected %s fork UpdateFraction", tt.forkName) + }) + } +} + +func TestGetBlobFeeDenominator_NilConfig(t *testing.T) { + t.Run("Nil config uses default", func(t *testing.T) { + result := GetBlobFeeDenominator(nil, 1000000000) + assert.NotNil(t, result) + assert.Equal(t, DefaultOsakaBlobConfig.UpdateFraction, result.Uint64()) + }) +} + +func TestGetBlobFeeDenominator_AllChainConfigs(t *testing.T) { + // Test that all chain configs in ChainConfigMap work correctly + for chainID, config := range ChainConfigMap { + t.Run("ChainID_"+strconv.FormatUint(chainID, 10), func(t *testing.T) { + assert.NotNil(t, config, "Config should not be nil for chainID %s", chainID) + assert.NotNil(t, config.LondonBlock, "LondonBlock should not be nil for chainID %s", chainID) + + // Test with a very large timestamp to ensure it works + result := GetBlobFeeDenominator(config, 9999999999) + assert.NotNil(t, result) + assert.Greater(t, result.Uint64(), uint64(0), "UpdateFraction should be greater than 0") + }) + } +} + +func TestGetBlobFeeDenominator_ChainConfigMap(t *testing.T) { + // Test GetBlobFeeDenominator using ChainConfigMap + t.Run("Mainnet from ChainConfigMap", func(t *testing.T) { + // Find Mainnet config by ChainID + var mainnetConfig *BlobFeeConfig + for chainID, config := range ChainConfigMap { + if chainID == 1 { + mainnetConfig = config + break + } + } + assert.NotNil(t, mainnetConfig, "Mainnet config should be found in ChainConfigMap") + + // Test various timestamps + result := GetBlobFeeDenominator(mainnetConfig, 1710338135) // At Cancun + assert.Equal(t, DefaultCancunBlobConfig.UpdateFraction, result.Uint64()) + + result = GetBlobFeeDenominator(mainnetConfig, 1746612311) // At Prague + assert.Equal(t, DefaultPragueBlobConfig.UpdateFraction, result.Uint64()) + }) + + t.Run("Hoodi from ChainConfigMap", func(t *testing.T) { + // Find Hoodi config by ChainID + var hoodiConfig *BlobFeeConfig + for chainID, config := range ChainConfigMap { + if chainID == 560048 { + hoodiConfig = config + break + } + } + assert.NotNil(t, hoodiConfig, "Hoodi config should be found in ChainConfigMap") + + // Test various timestamps + result := GetBlobFeeDenominator(hoodiConfig, 0) // At Cancun (0) + assert.Equal(t, DefaultCancunBlobConfig.UpdateFraction, result.Uint64()) + + result = GetBlobFeeDenominator(hoodiConfig, 1761677592) // At Osaka + assert.Equal(t, DefaultOsakaBlobConfig.UpdateFraction, result.Uint64()) + + result = GetBlobFeeDenominator(hoodiConfig, 1762365720) // At BPO1 + assert.Equal(t, DefaultBPO1BlobConfig.UpdateFraction, result.Uint64()) + + result = GetBlobFeeDenominator(hoodiConfig, 1762955544) // At BPO2 + assert.Equal(t, DefaultBPO2BlobConfig.UpdateFraction, result.Uint64()) + }) + + t.Run("Devnet from ChainConfigMap", func(t *testing.T) { + // Find Devnet config by ChainID + var devnetConfig *BlobFeeConfig + for chainID, config := range ChainConfigMap { + if chainID == 900 { + devnetConfig = config + break + } + } + assert.NotNil(t, devnetConfig, "Devnet config should be found in ChainConfigMap") + + // Test various timestamps + result := GetBlobFeeDenominator(devnetConfig, 0) // At Cancun (0) + assert.Equal(t, DefaultCancunBlobConfig.UpdateFraction, result.Uint64()) + + result = GetBlobFeeDenominator(devnetConfig, 1761677592) // At Osaka + assert.Equal(t, DefaultOsakaBlobConfig.UpdateFraction, result.Uint64()) + + result = GetBlobFeeDenominator(devnetConfig, 1762365720) // At BPO1 + assert.Equal(t, DefaultBPO1BlobConfig.UpdateFraction, result.Uint64()) + + result = GetBlobFeeDenominator(devnetConfig, 1762955544) // At BPO2 + assert.Equal(t, DefaultBPO2BlobConfig.UpdateFraction, result.Uint64()) + }) +} + +func TestGetBlobFeeDenominator_ForkPriority(t *testing.T) { + // Test that higher priority forks are checked first + config := HoodiChainConfig + assert.NotNil(t, config) + + // At BPO2 time, should return BPO2, not BPO1, Osaka, Prague, or Cancun + bpo2Time := uint64(1762955544) + result := GetBlobFeeDenominator(config, bpo2Time) + assert.Equal(t, DefaultBPO2BlobConfig.UpdateFraction, result.Uint64()) + + // At BPO1 time, should return BPO1, not Osaka, Prague, or Cancun + bpo1Time := uint64(1762365720) + result = GetBlobFeeDenominator(config, bpo1Time) + assert.Equal(t, DefaultBPO1BlobConfig.UpdateFraction, result.Uint64()) + + // At Osaka time, should return Osaka, not Prague or Cancun + osakaTime := uint64(1761677592) + result = GetBlobFeeDenominator(config, osakaTime) + assert.Equal(t, DefaultOsakaBlobConfig.UpdateFraction, result.Uint64()) +} diff --git a/tx-submitter/types/blob_params.go b/tx-submitter/types/blob_params.go new file mode 100644 index 00000000..0e51f9a3 --- /dev/null +++ b/tx-submitter/types/blob_params.go @@ -0,0 +1,97 @@ +package types + +import ( + "math/big" +) + +var ( + DefaultBlobConfig = HoodiChainConfig + + ChainConfigMap = ChainBlobConfigs{ + 1: MainnetChainConfig, + 560048: HoodiChainConfig, + 900: DevnetChainConfig, + } +) + +func newUint64(val uint64) *uint64 { return &val } + +type ChainBlobConfigs map[uint64]*BlobFeeConfig + +var ( + // MainnetChainConfig is the chain parameters to run a node on the main network. + MainnetChainConfig = &BlobFeeConfig{ + ChainID: big.NewInt(1), + LondonBlock: big.NewInt(12_965_000), + CancunTime: newUint64(1710338135), + PragueTime: newUint64(1746612311), + Cancun: DefaultCancunBlobConfig, + Prague: DefaultPragueBlobConfig, + Default: DefaultOsakaBlobConfig, + } + + // HoodiChainConfig contains the chain parameters to run a node on the Hoodi test network. + HoodiChainConfig = &BlobFeeConfig{ + ChainID: big.NewInt(560048), + LondonBlock: big.NewInt(0), + CancunTime: newUint64(0), + PragueTime: newUint64(1742999832), + OsakaTime: newUint64(1761677592), + BPO1Time: newUint64(1762365720), + BPO2Time: newUint64(1762955544), + Cancun: DefaultCancunBlobConfig, + Prague: DefaultPragueBlobConfig, + Osaka: DefaultOsakaBlobConfig, + BPO1: DefaultBPO1BlobConfig, + BPO2: DefaultBPO2BlobConfig, + Default: DefaultOsakaBlobConfig, + } + + // DevnetChainConfig contains the chain parameters to run a node on the devnet test network. + DevnetChainConfig = &BlobFeeConfig{ + ChainID: big.NewInt(900), + LondonBlock: big.NewInt(0), + CancunTime: newUint64(0), + PragueTime: newUint64(1742999832), + OsakaTime: newUint64(1761677592), + BPO1Time: newUint64(1762365720), + BPO2Time: newUint64(1762955544), + Cancun: DefaultCancunBlobConfig, + Prague: DefaultPragueBlobConfig, + Osaka: DefaultOsakaBlobConfig, + BPO1: DefaultBPO1BlobConfig, + BPO2: DefaultBPO2BlobConfig, + Default: DefaultOsakaBlobConfig, + } +) + +var ( + // DefaultCancunBlobConfig is the default blob configuration for the Cancun fork. + DefaultCancunBlobConfig = &BlobConfig{ + UpdateFraction: 3338477, + } + // DefaultPragueBlobConfig is the default blob configuration for the Prague fork. + DefaultPragueBlobConfig = &BlobConfig{ + UpdateFraction: 5007716, + } + // DefaultOsakaBlobConfig is the default blob configuration for the Osaka fork. + DefaultOsakaBlobConfig = &BlobConfig{ + UpdateFraction: 5007716, + } + // DefaultBPO1BlobConfig is the default blob configuration for the BPO1 fork. + DefaultBPO1BlobConfig = &BlobConfig{ + UpdateFraction: 8346193, + } + // DefaultBPO2BlobConfig is the default blob configuration for the BPO2 fork. + DefaultBPO2BlobConfig = &BlobConfig{ + UpdateFraction: 11684671, + } + // DefaultBPO3BlobConfig is the default blob configuration for the BPO3 fork. + DefaultBPO3BlobConfig = &BlobConfig{ + UpdateFraction: 20609697, + } + // DefaultBPO4BlobConfig is the default blob configuration for the BPO4 fork. + DefaultBPO4BlobConfig = &BlobConfig{ + UpdateFraction: 13739630, + } +)