Skip to content

Commit

Permalink
Merge branch 'master' into koanf
Browse files Browse the repository at this point in the history
  • Loading branch information
anodar authored Sep 1, 2023
2 parents 0e350fb + 8252c29 commit a645527
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 42 deletions.
4 changes: 2 additions & 2 deletions arbitrator/jit/src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ pub fn js_value_index(mut env: WasmEnvMut, sp: u32) {

pub fn js_value_call(mut env: WasmEnvMut, sp: u32) -> MaybeEscape {
let Some(resume) = env.data().exports.resume.clone() else {
return Escape::failure(format!("wasmer failed to bind {}", "resume".red()))
return Escape::failure(format!("wasmer failed to bind {}", "resume".red()));
};
let Some(get_stack_pointer) = env.data().exports.get_stack_pointer.clone() else {
return Escape::failure(format!("wasmer failed to bind {}", "getsp".red()))
return Escape::failure(format!("wasmer failed to bind {}", "getsp".red()));
};
let sp = GoStack::simple(sp, &env);
let data = env.data_mut();
Expand Down
2 changes: 1 addition & 1 deletion arbitrator/prover/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ pub struct MachineState<'a> {
initial_hash: Bytes32,
}

pub type PreimageResolver = Arc<dyn Fn(u64, Bytes32) -> Option<CBytes>>;
pub type PreimageResolver = Arc<dyn Fn(u64, Bytes32) -> Option<CBytes> + Send + Sync>;

/// Wraps a preimage resolver to provide an easier API
/// and cache the last preimage retrieved.
Expand Down
7 changes: 7 additions & 0 deletions arbitrator/prover/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ impl From<&[u8]> for CBytes {
}
}

// There's no thread safety concerns for CBytes.
// This type is basically a Box<[u8]> (which is Send + Sync) with libc as an allocator.
// Any data races between threads are prevented by Rust borrowing rules,
// and the data isn't thread-local so there's no concern moving it between threads.
unsafe impl Send for CBytes {}
unsafe impl Sync for CBytes {}

