From bc6896db7211ba45a9ec60dffc6a7867932ac976 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Tue, 10 Jan 2023 19:15:17 +0100 Subject: [PATCH 1/4] rename BatchPosterVerifier to AddressVerifier --- arbnode/node.go | 4 +- arbnode/seq_coordinator.go | 2 +- broadcastclient/broadcastclient.go | 2 +- broadcastclient/broadcastclient_test.go | 4 +- broadcastclients/broadcastclients.go | 2 +- das/aggregator.go | 6 +-- das/sign_after_store_das.go | 6 +-- util/contracts/batch_poster_verifier.go | 50 ++++++++++++------------- util/signature/sign_verify.go | 2 +- util/signature/verifier.go | 4 +- util/signature/verifier_test.go | 2 +- 11 files changed, 42 insertions(+), 42 deletions(-) diff --git a/arbnode/node.go b/arbnode/node.go index f5033e8314..7dabef4a1b 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -806,7 +806,7 @@ func createNodeImpl( var txPublisher TransactionPublisher var coordinator *SeqCoordinator var sequencer *Sequencer - var bpVerifier *contracts.BatchPosterVerifier + var bpVerifier *contracts.AddressVerifier if deployInfo != nil && l1client != nil { sequencerInboxAddr := deployInfo.SequencerInbox @@ -814,7 +814,7 @@ func createNodeImpl( if err != nil { return nil, err } - bpVerifier = contracts.NewBatchPosterVerifier(seqInboxCaller) + bpVerifier = contracts.NewAddressVerifier(seqInboxCaller) } if config.Sequencer.Enable { diff --git a/arbnode/seq_coordinator.go b/arbnode/seq_coordinator.go index 85f5789c73..a72e653dba 100644 --- a/arbnode/seq_coordinator.go +++ b/arbnode/seq_coordinator.go @@ -121,7 +121,7 @@ var TestSeqCoordinatorConfig = SeqCoordinatorConfig{ Signing: signature.DefaultSignVerifyConfig, } -func NewSeqCoordinator(dataSigner signature.DataSignerFunc, bpvalidator *contracts.BatchPosterVerifier, streamer *TransactionStreamer, sequencer *Sequencer, sync *SyncMonitor, config SeqCoordinatorConfig) (*SeqCoordinator, error) { +func NewSeqCoordinator(dataSigner signature.DataSignerFunc, bpvalidator *contracts.AddressVerifier, streamer *TransactionStreamer, sequencer *Sequencer, sync *SyncMonitor, config SeqCoordinatorConfig) (*SeqCoordinator, error) { redisCoordinator, err := redisutil.NewRedisCoordinator(config.RedisUrl) if err != nil { return nil, err diff --git a/broadcastclient/broadcastclient.go b/broadcastclient/broadcastclient.go index ce0d7f3930..8e72de521b 100644 --- a/broadcastclient/broadcastclient.go +++ b/broadcastclient/broadcastclient.go @@ -140,7 +140,7 @@ func NewBroadcastClient( txStreamer TransactionStreamerInterface, confirmedSequencerNumberListener chan arbutil.MessageIndex, fatalErrChan chan error, - bpVerifier contracts.BatchPosterVerifierInterface, + bpVerifier contracts.AddressVerifierInterface, adjustCount func(int32), ) (*BroadcastClient, error) { sigVerifier, err := signature.NewVerifier(&config.Verifier, bpVerifier) diff --git a/broadcastclient/broadcastclient_test.go b/broadcastclient/broadcastclient_test.go index 20948e6be1..62288d06f6 100644 --- a/broadcastclient/broadcastclient_test.go +++ b/broadcastclient/broadcastclient_test.go @@ -156,10 +156,10 @@ func (ts *dummyTransactionStreamer) AddBroadcastMessages(feedMessages []*broadca func newTestBroadcastClient(config Config, listenerAddress net.Addr, chainId uint64, currentMessageCount arbutil.MessageIndex, txStreamer TransactionStreamerInterface, confirmedSequenceNumberListener chan arbutil.MessageIndex, feedErrChan chan error, validAddr *common.Address) (*BroadcastClient, error) { port := listenerAddress.(*net.TCPAddr).Port - var bpv contracts.BatchPosterVerifierInterface + var bpv contracts.AddressVerifierInterface if validAddr != nil { config.Verifier.AcceptSequencer = true - bpv = contracts.NewMockBatchPosterVerifier(*validAddr) + bpv = contracts.NewMockAddressVerifier(*validAddr) } else { config.Verifier.AcceptSequencer = false } diff --git a/broadcastclients/broadcastclients.go b/broadcastclients/broadcastclients.go index cd96f8c608..d9f3d75027 100644 --- a/broadcastclients/broadcastclients.go +++ b/broadcastclients/broadcastclients.go @@ -28,7 +28,7 @@ func NewBroadcastClients( txStreamer broadcastclient.TransactionStreamerInterface, confirmedSequenceNumberListener chan arbutil.MessageIndex, fatalErrChan chan error, - bpVerifier contracts.BatchPosterVerifierInterface, + bpVerifier contracts.AddressVerifierInterface, ) (*BroadcastClients, error) { urlCount := len(config.URLs) if urlCount <= 0 { diff --git a/das/aggregator.go b/das/aggregator.go index 3230f9abe8..34ee19bc9f 100644 --- a/das/aggregator.go +++ b/das/aggregator.go @@ -60,7 +60,7 @@ type Aggregator struct { maxAllowedServiceStoreFailures int keysetHash [32]byte keysetBytes []byte - bpVerifier *contracts.BatchPosterVerifier + bpVerifier *contracts.AddressVerifier } type ServiceDetails struct { @@ -153,9 +153,9 @@ func NewAggregatorWithSeqInboxCaller( os.Exit(0) } - var bpVerifier *contracts.BatchPosterVerifier + var bpVerifier *contracts.AddressVerifier if seqInboxCaller != nil { - bpVerifier = contracts.NewBatchPosterVerifier(seqInboxCaller) + bpVerifier = contracts.NewAddressVerifier(seqInboxCaller) } return &Aggregator{ diff --git a/das/sign_after_store_das.go b/das/sign_after_store_das.go index 1c408618a3..9dfd97c647 100644 --- a/das/sign_after_store_das.go +++ b/das/sign_after_store_das.go @@ -79,7 +79,7 @@ type SignAfterStoreDAS struct { keysetHash [32]byte keysetBytes []byte storageService StorageService - bpVerifier *contracts.BatchPosterVerifier + bpVerifier *contracts.AddressVerifier // Extra batch poster verifier, for local installations to have their // own way of testing Stores. @@ -137,9 +137,9 @@ func NewSignAfterStoreDASWithSeqInboxCaller( return nil, err } - var bpVerifier *contracts.BatchPosterVerifier + var bpVerifier *contracts.AddressVerifier if seqInboxCaller != nil { - bpVerifier = contracts.NewBatchPosterVerifier(seqInboxCaller) + bpVerifier = contracts.NewAddressVerifier(seqInboxCaller) } var extraBpVerifier func(message []byte, timeout uint64, sig []byte) bool diff --git a/util/contracts/batch_poster_verifier.go b/util/contracts/batch_poster_verifier.go index da9354ed3e..9c2826d2ed 100644 --- a/util/contracts/batch_poster_verifier.go +++ b/util/contracts/batch_poster_verifier.go @@ -13,36 +13,36 @@ import ( "github.com/offchainlabs/nitro/solgen/go/bridgegen" ) -type BatchPosterVerifier struct { - seqInboxCaller *bridgegen.SequencerInboxCaller - cache map[common.Address]bool - cacheExpiry time.Time - mutex sync.Mutex +type AddressVerifier struct { + seqInboxCaller *bridgegen.SequencerInboxCaller + batchPosterCache map[common.Address]bool + batchPosterCacheExpiry time.Time + mutex sync.Mutex } -// Note that we only cache positive instances, not negative ones. That's because we're willing to accept the +// Note that we only batchPosterCache positive instances, not negative ones. That's because we're willing to accept the // consequences of a false positive (accepting a Store from a recently retired batch poster), but we don't want // to accept the consequences of a false negative (rejecting a Store from a recently added batch poster). -var batchPosterVerifierLifetime = time.Hour +var addressVerifierLifetime = time.Hour -func NewBatchPosterVerifier(seqInboxCaller *bridgegen.SequencerInboxCaller) *BatchPosterVerifier { - return &BatchPosterVerifier{ - seqInboxCaller: seqInboxCaller, - cache: make(map[common.Address]bool), - cacheExpiry: time.Now().Add(batchPosterVerifierLifetime), +func NewAddressVerifier(seqInboxCaller *bridgegen.SequencerInboxCaller) *AddressVerifier { + return &AddressVerifier{ + seqInboxCaller: seqInboxCaller, + batchPosterCache: make(map[common.Address]bool), + batchPosterCacheExpiry: time.Now().Add(addressVerifierLifetime), } } -func (bpv *BatchPosterVerifier) IsBatchPoster(ctx context.Context, addr common.Address) (bool, error) { +func (bpv *AddressVerifier) IsBatchPoster(ctx context.Context, addr common.Address) (bool, error) { bpv.mutex.Lock() - if time.Now().After(bpv.cacheExpiry) { + if time.Now().After(bpv.batchPosterCacheExpiry) { if err := bpv.flushCache_locked(ctx); err != nil { bpv.mutex.Unlock() return false, err } } - if bpv.cache[addr] { + if bpv.batchPosterCache[addr] { bpv.mutex.Unlock() return true, nil } @@ -54,38 +54,38 @@ func (bpv *BatchPosterVerifier) IsBatchPoster(ctx context.Context, addr common.A } if isBatchPoster { bpv.mutex.Lock() - bpv.cache[addr] = true + bpv.batchPosterCache[addr] = true bpv.mutex.Unlock() } return isBatchPoster, nil } -func (bpv *BatchPosterVerifier) FlushCache(ctx context.Context) error { +func (bpv *AddressVerifier) FlushCache(ctx context.Context) error { bpv.mutex.Lock() defer bpv.mutex.Unlock() return bpv.flushCache_locked(ctx) } -func (bpv *BatchPosterVerifier) flushCache_locked(ctx context.Context) error { - bpv.cache = make(map[common.Address]bool) - bpv.cacheExpiry = time.Now().Add(batchPosterVerifierLifetime) +func (bpv *AddressVerifier) flushCache_locked(ctx context.Context) error { + bpv.batchPosterCache = make(map[common.Address]bool) + bpv.batchPosterCacheExpiry = time.Now().Add(addressVerifierLifetime) return nil } -func NewMockBatchPosterVerifier(validAddr common.Address) *MockBatchPosterVerifier { - return &MockBatchPosterVerifier{ +func NewMockAddressVerifier(validAddr common.Address) *MockAddressVerifier { + return &MockAddressVerifier{ validAddr: validAddr, } } -type MockBatchPosterVerifier struct { +type MockAddressVerifier struct { validAddr common.Address } -func (bpv *MockBatchPosterVerifier) IsBatchPoster(_ context.Context, addr common.Address) (bool, error) { +func (bpv *MockAddressVerifier) IsBatchPoster(_ context.Context, addr common.Address) (bool, error) { return addr == bpv.validAddr, nil } -type BatchPosterVerifierInterface interface { +type AddressVerifierInterface interface { IsBatchPoster(ctx context.Context, addr common.Address) (bool, error) } diff --git a/util/signature/sign_verify.go b/util/signature/sign_verify.go index 9a594ccbeb..2911912979 100644 --- a/util/signature/sign_verify.go +++ b/util/signature/sign_verify.go @@ -39,7 +39,7 @@ var DefaultSignVerifyConfig = SignVerifyConfig{ Symmetric: TestSimpleHmacConfig, } -func NewSignVerify(config *SignVerifyConfig, signerFunc DataSignerFunc, bpValidator contracts.BatchPosterVerifierInterface) (*SignVerify, error) { +func NewSignVerify(config *SignVerifyConfig, signerFunc DataSignerFunc, bpValidator contracts.AddressVerifierInterface) (*SignVerify, error) { var fallback *SimpleHmac if config.SymmetricFallback { var err error diff --git a/util/signature/verifier.go b/util/signature/verifier.go index fb0aae9e1e..3fff0faa6a 100644 --- a/util/signature/verifier.go +++ b/util/signature/verifier.go @@ -19,7 +19,7 @@ import ( type Verifier struct { config *VerifierConfig authorizedMap map[common.Address]struct{} - bpValidator contracts.BatchPosterVerifierInterface + bpValidator contracts.AddressVerifierInterface } type VerifierConfig struct { @@ -62,7 +62,7 @@ var TestingFeedVerifierConfig = VerifierConfig{ }, } -func NewVerifier(config *VerifierConfig, bpValidator contracts.BatchPosterVerifierInterface) (*Verifier, error) { +func NewVerifier(config *VerifierConfig, bpValidator contracts.AddressVerifierInterface) (*Verifier, error) { authorizedMap := make(map[common.Address]struct{}, len(config.AllowedAddresses)) for _, addrString := range config.AllowedAddresses { addr := common.HexToAddress(addrString) diff --git a/util/signature/verifier_test.go b/util/signature/verifier_test.go index f6644f1238..38c4bbe891 100644 --- a/util/signature/verifier_test.go +++ b/util/signature/verifier_test.go @@ -82,7 +82,7 @@ func TestVerifierBatchPoster(t *testing.T) { signingAddr := crypto.PubkeyToAddress(privateKey.PublicKey) dataSigner := DataSignerFromPrivateKey(privateKey) - bpVerifier := contracts.NewMockBatchPosterVerifier(signingAddr) + bpVerifier := contracts.NewMockAddressVerifier(signingAddr) config := TestingFeedVerifierConfig config.AcceptSequencer = true verifier, err := NewVerifier(&config, bpVerifier) From 34142aa16dc2642fadf8f9fc78a22091b686d16d Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Tue, 10 Jan 2023 19:16:44 +0100 Subject: [PATCH 2/4] rename AddressVerifier file --- util/contracts/{batch_poster_verifier.go => address_verifier.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename util/contracts/{batch_poster_verifier.go => address_verifier.go} (100%) diff --git a/util/contracts/batch_poster_verifier.go b/util/contracts/address_verifier.go similarity index 100% rename from util/contracts/batch_poster_verifier.go rename to util/contracts/address_verifier.go From 55873d1f942d86bcc34aadfdbe278e1c1943ca82 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Tue, 10 Jan 2023 22:34:09 +0100 Subject: [PATCH 3/4] make AddressVerifier check both isBatchPoster and isSequencer --- das/aggregator.go | 2 +- das/sign_after_store_das.go | 2 +- util/contracts/address_verifier.go | 46 ++++++++++++++++++------------ util/signature/verifier.go | 4 +-- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/das/aggregator.go b/das/aggregator.go index 34ee19bc9f..09bd164677 100644 --- a/das/aggregator.go +++ b/das/aggregator.go @@ -201,7 +201,7 @@ func (a *Aggregator) Store(ctx context.Context, message []byte, timeout uint64, if err != nil { return nil, err } - isBatchPoster, err := a.bpVerifier.IsBatchPoster(ctx, actualSigner) + isBatchPoster, err := a.bpVerifier.IsBatchPosterOrSequencer(ctx, actualSigner) if err != nil { return nil, err } diff --git a/das/sign_after_store_das.go b/das/sign_after_store_das.go index 9dfd97c647..2812144276 100644 --- a/das/sign_after_store_das.go +++ b/das/sign_after_store_das.go @@ -194,7 +194,7 @@ func (d *SignAfterStoreDAS) Store( if err != nil { return nil, err } - isBatchPoster, err := d.bpVerifier.IsBatchPoster(ctx, actualSigner) + isBatchPoster, err := d.bpVerifier.IsBatchPosterOrSequencer(ctx, actualSigner) if err != nil { return nil, err } diff --git a/util/contracts/address_verifier.go b/util/contracts/address_verifier.go index 9c2826d2ed..f2ccb5d694 100644 --- a/util/contracts/address_verifier.go +++ b/util/contracts/address_verifier.go @@ -14,13 +14,13 @@ import ( ) type AddressVerifier struct { - seqInboxCaller *bridgegen.SequencerInboxCaller - batchPosterCache map[common.Address]bool - batchPosterCacheExpiry time.Time - mutex sync.Mutex + seqInboxCaller *bridgegen.SequencerInboxCaller + cache map[common.Address]bool + cacheExpiry time.Time + mutex sync.Mutex } -// Note that we only batchPosterCache positive instances, not negative ones. That's because we're willing to accept the +// Note that we only cache positive instances, not negative ones. That's because we're willing to accept the // consequences of a false positive (accepting a Store from a recently retired batch poster), but we don't want // to accept the consequences of a false negative (rejecting a Store from a recently added batch poster). @@ -28,36 +28,44 @@ var addressVerifierLifetime = time.Hour func NewAddressVerifier(seqInboxCaller *bridgegen.SequencerInboxCaller) *AddressVerifier { return &AddressVerifier{ - seqInboxCaller: seqInboxCaller, - batchPosterCache: make(map[common.Address]bool), - batchPosterCacheExpiry: time.Now().Add(addressVerifierLifetime), + seqInboxCaller: seqInboxCaller, + cache: make(map[common.Address]bool), + cacheExpiry: time.Now().Add(addressVerifierLifetime), } } -func (bpv *AddressVerifier) IsBatchPoster(ctx context.Context, addr common.Address) (bool, error) { +func (bpv *AddressVerifier) IsBatchPosterOrSequencer(ctx context.Context, addr common.Address) (bool, error) { bpv.mutex.Lock() - if time.Now().After(bpv.batchPosterCacheExpiry) { + if time.Now().After(bpv.cacheExpiry) { if err := bpv.flushCache_locked(ctx); err != nil { bpv.mutex.Unlock() return false, err } } - if bpv.batchPosterCache[addr] { + if bpv.cache[addr] { bpv.mutex.Unlock() return true, nil } bpv.mutex.Unlock() - isBatchPoster, err := bpv.seqInboxCaller.IsBatchPoster(&bind.CallOpts{Context: ctx}, addr) + result, err := bpv.seqInboxCaller.IsBatchPoster(&bind.CallOpts{Context: ctx}, addr) if err != nil { return false, err } - if isBatchPoster { + if !result { + var err error + result, err = bpv.seqInboxCaller.IsSequencer(&bind.CallOpts{Context: ctx}, addr) + if err != nil { + return false, err + } + } + if result { bpv.mutex.Lock() - bpv.batchPosterCache[addr] = true + bpv.cache[addr] = true bpv.mutex.Unlock() + return true, nil } - return isBatchPoster, nil + return result, nil } func (bpv *AddressVerifier) FlushCache(ctx context.Context) error { @@ -67,8 +75,8 @@ func (bpv *AddressVerifier) FlushCache(ctx context.Context) error { } func (bpv *AddressVerifier) flushCache_locked(ctx context.Context) error { - bpv.batchPosterCache = make(map[common.Address]bool) - bpv.batchPosterCacheExpiry = time.Now().Add(addressVerifierLifetime) + bpv.cache = make(map[common.Address]bool) + bpv.cacheExpiry = time.Now().Add(addressVerifierLifetime) return nil } @@ -82,10 +90,10 @@ type MockAddressVerifier struct { validAddr common.Address } -func (bpv *MockAddressVerifier) IsBatchPoster(_ context.Context, addr common.Address) (bool, error) { +func (bpv *MockAddressVerifier) IsBatchPosterOrSequencer(_ context.Context, addr common.Address) (bool, error) { return addr == bpv.validAddr, nil } type AddressVerifierInterface interface { - IsBatchPoster(ctx context.Context, addr common.Address) (bool, error) + IsBatchPosterOrSequencer(ctx context.Context, addr common.Address) (bool, error) } diff --git a/util/signature/verifier.go b/util/signature/verifier.go index 3fff0faa6a..a118ac58a4 100644 --- a/util/signature/verifier.go +++ b/util/signature/verifier.go @@ -115,12 +115,12 @@ func (v *Verifier) verifyClosure(ctx context.Context, sig []byte, hash common.Ha return ErrSignerNotApproved } - batchPoster, err := v.bpValidator.IsBatchPoster(ctx, addr) + batchPosterOrSequencer, err := v.bpValidator.IsBatchPosterOrSequencer(ctx, addr) if err != nil { return err } - if !batchPoster { + if !batchPosterOrSequencer { return ErrSignerNotApproved } From 07a9fc31ebbf0cf5b39469ffde623b630a91905f Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Tue, 10 Jan 2023 23:25:03 +0100 Subject: [PATCH 4/4] rename bpVerifier fields to addrVerifier --- broadcastclient/broadcastclient.go | 4 ++-- broadcastclient/broadcastclient_test.go | 6 +++--- broadcastclients/broadcastclients.go | 4 ++-- das/aggregator.go | 14 +++++++------- das/sign_after_store_das.go | 14 +++++++------- util/signature/verifier.go | 14 +++++++------- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/broadcastclient/broadcastclient.go b/broadcastclient/broadcastclient.go index 8e72de521b..ed8a246cdb 100644 --- a/broadcastclient/broadcastclient.go +++ b/broadcastclient/broadcastclient.go @@ -140,10 +140,10 @@ func NewBroadcastClient( txStreamer TransactionStreamerInterface, confirmedSequencerNumberListener chan arbutil.MessageIndex, fatalErrChan chan error, - bpVerifier contracts.AddressVerifierInterface, + addrVerifier contracts.AddressVerifierInterface, adjustCount func(int32), ) (*BroadcastClient, error) { - sigVerifier, err := signature.NewVerifier(&config.Verifier, bpVerifier) + sigVerifier, err := signature.NewVerifier(&config.Verifier, addrVerifier) if err != nil { return nil, err } diff --git a/broadcastclient/broadcastclient_test.go b/broadcastclient/broadcastclient_test.go index 62288d06f6..e177791ad2 100644 --- a/broadcastclient/broadcastclient_test.go +++ b/broadcastclient/broadcastclient_test.go @@ -156,14 +156,14 @@ func (ts *dummyTransactionStreamer) AddBroadcastMessages(feedMessages []*broadca func newTestBroadcastClient(config Config, listenerAddress net.Addr, chainId uint64, currentMessageCount arbutil.MessageIndex, txStreamer TransactionStreamerInterface, confirmedSequenceNumberListener chan arbutil.MessageIndex, feedErrChan chan error, validAddr *common.Address) (*BroadcastClient, error) { port := listenerAddress.(*net.TCPAddr).Port - var bpv contracts.AddressVerifierInterface + var av contracts.AddressVerifierInterface if validAddr != nil { config.Verifier.AcceptSequencer = true - bpv = contracts.NewMockAddressVerifier(*validAddr) + av = contracts.NewMockAddressVerifier(*validAddr) } else { config.Verifier.AcceptSequencer = false } - return NewBroadcastClient(config, fmt.Sprintf("ws://127.0.0.1:%d/", port), chainId, currentMessageCount, txStreamer, confirmedSequenceNumberListener, feedErrChan, bpv, func(_ int32) {}) + return NewBroadcastClient(config, fmt.Sprintf("ws://127.0.0.1:%d/", port), chainId, currentMessageCount, txStreamer, confirmedSequenceNumberListener, feedErrChan, av, func(_ int32) {}) } func startMakeBroadcastClient(ctx context.Context, t *testing.T, clientConfig Config, addr net.Addr, index int, expectedCount int, chainId uint64, wg *sync.WaitGroup, sequencerAddr *common.Address) { diff --git a/broadcastclients/broadcastclients.go b/broadcastclients/broadcastclients.go index d9f3d75027..47a915beb8 100644 --- a/broadcastclients/broadcastclients.go +++ b/broadcastclients/broadcastclients.go @@ -28,7 +28,7 @@ func NewBroadcastClients( txStreamer broadcastclient.TransactionStreamerInterface, confirmedSequenceNumberListener chan arbutil.MessageIndex, fatalErrChan chan error, - bpVerifier contracts.AddressVerifierInterface, + addrVerifier contracts.AddressVerifierInterface, ) (*BroadcastClients, error) { urlCount := len(config.URLs) if urlCount <= 0 { @@ -47,7 +47,7 @@ func NewBroadcastClients( txStreamer, confirmedSequenceNumberListener, fatalErrChan, - bpVerifier, + addrVerifier, func(delta int32) { clients.adjustCount(delta) }, ) if err != nil { diff --git a/das/aggregator.go b/das/aggregator.go index 09bd164677..4dc705ea81 100644 --- a/das/aggregator.go +++ b/das/aggregator.go @@ -60,7 +60,7 @@ type Aggregator struct { maxAllowedServiceStoreFailures int keysetHash [32]byte keysetBytes []byte - bpVerifier *contracts.AddressVerifier + addrVerifier *contracts.AddressVerifier } type ServiceDetails struct { @@ -153,9 +153,9 @@ func NewAggregatorWithSeqInboxCaller( os.Exit(0) } - var bpVerifier *contracts.AddressVerifier + var addrVerifier *contracts.AddressVerifier if seqInboxCaller != nil { - bpVerifier = contracts.NewAddressVerifier(seqInboxCaller) + addrVerifier = contracts.NewAddressVerifier(seqInboxCaller) } return &Aggregator{ @@ -166,7 +166,7 @@ func NewAggregatorWithSeqInboxCaller( maxAllowedServiceStoreFailures: config.AggregatorConfig.AssumedHonest - 1, keysetHash: keysetHash, keysetBytes: ksBuf.Bytes(), - bpVerifier: bpVerifier, + addrVerifier: addrVerifier, }, nil } @@ -196,16 +196,16 @@ type storeResponse struct { // signature is not checked, which is useful for testing. func (a *Aggregator) Store(ctx context.Context, message []byte, timeout uint64, sig []byte) (*arbstate.DataAvailabilityCertificate, error) { log.Trace("das.Aggregator.Store", "message", pretty.FirstFewBytes(message), "timeout", time.Unix(int64(timeout), 0), "sig", pretty.FirstFewBytes(sig)) - if a.bpVerifier != nil { + if a.addrVerifier != nil { actualSigner, err := DasRecoverSigner(message, timeout, sig) if err != nil { return nil, err } - isBatchPoster, err := a.bpVerifier.IsBatchPosterOrSequencer(ctx, actualSigner) + isBatchPosterOrSequencer, err := a.addrVerifier.IsBatchPosterOrSequencer(ctx, actualSigner) if err != nil { return nil, err } - if !isBatchPoster { + if !isBatchPosterOrSequencer { return nil, errors.New("store request not properly signed") } } diff --git a/das/sign_after_store_das.go b/das/sign_after_store_das.go index 2812144276..c738b5d85e 100644 --- a/das/sign_after_store_das.go +++ b/das/sign_after_store_das.go @@ -79,7 +79,7 @@ type SignAfterStoreDAS struct { keysetHash [32]byte keysetBytes []byte storageService StorageService - bpVerifier *contracts.AddressVerifier + addrVerifier *contracts.AddressVerifier // Extra batch poster verifier, for local installations to have their // own way of testing Stores. @@ -137,9 +137,9 @@ func NewSignAfterStoreDASWithSeqInboxCaller( return nil, err } - var bpVerifier *contracts.AddressVerifier + var addrVerifier *contracts.AddressVerifier if seqInboxCaller != nil { - bpVerifier = contracts.NewAddressVerifier(seqInboxCaller) + addrVerifier = contracts.NewAddressVerifier(seqInboxCaller) } var extraBpVerifier func(message []byte, timeout uint64, sig []byte) bool @@ -175,7 +175,7 @@ func NewSignAfterStoreDASWithSeqInboxCaller( keysetHash: ksHash, keysetBytes: ksBuf.Bytes(), storageService: storageService, - bpVerifier: bpVerifier, + addrVerifier: addrVerifier, extraBpVerifier: extraBpVerifier, }, nil } @@ -189,16 +189,16 @@ func (d *SignAfterStoreDAS) Store( verified = d.extraBpVerifier(message, timeout, sig) } - if !verified && d.bpVerifier != nil { + if !verified && d.addrVerifier != nil { actualSigner, err := DasRecoverSigner(message, timeout, sig) if err != nil { return nil, err } - isBatchPoster, err := d.bpVerifier.IsBatchPosterOrSequencer(ctx, actualSigner) + isBatchPosterOrSequencer, err := d.addrVerifier.IsBatchPosterOrSequencer(ctx, actualSigner) if err != nil { return nil, err } - if !isBatchPoster { + if !isBatchPosterOrSequencer { return nil, errors.New("store request not properly signed") } } diff --git a/util/signature/verifier.go b/util/signature/verifier.go index a118ac58a4..2bf5b854ed 100644 --- a/util/signature/verifier.go +++ b/util/signature/verifier.go @@ -19,7 +19,7 @@ import ( type Verifier struct { config *VerifierConfig authorizedMap map[common.Address]struct{} - bpValidator contracts.AddressVerifierInterface + addrVerifier contracts.AddressVerifierInterface } type VerifierConfig struct { @@ -62,19 +62,19 @@ var TestingFeedVerifierConfig = VerifierConfig{ }, } -func NewVerifier(config *VerifierConfig, bpValidator contracts.AddressVerifierInterface) (*Verifier, error) { +func NewVerifier(config *VerifierConfig, addrVerifier contracts.AddressVerifierInterface) (*Verifier, error) { authorizedMap := make(map[common.Address]struct{}, len(config.AllowedAddresses)) for _, addrString := range config.AllowedAddresses { addr := common.HexToAddress(addrString) authorizedMap[addr] = struct{}{} } - if bpValidator == nil && !config.Dangerous.AcceptMissing && config.AcceptSequencer { + if addrVerifier == nil && !config.Dangerous.AcceptMissing && config.AcceptSequencer { return nil, errors.New("cannot read batch poster addresses") } return &Verifier{ config: config, authorizedMap: authorizedMap, - bpValidator: bpValidator, + addrVerifier: addrVerifier, }, nil } @@ -107,15 +107,15 @@ func (v *Verifier) verifyClosure(ctx context.Context, sig []byte, hash common.Ha return nil } - if v.config.Dangerous.AcceptMissing && v.bpValidator == nil { + if v.config.Dangerous.AcceptMissing && v.addrVerifier == nil { return nil } - if !v.config.AcceptSequencer || v.bpValidator == nil { + if !v.config.AcceptSequencer || v.addrVerifier == nil { return ErrSignerNotApproved } - batchPosterOrSequencer, err := v.bpValidator.IsBatchPosterOrSequencer(ctx, addr) + batchPosterOrSequencer, err := v.addrVerifier.IsBatchPosterOrSequencer(ctx, addr) if err != nil { return err }