Skip to content

Commit

Permalink
Merge branch 'master' into get-machine-hashes-with-step
Browse files Browse the repository at this point in the history
  • Loading branch information
tsahee authored Jul 10, 2024
2 parents 24ddd89 + 1173644 commit ea39210
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 26 deletions.
2 changes: 1 addition & 1 deletion cmd/nitro/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func isLeveldbNotExistError(err error) bool {

func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeConfig, chainId *big.Int, cacheConfig *core.CacheConfig, persistentConfig *conf.PersistentConfig, l1Client arbutil.L1Interface, rollupAddrs chaininfo.RollupAddresses) (ethdb.Database, *core.BlockChain, error) {
if !config.Init.Force {
if readOnlyDb, err := stack.OpenDatabaseWithFreezerWithExtraOptions("l2chaindata", 0, 0, "", "l2chaindata/", true, persistentConfig.Pebble.ExtraOptions("l2chaindata")); err == nil {
if readOnlyDb, err := stack.OpenDatabaseWithFreezerWithExtraOptions("l2chaindata", 0, 0, config.Persistent.Ancient, "l2chaindata/", true, persistentConfig.Pebble.ExtraOptions("l2chaindata")); err == nil {
if chainConfig := gethexec.TryReadStoredChainConfig(readOnlyDb); chainConfig != nil {
readOnlyDb.Close()
if !arbmath.BigEquals(chainConfig.ChainID, chainId) {
Expand Down
5 changes: 0 additions & 5 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,6 @@ func mainImpl() int {
exitCode = 1
}
if nodeConfig.Init.ThenQuit {
close(sigint)

return exitCode
}
}
Expand All @@ -694,9 +692,6 @@ func mainImpl() int {
log.Info("shutting down because of sigint")
}

// cause future ctrl+c's to panic
close(sigint)

return exitCode
}

Expand Down
22 changes: 8 additions & 14 deletions das/local_file_storage_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (s *LocalFileStorageService) Put(ctx context.Context, data []byte, expiry u
}
}

if !s.enableLegacyLayout && s.layout.expiryEnabled {
if !s.enableLegacyLayout {
if err := createHardLink(batchPath, s.layout.expiryPath(key, expiry)); err != nil {
return fmt.Errorf("couldn't create by-expiry-path index entry: %w", err)
}
Expand Down Expand Up @@ -360,11 +360,9 @@ func migrate(fl *flatLayout, tl *trieLayout) error {
return err
}

if tl.expiryEnabled {
expiryPath := tl.expiryPath(batch.key, uint64(batch.expiry.Unix()))
if err = createHardLink(newPath, expiryPath); err != nil {
return err
}
expiryPath := tl.expiryPath(batch.key, uint64(batch.expiry.Unix()))
if err = createHardLink(newPath, expiryPath); err != nil {
return err
}
migrated++
}
Expand Down Expand Up @@ -698,10 +696,8 @@ func (l *trieLayout) startMigration() error {
return err
}

if l.expiryEnabled {
if err := os.MkdirAll(filepath.Join(l.root, byExpiryTimestamp+migratingSuffix), 0o700); err != nil {
return err
}
if err := os.MkdirAll(filepath.Join(l.root, byExpiryTimestamp+migratingSuffix), 0o700); err != nil {
return err
}
return nil

Expand All @@ -726,10 +722,8 @@ func (l *trieLayout) commitMigration() error {
return err
}

if l.expiryEnabled {
if err := removeSuffix(byExpiryTimestamp); err != nil {
return err
}
if err := removeSuffix(byExpiryTimestamp); err != nil {
return err
}

syscall.Sync()
Expand Down
7 changes: 3 additions & 4 deletions das/local_file_storage_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ func TestMigrationNoExpiry(t *testing.T) {
countEntries(t, &s.layout, 4)
getByHashAndCheck(t, s, "a", "b", "c", "d")

_, err = s.layout.iterateBatchesByTimestamp(time.Unix(int64(now+10), 0))
if err == nil {
Fail(t, "can't iterate by timestamp when expiry is disabled")
}
// Can still iterate by timestamp even if expiry disabled
countTimestampEntries(t, &s.layout, time.Unix(int64(now+11), 0), 4)

}

func TestMigrationExpiry(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion execution/nodeInterface/virtual-contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ func init() {
return
}
posterCost, _ := state.L1PricingState().PosterDataCost(msg, l1pricing.BatchPosterAddress, brotliCompressionLevel)
posterCostInL2Gas := arbos.GetPosterGas(state, header.BaseFee, msg.TxRunMode, posterCost)
// Use estimate mode because this is used to raise the gas cap, so we don't want to underestimate.
posterCostInL2Gas := arbos.GetPosterGas(state, header.BaseFee, core.MessageGasEstimationMode, posterCost)
*gascap = arbmath.SaturatingUAdd(*gascap, posterCostInL2Gas)
}

Expand Down
2 changes: 1 addition & 1 deletion staker/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@ validationsLoop:
v.possiblyFatal(errors.New("failed to set SendingValidation status"))
}
validatorPendingValidationsGauge.Inc(1)
defer validatorPendingValidationsGauge.Dec(1)
var runs []validator.ValidationRun
for _, moduleRoot := range wasmRoots {
run := v.chosenValidator[moduleRoot].Launch(input, moduleRoot)
Expand All @@ -826,6 +825,7 @@ validationsLoop:
validationStatus.Runs = runs
validationStatus.Cancel = cancel
v.LaunchUntrackedThread(func() {
defer validatorPendingValidationsGauge.Dec(1)
defer cancel()
replaced = validationStatus.replaceStatus(SendingValidation, ValidationSent)
if !replaced {
Expand Down
32 changes: 32 additions & 0 deletions system_tests/estimation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,35 @@ func TestDisableL1Charging(t *testing.T) {
_, err = builder.L2.Client.CallContract(ctx, ethereum.CallMsg{To: &addr, Gas: gasWithoutL1Charging, SkipL1Charging: true}, nil)
Require(t, err)
}

func TestGasEstimationWithRPCGasLimit(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
cleanup := builder.Build(t)
defer cleanup()

execConfigA := builder.execConfig
execConfigA.RPC.RPCGasCap = params.TxGas
testClientA, cleanupA := builder.Build2ndNode(t, &SecondNodeParams{execConfig: execConfigA})
defer cleanupA()
addr := common.HexToAddress("0x12345678")
estimateGas, err := testClientA.Client.EstimateGas(ctx, ethereum.CallMsg{To: &addr})
Require(t, err)
if estimateGas <= params.TxGas {
Fatal(t, "Incorrect gas estimate")
}

_, err = testClientA.Client.CallContract(ctx, ethereum.CallMsg{To: &addr}, nil)
Require(t, err)

execConfigB := builder.execConfig
execConfigB.RPC.RPCGasCap = params.TxGas - 1
testClientB, cleanupB := builder.Build2ndNode(t, &SecondNodeParams{execConfig: execConfigB})
defer cleanupB()
_, err = testClientB.Client.EstimateGas(ctx, ethereum.CallMsg{To: &addr})
if err == nil {
Fatal(t, "EstimateGas passed with insufficient gas")
}
}

0 comments on commit ea39210

Please sign in to comment.