#[derive(Serialize, Deserialize)]
#[serde(remote = "Type")]
enum RemoteType {
Expand Down
46 changes: 24 additions & 22 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ type batchPosterPosition struct {

type BatchPoster struct {
stopwaiter.StopWaiter
l1Reader *headerreader.HeaderReader
inbox *InboxTracker
streamer *TransactionStreamer
config BatchPosterConfigFetcher
seqInbox *bridgegen.SequencerInbox
bridge *bridgegen.Bridge
syncMonitor *SyncMonitor
seqInboxABI *abi.ABI
seqInboxAddr common.Address
building *buildingBatch
daWriter das.DataAvailabilityServiceWriter
dataPoster *dataposter.DataPoster
redisLock *redislock.Simple
firstAccErr time.Time // first time a continuous missing accumulator occurred
l1Reader *headerreader.HeaderReader
inbox *InboxTracker
streamer *TransactionStreamer
config BatchPosterConfigFetcher
seqInbox *bridgegen.SequencerInbox
bridge *bridgegen.Bridge
syncMonitor *SyncMonitor
seqInboxABI *abi.ABI
seqInboxAddr common.Address
building *buildingBatch
daWriter das.DataAvailabilityServiceWriter
dataPoster *dataposter.DataPoster
redisLock *redislock.Simple
firstEphemeralError time.Time // first time a continuous error suspected to be ephemeral occurred
// An estimate of the number of batches we want to post but haven't yet.
// This doesn't include batches which we don't want to post yet due to the L1 bounds.
backlog uint64
Expand Down Expand Up @@ -309,8 +309,8 @@ func (b *BatchPoster) pollForReverts(ctx context.Context) {
// - polling is through context, or
// - we see a transaction in the block from dataposter that was reverted.
select {
case h, closed := <-headerCh:
if closed {
case h, ok := <-headerCh:
if !ok {
log.Info("L1 headers channel has been closed")
return
}
Expand Down Expand Up @@ -970,20 +970,22 @@ func (b *BatchPoster) Start(ctxIn context.Context) {
return b.config().PollInterval
}
posted, err := b.maybePostSequencerBatch(ctx)
ephemeralError := errors.Is(err, AccumulatorNotFoundErr) || errors.Is(err, storage.ErrStorageRace)
if !ephemeralError {
b.firstEphemeralError = time.Time{}
}
if err != nil {
b.building = nil
logLevel := log.Error
if errors.Is(err, AccumulatorNotFoundErr) || errors.Is(err, storage.ErrStorageRace) {
if ephemeralError {
// Likely the inbox tracker just isn't caught up.
// Let's see if this error disappears naturally.
if b.firstAccErr == (time.Time{}) {
b.firstAccErr = time.Now()
if b.firstEphemeralError == (time.Time{}) {
b.firstEphemeralError = time.Now()
logLevel = log.Debug
} else if time.Since(b.firstAccErr) < time.Minute {
} else if time.Since(b.firstEphemeralError) < time.Minute {
logLevel = log.Debug
}
} else {
b.firstAccErr = time.Time{}
}
logLevel("error posting batch", "err", err)
return b.config().ErrorDelay
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
2 changes: 1 addition & 1 deletion staker/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ func (v *BlockValidator) iterativeValidationPrint(ctx context.Context) time.Dura
var batchMsgs arbutil.MessageIndex
var printedCount int64
if validated.GlobalState.Batch > 0 {
batchMsgs, err = v.inboxTracker.GetBatchMessageCount(validated.GlobalState.Batch)
batchMsgs, err = v.inboxTracker.GetBatchMessageCount(validated.GlobalState.Batch - 1)
}
if err != nil {
printedCount = -1
Expand Down
30 changes: 15 additions & 15 deletions system_tests/conditionaltx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/ethereum/go-ethereum/arbitrum"
"github.com/ethereum/go-ethereum/arbitrum_types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rpc"
Expand Down Expand Up @@ -103,23 +103,23 @@ func getOptions(address common.Address, rootHash common.Hash, slotValueMap map[c
}

func getFulfillableBlockTimeLimits(t *testing.T, blockNumber uint64, timestamp uint64) []*arbitrum_types.ConditionalOptions {
future := hexutil.Uint64(timestamp + 30)
past := hexutil.Uint64(timestamp - 1)
futureBlockNumber := hexutil.Uint64(blockNumber + 1000)
currentBlockNumber := hexutil.Uint64(blockNumber)
future := math.HexOrDecimal64(timestamp + 30)
past := math.HexOrDecimal64(timestamp - 1)
futureBlockNumber := math.HexOrDecimal64(blockNumber + 1000)
currentBlockNumber := math.HexOrDecimal64(blockNumber)
return getBlockTimeLimits(t, currentBlockNumber, futureBlockNumber, past, future)
}

func getUnfulfillableBlockTimeLimits(t *testing.T, blockNumber uint64, timestamp uint64) []*arbitrum_types.ConditionalOptions {
future := hexutil.Uint64(timestamp + 30)
past := hexutil.Uint64(timestamp - 1)
futureBlockNumber := hexutil.Uint64(blockNumber + 1000)
previousBlockNumber := hexutil.Uint64(blockNumber - 1)
future := math.HexOrDecimal64(timestamp + 30)
past := math.HexOrDecimal64(timestamp - 1)
futureBlockNumber := math.HexOrDecimal64(blockNumber + 1000)
previousBlockNumber := math.HexOrDecimal64(blockNumber - 1)
// skip first empty options
return getBlockTimeLimits(t, futureBlockNumber, previousBlockNumber, future, past)[1:]
}

func getBlockTimeLimits(t *testing.T, blockMin, blockMax hexutil.Uint64, timeMin, timeMax hexutil.Uint64) []*arbitrum_types.ConditionalOptions {
func getBlockTimeLimits(t *testing.T, blockMin, blockMax math.HexOrDecimal64, timeMin, timeMax math.HexOrDecimal64) []*arbitrum_types.ConditionalOptions {
basic := []*arbitrum_types.ConditionalOptions{
{},
{TimestampMin: &timeMin},
Expand Down Expand Up @@ -157,9 +157,9 @@ func optionsProduct(optionsA, optionsB []*arbitrum_types.ConditionalOptions) []*
c.KnownAccounts[k] = v
}
limitTriples := []struct {
a *hexutil.Uint64
b *hexutil.Uint64
c **hexutil.Uint64
a *math.HexOrDecimal64
b *math.HexOrDecimal64
c **math.HexOrDecimal64
}{
{a.BlockNumberMin, b.BlockNumberMin, &c.BlockNumberMin},
{a.BlockNumberMax, b.BlockNumberMax, &c.BlockNumberMax},
Expand All @@ -168,10 +168,10 @@ func optionsProduct(optionsA, optionsB []*arbitrum_types.ConditionalOptions) []*
}
for _, tripple := range limitTriples {
if tripple.b != nil {
value := hexutil.Uint64(*tripple.b)
value := math.HexOrDecimal64(*tripple.b)
*tripple.c = &value
} else if tripple.a != nil {
value := hexutil.Uint64(*tripple.a)
value := math.HexOrDecimal64(*tripple.a)
*tripple.c = &value
} else {
*tripple.c = nil
Expand Down

0 comments on commit a645527

Please sign in to comment.