Skip to content

Commit e184562

Browse files
Merge remote-tracking branch 'origin/master' into split-resource-kind-storage-access
2 parents edd6ce7 + d230899 commit e184562

23 files changed

Lines changed: 317 additions & 53 deletions

.github/workflows/sbom-export.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: SBOM Export & Centralize
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
schedule:
7+
- cron: '10 18 * * 1'
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
generate-and-upload:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Source Code
17+
uses: actions/checkout@v6
18+
19+
- name: Check for recent changes
20+
id: check
21+
run: |
22+
if [ -z "$(git log --since='7 days ago' --oneline | head -1)" ]; then
23+
echo "No commits in the last 7 days, skipping SBOM generation."
24+
echo "skip=true" >> "$GITHUB_OUTPUT"
25+
fi
26+
27+
- name: Generate CycloneDX SBOM via cdxgen
28+
if: steps.check.outputs.skip != 'true'
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
run: |
32+
docker run --rm \
33+
--user "$(id -u):$(id -g)" \
34+
-v /tmp:/tmp \
35+
-v "${{ github.workspace }}:/app:rw" \
36+
-e FETCH_LICENSE=true \
37+
-e GITHUB_TOKEN \
38+
ghcr.io/cdxgen/cdxgen:v12.1.1 \
39+
-r /app \
40+
-o /app/sbom.cdx.json \
41+
--no-install-deps \
42+
--spec-version 1.6
43+
44+
if [ ! -s sbom.cdx.json ]; then
45+
echo "::error::cdxgen SBOM generation failed or returned empty."
46+
exit 1
47+
fi
48+
49+
echo "SBOM generated successfully:"
50+
ls -lh sbom.cdx.json
51+
52+
- name: Upload SBOM to Dependency Track
53+
if: steps.check.outputs.skip != 'true'
54+
env:
55+
DT_API_KEY: ${{ secrets.DEPENDENCY_TRACK_API_KEY }}
56+
DT_URL: ${{ secrets.DEPENDENCY_TRACK_URL }}
57+
run: |
58+
REPO_NAME=${GITHUB_REPOSITORY##*/}
59+
60+
curl -sf -X POST "${DT_URL}/api/v1/bom" \
61+
-H "X-Api-Key: ${DT_API_KEY}" \
62+
-F "autoCreate=true" \
63+
-F "projectName=${REPO_NAME}" \
64+
-F "projectVersion=${{ github.ref_name }}" \
65+
-F "bom=@sbom.cdx.json"
66+
67+
echo "SBOM uploaded to Dependency Track for ${REPO_NAME}@${{ github.ref_name }}"

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arbos/l2pricing/model.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ func (ps *L2PricingState) CalcMultiGasConstraintsExponents() ([multigas.NumResou
306306
}
307307

308308
for _, kind := range usedResources {
309+
if kind == multigas.ResourceKindSingleDim {
310+
// The single-dimensional gas dimension shouldn't be used to compute the base fee.
311+
// This condition should never be reached but we enforce it just to be sure.
312+
continue
313+
}
309314
weight, err := constraint.ResourceWeight(uint8(kind))
310315
if err != nil {
311316
return [multigas.NumResourceKind]arbmath.Bips{}, err
@@ -347,8 +352,9 @@ func (ps *L2PricingState) GetMultiGasBaseFeePerResource() ([]*big.Int, error) {
347352
if err != nil {
348353
return nil, err
349354
}
350-
// Force L1 calldata (and the unlikely zero-basefee case) to use the max base fee.
351-
if kind == multigas.ResourceKindL1Calldata || baseFee.Cmp(big.NewInt(0)) == 0 {
355+
// Force single-dimensional gas (and the unlikely zero-basefee case) to use the max base fee
356+
// because it is not refundable.
357+
if kind == multigas.ResourceKindSingleDim || baseFee.Cmp(big.NewInt(0)) == 0 {
352358
baseFee = baseFeeWei
353359
}
354360
fees[kind] = baseFee

arbos/l2pricing/model_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ func TestCalcMultiGasConstraintsExponents(t *testing.T) {
170170
if got := exponents[multigas.ResourceKindHistoryGrowth]; got != 0 {
171171
t.Errorf("expected zero history-growth exponent, got %v", got)
172172
}
173-
if got := exponents[multigas.ResourceKindL1Calldata]; got != 0 {
174-
t.Errorf("expected zero L1 calldata exponent, got %v", got)
173+
if got := exponents[multigas.ResourceKindSingleDim]; got != 0 {
174+
t.Errorf("expected zero single-dimensional gas exponent, got %v", got)
175175
}
176176
if got := exponents[multigas.ResourceKindL2Calldata]; got != 0 {
177177
t.Errorf("expected zero L2 calldata exponent, got %v", got)
@@ -253,7 +253,7 @@ func TestMultiDimensionalPriceForRefund(t *testing.T) {
253253
Require(t, err)
254254

255255
// Same override logic as MultiDimensionalPriceForRefund
256-
if kind == multigas.ResourceKindL1Calldata || baseFeeKind.Sign() == 0 {
256+
if kind == multigas.ResourceKindSingleDim || baseFeeKind.Sign() == 0 {
257257
baseFeeKind = baseFeeWei
258258
}
259259

arbos/tx_processor.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, multiGasUsed multigas.MultiG
390390
// This prevents the auto-redeem from executing calls against
391391
// potentially filtered addresses.
392392
if isFiltered {
393-
return true, multigas.L2CalldataGas(usergas), filteredErr, ticketId.Bytes()
393+
return true, multigas.SingleDimGas(usergas), filteredErr, ticketId.Bytes()
394394
}
395395

396396
// emit RedeemScheduled event
@@ -432,7 +432,7 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, multiGasUsed multigas.MultiG
432432
}
433433
}
434434

435-
return true, multigas.L2CalldataGas(usergas), nil, ticketId.Bytes()
435+
return true, multigas.SingleDimGas(usergas), nil, ticketId.Bytes()
436436
case *types.ArbitrumRetryTx:
437437
retryable, err := p.state.RetryableState().OpenRetryable(tx.TicketId, p.evm.Context.Time)
438438
if err != nil {
@@ -527,7 +527,7 @@ func (p *TxProcessor) GasChargingHook(gasRemaining *uint64, intrinsicGas uint64)
527527
return tipReceipient, multigas.ZeroGas(), core.ErrIntrinsicGas
528528
}
529529
*gasRemaining -= gasNeededToStartEVM
530-
multiGas := multigas.L1CalldataGas(gasNeededToStartEVM)
530+
multiGas := multigas.SingleDimGas(gasNeededToStartEVM)
531531

532532
if !p.msg.TxRunContext.IsEthcall() {
533533
var max uint64
@@ -781,8 +781,8 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, usedMultiGas multigas.MultiGas,
781781
log.Error("total gas used < poster gas component", "gasUsed", gasUsed, "posterGas", p.posterGas)
782782
computeGas = gasUsed
783783
}
784-
// Poster gas added to multiGas in GasChargingHook as L1CalldataGas
785-
usedMultiGas = usedMultiGas.SaturatingDecrement(multigas.ResourceKindL1Calldata, p.posterGas)
784+
// Poster gas added to multiGas in GasChargingHook as SingleDimGas
785+
usedMultiGas = usedMultiGas.SaturatingDecrement(multigas.ResourceKindSingleDim, p.posterGas)
786786
p.state.Restrict(p.state.L2PricingState().GrowBacklog(computeGas, usedMultiGas))
787787
}
788788
}

arbos/tx_processor_multigas_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestStartTxHookReturnsMultigas(t *testing.T) {
7979
if c.expectZeroMG {
8080
require.Equal(t, multigas.ZeroGas(), mg, "expected ZeroGas for this case")
8181
} else {
82-
require.Greater(t, mg.Get(multigas.ResourceKindL1Calldata), uint64(0), "expected L1Calldata > 0")
82+
require.Greater(t, mg.Get(multigas.ResourceKindSingleDim), uint64(0), "expected SingleDim > 0")
8383
}
8484
})
8585
}

bold/api/server/server.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,19 @@ func New(addr string, backend backend.BusinessLogicProvider) (*Server, error) {
5252
return s, nil
5353
}
5454

55-
func (s *Server) Start(ctx context.Context) error {
55+
func (s *Server) Start(ctx context.Context) {
5656
s.StopWaiter.Start(ctx, s)
57-
go func() {
58-
<-ctx.Done()
59-
if err := s.srv.Shutdown(ctx); err != nil {
60-
log.Error("Could not shutdown API server", "err", err)
57+
s.LaunchThread(func(ctx context.Context) {
58+
go func() {
59+
<-ctx.Done()
60+
if err := s.srv.Shutdown(ctx); err != nil {
61+
log.Error("Could not shutdown API server", "err", err)
62+
}
63+
}()
64+
if err := s.srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
65+
log.Error("Could not start API server", "address", s.srv.Addr, "err", err)
6166
}
62-
}()
63-
return s.srv.ListenAndServe()
67+
})
6468
}
6569

6670
func (s *Server) Addr() string {

bold/assertions/manager.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ func (m *Manager) SetRivalHandler(handler types.RivalHandler) {
271271

272272
func (m *Manager) Start(ctx context.Context) {
273273
m.StopWaiter.Start(ctx, m)
274+
m.LaunchThread(m.initialize)
275+
}
276+
277+
func (m *Manager) initialize(ctx context.Context) {
274278
if m.mode != types.WatchTowerMode {
275279
if m.delegatedStaking {
276280
// Attempt to become a new staker onchain until successful.

bold/challenge/chain/watcher.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ func (w *Watcher) IsSynced() bool {
190190
// representations for confirmation purposes.
191191
func (w *Watcher) Start(ctx context.Context) {
192192
w.StopWaiter.Start(ctx, w)
193+
w.LaunchThread(w.watchEvents)
194+
}
195+
196+
func (w *Watcher) watchEvents(ctx context.Context) {
193197
scanRange, err := retry.UntilSucceeds(ctx, func() (filterRange, error) {
194198
return w.getStartEndBlockNum(ctx)
195199
})

bold/challenge/manager.go

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ func (m *Manager) Start(ctx context.Context) {
280280
m.StopWaiter.Start(ctx, m)
281281
log.Info("Started challenge manager", "stakerAddress", m.chain.StakerAddress().Hex())
282282

283-
// Start the assertion manager.
284-
m.LaunchThread(m.assertionManager.Start)
283+
// Start the assertion manager on its own StopWaiter.
284+
m.assertionManager.Start(m.GetContext())
285285

286286
// Watcher tower and resolve modes don't monitor challenges.
287287
if m.mode == types.WatchTowerMode || m.mode == types.ResolveMode {
@@ -291,28 +291,24 @@ func (m *Manager) Start(ctx context.Context) {
291291
// Start watching for parent chain block events in the background.
292292
m.LaunchThread(m.listenForBlockEvents)
293293

294-
// Start watching for ongoing chain events in the background.
295-
m.LaunchThread(m.watcher.Start)
294+
// Start watching for ongoing chain events on its own StopWaiter.
295+
m.watcher.Start(m.GetContext())
296296

297297
if m.api != nil {
298-
m.LaunchThread(func(ctx context.Context) {
299-
if err := m.api.Start(ctx); err != nil {
300-
log.Error("Could not start API server",
301-
"address", m.api.Addr(),
302-
"err", err,
303-
)
304-
}
305-
})
298+
// Start the API server on its own StopWaiter.
299+
m.api.Start(m.GetContext())
306300
}
307301
}
308302

309303
func (m *Manager) StopAndWait() {
310-
m.StopWaiter.StopAndWait()
311-
m.assertionManager.StopAndWait()
312-
m.watcher.StopAndWait()
304+
// Stop children first so they can shut down gracefully before
305+
// the parent context is cancelled.
313306
if m.api != nil {
314307
m.api.StopAndWait()
315308
}
309+
m.watcher.StopAndWait()
310+
m.assertionManager.StopAndWait()
311+
m.StopWaiter.StopAndWait()
316312
}
317313

318314
func (m *Manager) listenForBlockEvents(ctx context.Context) {

0 commit comments

Comments
 (0)