all: expose DeriveAuthorities publicly, use in other Message call sites

This commit is contained in:
lightclient 2025-10-29 20:20:48 -06:00
parent cc65a4ad32
commit 350978a0a6
No known key found for this signature in database
GPG key ID: 657913021EF45A6A
4 changed files with 9 additions and 7 deletions

View file

@ -523,7 +523,7 @@ func (tx *Transaction) SetCodeAuthorities() []*common.Address {
if cache := tx.auths.Load(); cache != nil { if cache := tx.auths.Load(); cache != nil {
return *cache return *cache
} }
cache := setcodetx.deriveAuthorities() cache := (authCache)(DeriveAuthorities(setcodetx.AuthList))
tx.auths.Store(&cache) tx.auths.Store(&cache)
return cache return cache
} }

View file

@ -66,14 +66,16 @@ type SetCodeTx struct {
S *uint256.Int S *uint256.Int
} }
// authCache is an internal helper type used in the Transaction object to cache
// authorizations.
type authCache []*common.Address type authCache []*common.Address
// deriveAuthorities returns a list of recovered authorization signers. The // DeriveAuthorities returns a list of recovered authorization signers. The
// length is always equal to the number of authorizations. Any authorities that // length is always equal to the number of authorizations. Any authorities that
// fail to recover are set as nil in the list. // fail to recover are set as nil in the list.
func (tx *SetCodeTx) deriveAuthorities() authCache { func DeriveAuthorities(authList []SetCodeAuthorization) []*common.Address {
auths := make([]*common.Address, 0, len(tx.AuthList)) auths := make([]*common.Address, 0, len(authList))
for _, auth := range tx.AuthList { for _, auth := range authList {
if addr, err := auth.Authority(); err == nil { if addr, err := auth.Authority(); err == nil {
auths = append(auths, &addr) auths = append(auths, &addr)
} else { } else {

View file

@ -490,7 +490,7 @@ func (args *TransactionArgs) ToMessage(baseFee *big.Int, skipNonceCheck bool) *c
BlobGasFeeCap: (*big.Int)(args.BlobFeeCap), BlobGasFeeCap: (*big.Int)(args.BlobFeeCap),
BlobHashes: args.BlobHashes, BlobHashes: args.BlobHashes,
SetCodeAuthorizations: args.AuthorizationList, SetCodeAuthorizations: args.AuthorizationList,
AuthorityCache: types.ToAuthorityCache(args.AuthorizationList), Authorities: types.DeriveAuthorities(args.AuthorizationList),
SkipNonceChecks: skipNonceCheck, SkipNonceChecks: skipNonceCheck,
SkipTransactionChecks: true, SkipTransactionChecks: true,
} }

View file

@ -477,7 +477,7 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (*core.Mess
BlobHashes: tx.BlobVersionedHashes, BlobHashes: tx.BlobVersionedHashes,
BlobGasFeeCap: tx.BlobGasFeeCap, BlobGasFeeCap: tx.BlobGasFeeCap,
SetCodeAuthorizations: authList, SetCodeAuthorizations: authList,
AuthorityCache: types.ToAuthorityCache(authList), Authorities: types.DeriveAuthorities(authList),
} }
return msg, nil return msg, nil
} }