Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
[withdrawal_safety_fixes] fix code regressions & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethen Pociask committed Nov 30, 2023
1 parent 4d51b93 commit 1aad436
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions e2e/heuristic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ func TestWithdrawalSafetyAllInvariants(t *testing.T) {
},
{
Network: core.Layer2.String(),
PType: core.Live.String(),
HeuristicType: core.WithdrawalSafety.String(),
StartHeight: nil,
EndHeight: nil,
Expand Down Expand Up @@ -309,8 +308,8 @@ func TestWithdrawalSafetyAllInvariants(t *testing.T) {

// Wait for Pessimism to process initiation
require.NoError(t, wait.For(context.Background(), 500*time.Millisecond, func() (bool, error) {
pUUID := ids[0].PUUID
height, err := ts.Subsystems.PipelineHeight(pUUID)
id := ids[0].PathID
height, err := ts.Subsystems.PathHeight(id)
if err != nil {
return false, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/registry/l1_withdrawal_safety.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func NewL1WithdrawalSafety(ctx context.Context, cfg *WithdrawalSafetyCfg) (heuri
}

// Assess ...
func (wsh *WithdrawalSafetyHeuristic) Assess(e core.Event) (*heuristic.ActivationSet, error) {
func (wsh *L1WithdrawalSafety) Assess(e core.Event) (*heuristic.ActivationSet, error) {
// TODO - Support running from withdrawal finalized events as well

// 1. Validate input
Expand Down
10 changes: 5 additions & 5 deletions internal/engine/registry/l2_withdrawal_safety.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ func NewL2WithdrawalSafety(ctx context.Context, cfg *WithdrawalSafetyCfg) (heuri
ixClient: clients.IxClient,
l1Client: clients.L1Client,

Heuristic: heuristic.NewBaseHeuristic(core.EventLog),
Heuristic: heuristic.New(core.Log, core.WithdrawalSafety),
}, nil
}

// Assess ...
func (wsh *L2WithdrawalSafety) Assess(td core.TransitData) (*heuristic.ActivationSet, error) {
func (wsh *L2WithdrawalSafety) Assess(td core.Event) (*heuristic.ActivationSet, error) {
// TODO - Support running from withdrawal finalized events as well

// 1. Validate input
logging.NoContext().Debug("Checking activation for withdrawal safety heuristic",
zap.String("data", fmt.Sprintf("%v", td)))

err := wsh.ValidateInput(td)
err := wsh.Validate(td)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func (wsh *L2WithdrawalSafety) Assess(td core.TransitData) (*heuristic.Activatio
&heuristic.Activation{
TimeStamp: time.Now(),
Message: fmt.Sprintf(WithdrawalSafetyMsg, msg, wsh.cfg.L1PortalAddress, wsh.cfg.L2ToL1Address,
wsh.SUUID(), "N/A", log.TxHash.String(), math.WeiToEther(msgPassed.Value).String()),
wsh.ID(), "N/A", log.TxHash.String(), math.WeiToEther(msgPassed.Value).String()),
},
), nil
}
Expand Down Expand Up @@ -217,7 +217,7 @@ func (wsh *L2WithdrawalSafety) Execute(invs []Invariant, meta *WithdrawalMeta) (
&heuristic.Activation{
TimeStamp: time.Now(),
Message: fmt.Sprintf(WithdrawalSafetyMsg, msg, wsh.cfg.L1PortalAddress, wsh.cfg.L2ToL1Address,
wsh.SUUID(), meta.ProvenTx.String(), meta.InitTx.String(), math.WeiToEther(meta.Value).String()),
wsh.ID(), meta.ProvenTx.String(), meta.InitTx.String(), math.WeiToEther(meta.Value).String()),
},
), nil
}

0 comments on commit 1aad436

Please sign in to comment.