Skip to content

Commit

Permalink
Fix New Stake Method (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan authored Feb 4, 2025
1 parent 06459d1 commit f708331
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
12 changes: 2 additions & 10 deletions chain-abstraction/sol-implementation/assertion_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,19 +501,11 @@ func (a *AssertionChain) NewStake(
if err != nil {
return err
}
if !staked {
if staked {
return nil
}
latestConfirmed, err := a.LatestConfirmed(ctx, a.GetCallOptsWithDesiredRpcHeadBlockNumber(&bind.CallOpts{Context: ctx}))
if err != nil {
return err
}
info, err := a.ReadAssertionCreationInfo(ctx, latestConfirmed.Id())
if err != nil {
return err
}
_, err = a.transact(ctx, a.backend, func(opts *bind.TransactOpts) (*types.Transaction, error) {
return a.userLogic.RollupUserLogicTransactor.NewStake(opts, info.RequiredStake, a.withdrawalAddress)
return a.userLogic.RollupUserLogicTransactor.NewStake(opts, new(big.Int), a.withdrawalAddress)
})
return err
}
Expand Down
11 changes: 11 additions & 0 deletions chain-abstraction/sol-implementation/assertion_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ import (
"github.com/offchainlabs/bold/testing/setup"
)

func TestNewEmptyStake(t *testing.T) {
ctx := context.Background()
cfg, err := setup.ChainsWithEdgeChallengeManager()
require.NoError(t, err)
chain := cfg.Chains[0]
require.NoError(t, chain.NewStake(ctx))
isStaked, err := chain.IsStaked(ctx)
require.NoError(t, err)
require.True(t, isStaked)
}

func TestNewStakeOnNewAssertion(t *testing.T) {
ctx := context.Background()
cfg, err := setup.ChainsWithEdgeChallengeManager()
Expand Down

0 comments on commit f708331

Please sign in to comment.