Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use shutter-network/contracts/v2 bindings #527

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions rolling-shutter/eonkeypublisher/eonkeypublisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
"github.com/jackc/pgx/v4/pgxpool"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/shutter-network/shop-contracts/bindings"
"github.com/shutter-network/contracts/v2/bindings/eonkeypublish"
"github.com/shutter-network/contracts/v2/bindings/keyperset"
"github.com/shutter-network/contracts/v2/bindings/keypersetmanager"

obskeyperdb "github.com/shutter-network/rolling-shutter/rolling-shutter/chainobserver/db/keyper"
"github.com/shutter-network/rolling-shutter/rolling-shutter/keyper"
Expand All @@ -32,7 +34,7 @@ const (
type EonKeyPublisher struct {
dbpool *pgxpool.Pool
client *ethclient.Client
keyperSetManager *bindings.KeyperSetManager
keyperSetManager *keypersetmanager.Keypersetmanager
privateKey *ecdsa.PrivateKey

keys chan keyper.EonPublicKey
Expand All @@ -44,7 +46,7 @@ func NewEonKeyPublisher(
keyperSetManagerAddress common.Address,
privateKey *ecdsa.PrivateKey,
) (*EonKeyPublisher, error) {
keyperSetManager, err := bindings.NewKeyperSetManager(keyperSetManagerAddress, client)
keyperSetManager, err := keypersetmanager.NewKeypersetmanager(keyperSetManagerAddress, client)
if err != nil {
return nil, errors.Wrapf(err, "failed to instantiate keyper set manager contract at address %s", keyperSetManagerAddress.Hex())
}
Expand Down Expand Up @@ -221,21 +223,21 @@ func (p *EonKeyPublisher) tryPublish(ctx context.Context, key []byte, keyperSetI
return nil
}

func (p *EonKeyPublisher) getEonKeyPublisherContract(keyperSetIndex uint64) (*bindings.EonKeyPublish, error) {
func (p *EonKeyPublisher) getEonKeyPublisherContract(keyperSetIndex uint64) (*eonkeypublish.Eonkeypublish, error) {
opts := &bind.CallOpts{}
keyperSetAddress, err := p.keyperSetManager.GetKeyperSetAddress(opts, keyperSetIndex)
if err != nil {
return nil, errors.Wrapf(err, "failed to get keyper set address from manager for index %d", keyperSetIndex)
}
keyperSet, err := bindings.NewKeyperSet(keyperSetAddress, p.client)
keyperSet, err := keyperset.NewKeyperset(keyperSetAddress, p.client)
if err != nil {
return nil, errors.Wrapf(err, "failed to instantiate keyper set contract at address %s", keyperSetAddress.Hex())
}
eonKeyPublisherAddress, err := keyperSet.GetPublisher(opts)
if err != nil {
return nil, errors.Wrapf(err, "failed to get eon key publisher contract from keyper set at address %s", keyperSetAddress.Hex())
}
eonKeyPublisher, err := bindings.NewEonKeyPublish(eonKeyPublisherAddress, p.client)
eonKeyPublisher, err := eonkeypublish.NewEonkeypublish(eonKeyPublisherAddress, p.client)
if err != nil {
return nil, errors.Wrapf(err, "failed to instantiate eon key publisher contract at address %s", eonKeyPublisherAddress.Hex())
}
Expand Down
4 changes: 2 additions & 2 deletions rolling-shutter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.19.1
github.com/rs/zerolog v1.28.0
github.com/shutter-network/gnosh-contracts v0.4.0
github.com/shutter-network/shop-contracts v0.0.0-20240407151512-08ef5d8355b6
github.com/shutter-network/contracts/v2 v2.0.0-beta.2
github.com/shutter-network/shop-contracts v0.0.0-20240826093107-e2022678a13f
github.com/shutter-network/shutter/shlib v0.1.19
github.com/shutter-network/txtypes v0.1.0
github.com/spf13/afero v1.8.2
Expand Down
8 changes: 4 additions & 4 deletions rolling-shutter/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,10 @@ github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
github.com/shutter-network/gnosh-contracts v0.4.0 h1:2GJcHK9w4lJZMsccklmxDhNnrkRLJDRwsL1acBnAeak=
github.com/shutter-network/gnosh-contracts v0.4.0/go.mod h1:QB0d64ybbVFKMrLjrc1tldri87KNjTmKQjhk9jaso2E=
github.com/shutter-network/shop-contracts v0.0.0-20240407151512-08ef5d8355b6 h1:m6Ti1/IH+GBTtGqyAX3xbh+ruUKvC+m+/uzYDUa+JDQ=
github.com/shutter-network/shop-contracts v0.0.0-20240407151512-08ef5d8355b6/go.mod h1:LEWXLRruvxq9fe2oKtJI3xfzbauhfWTjOczHN61RU+4=
github.com/shutter-network/contracts/v2 v2.0.0-beta.2 h1:cJJUis+ljdDWKAIOkhj8xQjJs/j0aKwoX71AqM5oXHA=
github.com/shutter-network/contracts/v2 v2.0.0-beta.2/go.mod h1:V8KhVM75wyWVSzZJ6GeC9dWCjRrinIQVb7mYNP+knbg=
github.com/shutter-network/shop-contracts v0.0.0-20240826093107-e2022678a13f h1:tp9nqAaz9t4yvnmw1vUw8vBDryvejVmeQiAzARmnUoU=
github.com/shutter-network/shop-contracts v0.0.0-20240826093107-e2022678a13f/go.mod h1:LEWXLRruvxq9fe2oKtJI3xfzbauhfWTjOczHN61RU+4=
github.com/shutter-network/shutter/shlib v0.1.19 h1:Fm/PnxAapl5UK4JuJyF2wBh3dYB5ESztnNFcbmzNNOI=
github.com/shutter-network/shutter/shlib v0.1.19/go.mod h1:miY10OJ0FKjLZTwvmG0AJNijsjsNDAk6l1tROTj8uzU=
github.com/shutter-network/txtypes v0.1.0 h1:QqdiiiB9AiBCSJ/ke6z1ZoDGfu2+1Lgpz5vHzVN4FKc=
Expand Down
4 changes: 2 additions & 2 deletions rolling-shutter/keyperimpl/gnosis/keyper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/jackc/pgx/v4/pgxpool"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
sequencerBindings "github.com/shutter-network/gnosh-contracts/gnoshcontracts/sequencer"
validatorRegistryBindings "github.com/shutter-network/gnosh-contracts/gnoshcontracts/validatorregistry"
sequencerBindings "github.com/shutter-network/contracts/v2/bindings/sequencer"
validatorRegistryBindings "github.com/shutter-network/contracts/v2/bindings/validatorregistry"
"golang.org/x/exp/slog"

"github.com/shutter-network/rolling-shutter/rolling-shutter/eonkeypublisher"
Expand Down
2 changes: 1 addition & 1 deletion rolling-shutter/keyperimpl/gnosis/sequencersyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/jackc/pgx/v4/pgxpool"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
sequencerBindings "github.com/shutter-network/gnosh-contracts/gnoshcontracts/sequencer"
sequencerBindings "github.com/shutter-network/contracts/v2/bindings/sequencer"

"github.com/shutter-network/rolling-shutter/rolling-shutter/keyperimpl/gnosis/database"
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley"
Expand Down
2 changes: 1 addition & 1 deletion rolling-shutter/keyperimpl/gnosis/validatorsyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
validatorRegistryBindings "github.com/shutter-network/gnosh-contracts/gnoshcontracts/validatorregistry"
validatorRegistryBindings "github.com/shutter-network/contracts/v2/bindings/validatorregistry"
blst "github.com/supranational/blst/bindings/go"

"github.com/shutter-network/rolling-shutter/rolling-shutter/keyperimpl/gnosis/database"
Expand Down
7 changes: 4 additions & 3 deletions rolling-shutter/medley/chainsync/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/pkg/errors"
"github.com/shutter-network/shop-contracts/bindings"
"github.com/shutter-network/contracts/v2/bindings/keybroadcastcontract"
"github.com/shutter-network/contracts/v2/bindings/keypersetmanager"

"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/chainsync/client"
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/chainsync/event"
Expand All @@ -31,8 +32,8 @@ type Client struct {
chainID *big.Int
privKey *ecdsa.PrivateKey

KeyperSetManager *bindings.KeyperSetManager
KeyBroadcast *bindings.KeyBroadcastContract
KeyperSetManager *keypersetmanager.Keypersetmanager
KeyBroadcast *keybroadcastcontract.Keybroadcastcontract

sssync *syncer.ShutterStateSyncer
kssync *syncer.KeyperSetSyncer
Expand Down
7 changes: 4 additions & 3 deletions rolling-shutter/medley/chainsync/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/pkg/errors"
"github.com/shutter-network/shop-contracts/bindings"
"github.com/shutter-network/contracts/v2/bindings/keybroadcastcontract"
"github.com/shutter-network/contracts/v2/bindings/keypersetmanager"
"github.com/shutter-network/shop-contracts/predeploy"

syncclient "github.com/shutter-network/rolling-shutter/rolling-shutter/medley/chainsync/client"
Expand Down Expand Up @@ -80,7 +81,7 @@ func (o *options) apply(ctx context.Context, c *Client) error {
o.syncStart = number.NewBlockNumber(&latestBlock)
}

c.KeyperSetManager, err = bindings.NewKeyperSetManager(*o.keyperSetManagerAddress, client)
c.KeyperSetManager, err = keypersetmanager.NewKeypersetmanager(*o.keyperSetManagerAddress, client)
if err != nil {
return err
}
Expand All @@ -95,7 +96,7 @@ func (o *options) apply(ctx context.Context, c *Client) error {
c.services = append(c.services, c.kssync)
}

c.KeyBroadcast, err = bindings.NewKeyBroadcastContract(*o.keyBroadcastContractAddress, client)
c.KeyBroadcast, err = keybroadcastcontract.NewKeybroadcastcontract(*o.keyBroadcastContractAddress, client)
if err != nil {
return err
}
Expand Down
11 changes: 6 additions & 5 deletions rolling-shutter/medley/chainsync/syncer/eonpubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/log"
"github.com/shutter-network/shop-contracts/bindings"
"github.com/shutter-network/contracts/v2/bindings/keybroadcastcontract"
"github.com/shutter-network/contracts/v2/bindings/keypersetmanager"

"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/chainsync/client"
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/chainsync/event"
Expand All @@ -18,12 +19,12 @@ import (
type EonPubKeySyncer struct {
Client client.Client
Log log.Logger
KeyBroadcast *bindings.KeyBroadcastContract
KeyperSetManager *bindings.KeyperSetManager
KeyBroadcast *keybroadcastcontract.Keybroadcastcontract
KeyperSetManager *keypersetmanager.Keypersetmanager
StartBlock *number.BlockNumber
Handler event.EonPublicKeyHandler

keyBroadcastCh chan *bindings.KeyBroadcastContractEonKeyBroadcast
keyBroadcastCh chan *keybroadcastcontract.KeybroadcastcontractEonKeyBroadcast
}

func (s *EonPubKeySyncer) Start(ctx context.Context, runner service.Runner) error {
Expand Down Expand Up @@ -55,7 +56,7 @@ func (s *EonPubKeySyncer) Start(ctx context.Context, runner service.Runner) erro
Start: s.StartBlock.ToUInt64Ptr(),
Context: ctx,
}
s.keyBroadcastCh = make(chan *bindings.KeyBroadcastContractEonKeyBroadcast, channelSize)
s.keyBroadcastCh = make(chan *keybroadcastcontract.KeybroadcastcontractEonKeyBroadcast, channelSize)
subs, err := s.KeyBroadcast.WatchEonKeyBroadcast(watchOpts, s.keyBroadcastCh)
// FIXME: what to do on subs.Error()
if err != nil {
Expand Down
11 changes: 6 additions & 5 deletions rolling-shutter/medley/chainsync/syncer/keyperset.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/pkg/errors"
"github.com/shutter-network/shop-contracts/bindings"
"github.com/shutter-network/contracts/v2/bindings/keyperset"
"github.com/shutter-network/contracts/v2/bindings/keypersetmanager"

"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/chainsync/client"
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/chainsync/event"
Expand All @@ -23,12 +24,12 @@ const channelSize = 10

type KeyperSetSyncer struct {
Client client.Client
Contract *bindings.KeyperSetManager
Contract *keypersetmanager.Keypersetmanager
Log log.Logger
StartBlock *number.BlockNumber
Handler event.KeyperSetHandler

keyperAddedCh chan *bindings.KeyperSetManagerKeyperSetAdded
keyperAddedCh chan *keypersetmanager.KeypersetmanagerKeyperSetAdded
}

func (s *KeyperSetSyncer) Start(ctx context.Context, runner service.Runner) error {
Expand Down Expand Up @@ -65,7 +66,7 @@ func (s *KeyperSetSyncer) Start(ctx context.Context, runner service.Runner) erro
)
}
}
s.keyperAddedCh = make(chan *bindings.KeyperSetManagerKeyperSetAdded, channelSize)
s.keyperAddedCh = make(chan *keypersetmanager.KeypersetmanagerKeyperSetAdded, channelSize)
subs, err := s.Contract.WatchKeyperSetAdded(watchOpts, s.keyperAddedCh)
// FIXME: what to do on subs.Error()
if err != nil {
Expand Down Expand Up @@ -171,7 +172,7 @@ func (s *KeyperSetSyncer) newEvent(
if err := guardCallOpts(opts, false); err != nil {
return nil, err
}
ks, err := bindings.NewKeyperSet(keyperSetContract, s.Client)
ks, err := keyperset.NewKeyperset(keyperSetContract, s.Client)
if err != nil {
return nil, errors.Wrap(err, "could not bind to KeyperSet contract")
}
Expand Down
12 changes: 6 additions & 6 deletions rolling-shutter/medley/chainsync/syncer/shutterstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/log"
"github.com/pkg/errors"
"github.com/shutter-network/shop-contracts/bindings"
"github.com/shutter-network/contracts/v2/bindings/keypersetmanager"

"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/chainsync/client"
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/chainsync/event"
Expand All @@ -16,13 +16,13 @@ import (

type ShutterStateSyncer struct {
Client client.Client
Contract *bindings.KeyperSetManager
Contract *keypersetmanager.Keypersetmanager
StartBlock *number.BlockNumber
Log log.Logger
Handler event.ShutterStateHandler

pausedCh chan *bindings.KeyperSetManagerPaused
unpausedCh chan *bindings.KeyperSetManagerUnpaused
pausedCh chan *keypersetmanager.KeypersetmanagerPaused
unpausedCh chan *keypersetmanager.KeypersetmanagerUnpaused
}

func (s *ShutterStateSyncer) GetShutterState(ctx context.Context, opts *bind.CallOpts) (*event.ShutterState, error) {
Expand All @@ -48,15 +48,15 @@ func (s *ShutterStateSyncer) Start(ctx context.Context, runner service.Runner) e
Start: s.StartBlock.ToUInt64Ptr(), // nil means latest
Context: ctx,
}
s.pausedCh = make(chan *bindings.KeyperSetManagerPaused)
s.pausedCh = make(chan *keypersetmanager.KeypersetmanagerPaused)
subs, err := s.Contract.WatchPaused(watchOpts, s.pausedCh)
// FIXME: what to do on subs.Error()
if err != nil {
return err
}
runner.Defer(subs.Unsubscribe)

s.unpausedCh = make(chan *bindings.KeyperSetManagerUnpaused)
s.unpausedCh = make(chan *keypersetmanager.KeypersetmanagerUnpaused)
subs, err = s.Contract.WatchUnpaused(watchOpts, s.unpausedCh)
// FIXME: what to do on subs.Error()
if err != nil {
Expand Down