@@ -182,9 +182,22 @@ type Signer interface {
182182// modernSigner is the signer implementation that handles non-legacy transaction types.
183183// For legacy transactions, it defers to one of the legacy signers (frontier, homestead, eip155).
184184type modernSigner struct {
185- txTypeBitVec txTypeBitVec
186- chainID * big.Int
187- legacy Signer
185+ txtypes txtypeSet
186+ chainID * big.Int
187+ legacy Signer
188+ }
189+
190+ type txtypeSet [2 ]uint64
191+
192+ func (v * txtypeSet ) set (txType byte ) {
193+ v [txType / 64 ] |= 1 << (txType % 64 )
194+ }
195+
196+ func (v * txtypeSet ) has (txType byte ) bool {
197+ if txType >= byte (len (v )* 64 ) {
198+ return false
199+ }
200+ return v [txType / 64 ]& (1 << (txType % 64 )) != 0
188201}
189202
190203func newModernSigner (chainID * big.Int , fork forks.Fork ) Signer {
@@ -203,19 +216,19 @@ func newModernSigner(chainID *big.Int, fork forks.Fork) Signer {
203216 default :
204217 s .legacy = FrontierSigner {}
205218 }
206- s .txTypeBitVec . Set (LegacyTxType )
219+ s .txtypes . set (LegacyTxType )
207220 // configure tx types
208221 if fork >= forks .Berlin {
209- s .txTypeBitVec . Set (AccessListTxType )
222+ s .txtypes . set (AccessListTxType )
210223 }
211224 if fork >= forks .London {
212- s .txTypeBitVec . Set (DynamicFeeTxType )
225+ s .txtypes . set (DynamicFeeTxType )
213226 }
214227 if fork >= forks .Cancun {
215- s .txTypeBitVec . Set (BlobTxType )
228+ s .txtypes . set (BlobTxType )
216229 }
217230 if fork >= forks .Prague {
218- s .txTypeBitVec . Set (SetCodeTxType )
231+ s .txtypes . set (SetCodeTxType )
219232 }
220233 return s
221234}
@@ -226,15 +239,15 @@ func (s *modernSigner) ChainID() *big.Int {
226239
227240func (s * modernSigner ) Equal (s2 Signer ) bool {
228241 other , ok := s2 .(* modernSigner )
229- return ok && s .chainID .Cmp (other .chainID ) == 0 && s .txTypeBitVec . Equals ( & other .txTypeBitVec ) && s .legacy .Equal (other .legacy )
242+ return ok && s .chainID .Cmp (other .chainID ) == 0 && s .txtypes == other .txtypes && s .legacy .Equal (other .legacy )
230243}
231244
232245func (s * modernSigner ) Hash (tx * Transaction ) common.Hash {
233246 return tx .inner .sigHash (s .chainID )
234247}
235248
236249func (s * modernSigner ) supportsType (txtype byte ) bool {
237- return s .txTypeBitVec . Has (txtype )
250+ return s .txtypes . has (txtype )
238251}
239252
240253func (s * modernSigner ) Sender (tx * Transaction ) (common.Address , error ) {
0 commit comments