From 9d6fc4d7faf96b6f4b8b37a42b4a7b067dd3e1fd Mon Sep 17 00:00:00 2001 From: Ahmed Mohamed Date: Fri, 15 May 2026 11:06:17 +1000 Subject: [PATCH] Widen authorization-list nonce to NUMERIC(20,0). --- main.go | 2 +- services/execdb/postgresql/upgrader.go | 29 ++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index a76a787..afff306 100644 --- a/main.go +++ b/main.go @@ -55,7 +55,7 @@ import ( ) // ReleaseVersion is the release version for the code. -var ReleaseVersion = "0.6.0" +var ReleaseVersion = "0.6.1" func main() { os.Exit(main2()) diff --git a/services/execdb/postgresql/upgrader.go b/services/execdb/postgresql/upgrader.go index 909138f..2780df5 100644 --- a/services/execdb/postgresql/upgrader.go +++ b/services/execdb/postgresql/upgrader.go @@ -25,7 +25,7 @@ type schemaMetadata struct { Version uint64 `json:"version"` } -var currentVersion = uint64(11) +var currentVersion = uint64(12) type upgrade struct { funcs []func(context.Context, *Service) error @@ -85,6 +85,11 @@ var upgrades = map[uint64]*upgrade{ addTransactionAuthorizationLists, }, }, + 12: { + funcs: []func(context.Context, *Service) error{ + widenAuthorizationListNonce, + }, + }, } // Upgrade upgrades the database. @@ -346,7 +351,7 @@ CREATE TABLE t_transaction_authorization_lists ( ,f_index INTEGER NOT NULL ,f_chain_id BYTEA NOT NULL ,f_address BYTEA NOT NULL - ,f_nonce BIGINT NOT NULL + ,f_nonce NUMERIC(20,0) NOT NULL ,f_r BYTEA NOT NULL ,f_s BYTEA NOT NULL ,f_y_parity BOOLEAN NOT NULL @@ -948,3 +953,23 @@ CREATE INDEX i_transaction_authorization_lists_3 ON t_transaction_authorization_ return nil } + +// widenAuthorizationListNonce widens t_transaction_authorization_lists.f_nonce from BIGINT to +// NUMERIC(20,0) so it can hold the full uint64 range. EIP-7702 authorization entries with an +// invalid nonce of 2^64-1 appear on chain (the spec rejects them but they still land in blocks), +// and the signed-int64 column overflowed on encode. +func widenAuthorizationListNonce(ctx context.Context, s *Service) error { + tx := s.tx(ctx) + if tx == nil { + return ErrNoTransaction + } + + if _, err := tx.Exec(ctx, ` +ALTER TABLE t_transaction_authorization_lists +ALTER COLUMN f_nonce TYPE NUMERIC(20,0) +`); err != nil { + return errors.Wrap(err, "failed to widen f_nonce in t_transaction_authorization_lists") + } + + return nil +}