Skip to content

Commit

Permalink
ExecutionClient.Start and ExecutionClient.StopAndWait return promises
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoximenes committed Jan 3, 2025
1 parent 375bd8d commit 483c082
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
8 changes: 4 additions & 4 deletions arbnode/inbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ func (w *execClientWrapper) ResultAtPos(pos arbutil.MessageIndex) containers.Pro
return containers.NewReadyPromise(w.ExecutionEngine.ResultAtPos(pos))
}

func (w *execClientWrapper) Start(ctx context.Context) error {
return nil
func (w *execClientWrapper) Start(ctx context.Context) containers.PromiseInterface[struct{}] {
return containers.NewReadyPromise(struct{}{}, nil)
}

func (w *execClientWrapper) StopAndWait() {
return
func (w *execClientWrapper) StopAndWait() containers.PromiseInterface[struct{}] {
return containers.NewReadyPromise(struct{}{}, nil)
}

func NewTransactionStreamerForTest(t *testing.T, ownerAddress common.Address) (*gethexec.ExecutionEngine, *TransactionStreamer, ethdb.Database, *core.BlockChain) {
Expand Down
7 changes: 5 additions & 2 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ func (n *Node) Start(ctx context.Context) error {
if execClient != nil {
execClient.SetConsensusClient(n)
}
err = n.ExecutionClient.Start(ctx)
_, err = n.ExecutionClient.Start(ctx).Await(ctx)
if err != nil {
return fmt.Errorf("error starting exec client: %w", err)
}
Expand Down Expand Up @@ -1414,7 +1414,10 @@ func (n *Node) StopAndWait() {
n.DASLifecycleManager.StopAndWaitUntil(2 * time.Second)
}
if n.ExecutionClient != nil {
n.ExecutionClient.StopAndWait()
_, err := n.ExecutionClient.StopAndWait().Await(n.ctx)
if err != nil {
log.Error("error stopping execution client", "err", err)
}
}
if err := n.Stack.Close(); err != nil {
log.Error("error on stack close", "err", err)
Expand Down
14 changes: 8 additions & 6 deletions execution/gethexec/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ func (n *ExecutionNode) Initialize(ctx context.Context) error {
}

// not thread safe
func (n *ExecutionNode) Start(ctx context.Context) error {
func (n *ExecutionNode) Start(ctx context.Context) containers.PromiseInterface[struct{}] {
if n.started.Swap(true) {
return errors.New("already started")
return containers.NewReadyPromise(struct{}{}, errors.New("already started"))
}
// TODO after separation
// err := n.Stack.Start()
Expand All @@ -359,17 +359,17 @@ func (n *ExecutionNode) Start(ctx context.Context) error {
n.ExecEngine.Start(ctx)
err := n.TxPublisher.Start(ctx)
if err != nil {
return fmt.Errorf("error starting transaction puiblisher: %w", err)
return containers.NewReadyPromise(struct{}{}, fmt.Errorf("error starting transaction puiblisher: %w", err))
}
if n.ParentChainReader != nil {
n.ParentChainReader.Start(ctx)
}
return nil
return containers.NewReadyPromise(struct{}{}, nil)
}

func (n *ExecutionNode) StopAndWait() {
func (n *ExecutionNode) StopAndWait() containers.PromiseInterface[struct{}] {
if !n.started.Load() {
return
return containers.NewReadyPromise(struct{}{}, nil)
}
// TODO after separation
// n.Stack.StopRPC() // does nothing if not running
Expand All @@ -391,6 +391,8 @@ func (n *ExecutionNode) StopAndWait() {
// if err := n.Stack.Close(); err != nil {
// log.Error("error on stak close", "err", err)
// }

return containers.NewReadyPromise(struct{}{}, nil)
}

func (n *ExecutionNode) DigestMessage(num arbutil.MessageIndex, msg *arbostypes.MessageWithMetadata, msgForPrefetch *arbostypes.MessageWithMetadata) containers.PromiseInterface[*execution.MessageResult] {
Expand Down
4 changes: 2 additions & 2 deletions execution/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ type ExecutionClient interface {

Maintenance() containers.PromiseInterface[struct{}]

Start(ctx context.Context) error
StopAndWait()
Start(ctx context.Context) containers.PromiseInterface[struct{}]
StopAndWait() containers.PromiseInterface[struct{}]
}

// needed for validators / stakers
Expand Down

0 comments on commit 483c082

Please sign in to comment.