Skip to content

Commit

Permalink
Merge branch 'master' into fix-stop-only
Browse files Browse the repository at this point in the history
  • Loading branch information
tsahee authored Dec 9, 2024
2 parents 9983043 + d07d7a4 commit a5e169c
Show file tree
Hide file tree
Showing 56 changed files with 4,286 additions and 859 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
redis:
image: redis
ports:
- 6379:6379
- 6379:6379

strategy:
fail-fast: false
Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
- name: run challenge tests
if: matrix.test-mode == 'challenge'
run: ${{ github.workspace }}/.github/workflows/gotestsum.sh --tags challengetest --run TestChallenge --cover
run: ${{ github.workspace }}/.github/workflows/gotestsum.sh --tags challengetest --run TestChallenge --timeout 60m --cover

- name: run stylus tests
if: matrix.test-mode == 'stylus'
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
[submodule "nitro-testnode"]
path = nitro-testnode
url = https://github.com/OffchainLabs/nitro-testnode.git
[submodule "bold"]
path = bold
url = https://github.com/OffchainLabs/bold.git
[submodule "arbitrator/langs/rust"]
path = arbitrator/langs/rust
url = https://github.com/OffchainLabs/stylus-sdk-rs.git
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
COPY go.mod go.sum ./
COPY go-ethereum/go.mod go-ethereum/go.sum go-ethereum/
COPY fastcache/go.mod fastcache/go.sum fastcache/
COPY bold/go.mod bold/go.sum bold/
RUN go mod download
COPY . ./
COPY --from=contracts-builder workspace/contracts/build/ contracts/build/
Expand Down
6 changes: 6 additions & 0 deletions arbitrator/prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ pub unsafe extern "C" fn arbitrator_load_wavm_binary(binary_path: *const c_char)
}
}

#[no_mangle]
#[cfg(feature = "native")]
pub unsafe extern "C" fn arbitrator_new_finished(gs: GlobalState) -> *mut Machine {
Box::into_raw(Box::new(Machine::new_finished(gs)))
}

unsafe fn cstr_to_string(c_str: *const c_char) -> String {
CStr::from_ptr(c_str).to_string_lossy().into_owned()
}
Expand Down
39 changes: 39 additions & 0 deletions arbitrator/prover/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,36 @@ impl Machine {
Ok(mach)
}

// new_finished returns a Machine in the Finished state at step 0.
//
// This allows the Mahine to be set up to model the final state of the
// machine at the end of the execution of a block.
pub fn new_finished(gs: GlobalState) -> Machine {
Machine {
steps: 0,
status: MachineStatus::Finished,
global_state: gs,
// The machine is in the Finished state, so nothing else really matters.
// values_stacks and frame_stacks cannot be empty for proof serialization,
// but everything else can just be entirely blank.
thread_state: ThreadState::Main,
value_stacks: vec![Vec::new()],
frame_stacks: vec![Vec::new()],
internal_stack: Default::default(),
modules: Default::default(),
modules_merkle: Default::default(),
pc: Default::default(),
stdio_output: Default::default(),
inbox_contents: Default::default(),
first_too_far: Default::default(),
preimage_resolver: PreimageResolverWrapper::new(Arc::new(|_, _, _| None)),
stylus_modules: Default::default(),
initial_hash: Default::default(),
context: Default::default(),
debug_info: Default::default(),
}
}

pub fn new_from_wavm(wavm_binary: &Path) -> Result<Machine> {
let mut modules: Vec<Module> = {
let compressed = std::fs::read(wavm_binary)?;
Expand Down Expand Up @@ -2867,6 +2897,15 @@ impl Machine {
let mod_merkle = self.get_modules_merkle();
out!(mod_merkle.root());

if self.is_halted() {
// If the machine is halted, instead of serializing the module,
// serialize the global state and return.
// This is for the "kickstart" BoLD proof, but it's backwards compatible
// with the old OSP behavior which reads no further.
out!(self.global_state.serialize());
return data;
}

// End machine serialization, serialize module

let module = &self.modules[self.pc.module()];
Expand Down
14 changes: 12 additions & 2 deletions arbnode/dataposter/data_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,13 +712,23 @@ func (p *DataPoster) feeAndTipCaps(ctx context.Context, nonce uint64, gasLimit u
return newBaseFeeCap, newTipCap, newBlobFeeCap, nil
}

func (p *DataPoster) PostSimpleTransaction(ctx context.Context, nonce uint64, to common.Address, calldata []byte, gasLimit uint64, value *big.Int) (*types.Transaction, error) {
return p.PostTransaction(ctx, time.Now(), nonce, nil, to, calldata, gasLimit, value, nil, nil)
func (p *DataPoster) PostSimpleTransaction(ctx context.Context, to common.Address, calldata []byte, gasLimit uint64, value *big.Int) (*types.Transaction, error) {
p.mutex.Lock()
defer p.mutex.Unlock()
nonce, _, _, _, err := p.getNextNonceAndMaybeMeta(ctx, 1)
if err != nil {
return nil, err
}
return p.postTransactionWithMutex(ctx, time.Now(), nonce, nil, to, calldata, gasLimit, value, nil, nil)
}

func (p *DataPoster) PostTransaction(ctx context.Context, dataCreatedAt time.Time, nonce uint64, meta []byte, to common.Address, calldata []byte, gasLimit uint64, value *big.Int, kzgBlobs []kzg4844.Blob, accessList types.AccessList) (*types.Transaction, error) {
p.mutex.Lock()
defer p.mutex.Unlock()
return p.postTransactionWithMutex(ctx, dataCreatedAt, nonce, meta, to, calldata, gasLimit, value, kzgBlobs, accessList)
}

func (p *DataPoster) postTransactionWithMutex(ctx context.Context, dataCreatedAt time.Time, nonce uint64, meta []byte, to common.Address, calldata []byte, gasLimit uint64, value *big.Int, kzgBlobs []kzg4844.Blob, accessList types.AccessList) (*types.Transaction, error) {

if p.config().DisableNewTx {
return nil, fmt.Errorf("posting new transaction is disabled")
Expand Down
61 changes: 31 additions & 30 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ import (
"github.com/offchainlabs/nitro/solgen/go/precompilesgen"
"github.com/offchainlabs/nitro/solgen/go/rollupgen"
"github.com/offchainlabs/nitro/staker"
boldstaker "github.com/offchainlabs/nitro/staker/bold"
legacystaker "github.com/offchainlabs/nitro/staker/legacy"
multiprotocolstaker "github.com/offchainlabs/nitro/staker/multi_protocol"
"github.com/offchainlabs/nitro/staker/validatorwallet"
"github.com/offchainlabs/nitro/util/contracts"
"github.com/offchainlabs/nitro/util/headerreader"
Expand Down Expand Up @@ -79,22 +82,23 @@ func GenerateRollupConfig(prod bool, wasmModuleRoot common.Hash, rollupOwner com
}

type Config struct {
Sequencer bool `koanf:"sequencer"`
ParentChainReader headerreader.Config `koanf:"parent-chain-reader" reload:"hot"`
InboxReader InboxReaderConfig `koanf:"inbox-reader" reload:"hot"`
DelayedSequencer DelayedSequencerConfig `koanf:"delayed-sequencer" reload:"hot"`
BatchPoster BatchPosterConfig `koanf:"batch-poster" reload:"hot"`
MessagePruner MessagePrunerConfig `koanf:"message-pruner" reload:"hot"`
BlockValidator staker.BlockValidatorConfig `koanf:"block-validator" reload:"hot"`
Feed broadcastclient.FeedConfig `koanf:"feed" reload:"hot"`
Staker staker.L1ValidatorConfig `koanf:"staker" reload:"hot"`
SeqCoordinator SeqCoordinatorConfig `koanf:"seq-coordinator"`
DataAvailability das.DataAvailabilityConfig `koanf:"data-availability"`
SyncMonitor SyncMonitorConfig `koanf:"sync-monitor"`
Dangerous DangerousConfig `koanf:"dangerous"`
TransactionStreamer TransactionStreamerConfig `koanf:"transaction-streamer" reload:"hot"`
Maintenance MaintenanceConfig `koanf:"maintenance" reload:"hot"`
ResourceMgmt resourcemanager.Config `koanf:"resource-mgmt" reload:"hot"`
Sequencer bool `koanf:"sequencer"`
ParentChainReader headerreader.Config `koanf:"parent-chain-reader" reload:"hot"`
InboxReader InboxReaderConfig `koanf:"inbox-reader" reload:"hot"`
DelayedSequencer DelayedSequencerConfig `koanf:"delayed-sequencer" reload:"hot"`
BatchPoster BatchPosterConfig `koanf:"batch-poster" reload:"hot"`
MessagePruner MessagePrunerConfig `koanf:"message-pruner" reload:"hot"`
BlockValidator staker.BlockValidatorConfig `koanf:"block-validator" reload:"hot"`
Feed broadcastclient.FeedConfig `koanf:"feed" reload:"hot"`
Staker legacystaker.L1ValidatorConfig `koanf:"staker" reload:"hot"`
Bold boldstaker.BoldConfig `koanf:"bold"`
SeqCoordinator SeqCoordinatorConfig `koanf:"seq-coordinator"`
DataAvailability das.DataAvailabilityConfig `koanf:"data-availability"`
SyncMonitor SyncMonitorConfig `koanf:"sync-monitor"`
Dangerous DangerousConfig `koanf:"dangerous"`
TransactionStreamer TransactionStreamerConfig `koanf:"transaction-streamer" reload:"hot"`
Maintenance MaintenanceConfig `koanf:"maintenance" reload:"hot"`
ResourceMgmt resourcemanager.Config `koanf:"resource-mgmt" reload:"hot"`
// SnapSyncConfig is only used for testing purposes, these should not be configured in production.
SnapSyncTest SnapSyncConfig
}
Expand Down Expand Up @@ -153,7 +157,8 @@ func ConfigAddOptions(prefix string, f *flag.FlagSet, feedInputEnable bool, feed
MessagePrunerConfigAddOptions(prefix+".message-pruner", f)
staker.BlockValidatorConfigAddOptions(prefix+".block-validator", f)
broadcastclient.FeedConfigAddOptions(prefix+".feed", f, feedInputEnable, feedOutputEnable)
staker.L1ValidatorConfigAddOptions(prefix+".staker", f)
legacystaker.L1ValidatorConfigAddOptions(prefix+".staker", f)
boldstaker.BoldConfigAddOptions(prefix+".bold", f)
SeqCoordinatorConfigAddOptions(prefix+".seq-coordinator", f)
das.DataAvailabilityConfigAddNodeOptions(prefix+".data-availability", f)
SyncMonitorConfigAddOptions(prefix+".sync-monitor", f)
Expand All @@ -171,7 +176,8 @@ var ConfigDefault = Config{
MessagePruner: DefaultMessagePrunerConfig,
BlockValidator: staker.DefaultBlockValidatorConfig,
Feed: broadcastclient.FeedConfigDefault,
Staker: staker.DefaultL1ValidatorConfig,
Staker: legacystaker.DefaultL1ValidatorConfig,
Bold: boldstaker.DefaultBoldConfig,
SeqCoordinator: DefaultSeqCoordinatorConfig,
DataAvailability: das.DefaultDataAvailabilityConfig,
SyncMonitor: DefaultSyncMonitorConfig,
Expand Down Expand Up @@ -203,7 +209,7 @@ func ConfigDefaultL1NonSequencerTest() *Config {
config.SeqCoordinator.Enable = false
config.BlockValidator = staker.TestBlockValidatorConfig
config.SyncMonitor = TestSyncMonitorConfig
config.Staker = staker.TestL1ValidatorConfig
config.Staker = legacystaker.TestL1ValidatorConfig
config.Staker.Enable = false
config.BlockValidator.ValidationServerConfigs = []rpcclient.ClientConfig{{URL: ""}}

Expand All @@ -219,7 +225,7 @@ func ConfigDefaultL2Test() *Config {
config.Feed.Output.Signed = false
config.SeqCoordinator.Signer.ECDSA.AcceptSequencer = false
config.SeqCoordinator.Signer.ECDSA.Dangerous.AcceptMissing = true
config.Staker = staker.TestL1ValidatorConfig
config.Staker = legacystaker.TestL1ValidatorConfig
config.SyncMonitor = TestSyncMonitorConfig
config.Staker.Enable = false
config.BlockValidator.ValidationServerConfigs = []rpcclient.ClientConfig{{URL: ""}}
Expand Down Expand Up @@ -267,7 +273,7 @@ type Node struct {
MessagePruner *MessagePruner
BlockValidator *staker.BlockValidator
StatelessBlockValidator *staker.StatelessBlockValidator
Staker *staker.Staker
Staker *multiprotocolstaker.MultiProtocolStaker
BroadcastServer *broadcaster.Broadcaster
BroadcastClients *broadcastclients.BroadcastClients
SeqCoordinator *SeqCoordinator
Expand Down Expand Up @@ -633,7 +639,7 @@ func createNodeImpl(
}
}

var stakerObj *staker.Staker
var stakerObj *multiprotocolstaker.MultiProtocolStaker
var messagePruner *MessagePruner
var stakerAddr common.Address

Expand All @@ -653,7 +659,7 @@ func createNodeImpl(
getExtraGas := func() uint64 { return configFetcher.Get().Staker.ExtraGas }
// TODO: factor this out into separate helper, and split rest of node
// creation into multiple helpers.
var wallet staker.ValidatorWalletInterface = validatorwallet.NewNoOp(l1client, deployInfo.Rollup)
var wallet legacystaker.ValidatorWalletInterface = validatorwallet.NewNoOp(l1client, deployInfo.Rollup)
if !strings.EqualFold(config.Staker.Strategy, "watchtower") {
if config.Staker.UseSmartContractWallet || (txOptsValidator == nil && config.Staker.DataPoster.ExternalSigner.URL == "") {
var existingWalletAddress *common.Address
Expand Down Expand Up @@ -681,13 +687,13 @@ func createNodeImpl(
}
}

var confirmedNotifiers []staker.LatestConfirmedNotifier
var confirmedNotifiers []legacystaker.LatestConfirmedNotifier
if config.MessagePruner.Enable {
messagePruner = NewMessagePruner(txStreamer, inboxTracker, func() *MessagePrunerConfig { return &configFetcher.Get().MessagePruner })
confirmedNotifiers = append(confirmedNotifiers, messagePruner)
}

stakerObj, err = staker.NewStaker(l1Reader, wallet, bind.CallOpts{}, func() *staker.L1ValidatorConfig { return &configFetcher.Get().Staker }, blockValidator, statelessBlockValidator, nil, confirmedNotifiers, deployInfo.ValidatorUtils, fatalErrChan)
stakerObj, err = multiprotocolstaker.NewMultiProtocolStaker(stack, l1Reader, wallet, bind.CallOpts{}, func() *legacystaker.L1ValidatorConfig { return &configFetcher.Get().Staker }, &configFetcher.Get().Bold, blockValidator, statelessBlockValidator, nil, deployInfo.StakeToken, confirmedNotifiers, deployInfo.ValidatorUtils, deployInfo.Bridge, fatalErrChan)
if err != nil {
return nil, err
}
Expand All @@ -697,11 +703,6 @@ func createNodeImpl(
if dp != nil {
stakerAddr = dp.Sender()
}
whitelisted, err := stakerObj.IsWhitelisted(ctx)
if err != nil {
return nil, err
}
log.Info("running as validator", "txSender", stakerAddr, "actingAsWallet", wallet.Address(), "whitelisted", whitelisted, "strategy", config.Staker.Strategy)
}

var batchPoster *BatchPoster
Expand Down
1 change: 1 addition & 0 deletions bold
Submodule bold added at d0a87d
2 changes: 2 additions & 0 deletions cmd/chaininfo/arbitrum_chain_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"sequencer-inbox": "0x1c479675ad559dc151f6ec7ed3fbf8cee79582b6",
"validator-utils": "0x9e40625f52829cf04bc4839f186d621ee33b0e67",
"validator-wallet-creator": "0x960953f7c69cd2bc2322db9223a815c680ccc7ea",
"stake-token": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"deployed-at": 15411056
}
},
Expand Down Expand Up @@ -90,6 +91,7 @@
"sequencer-inbox": "0x211e1c4c7f1bf5351ac850ed10fd68cffcf6c21b",
"validator-utils": "0x2B081fbaB646D9013f2699BebEf62B7e7d7F0976",
"validator-wallet-creator": "0xe05465Aab36ba1277dAE36aa27a7B74830e74DE4",
"stake-token": "0x765277eebeca2e31912c9946eae1021199b39c61",
"deployed-at": 15016829
}
},
Expand Down
1 change: 1 addition & 0 deletions cmd/chaininfo/chain_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@ type RollupAddresses struct {
UpgradeExecutor common.Address `json:"upgrade-executor"`
ValidatorUtils common.Address `json:"validator-utils"`
ValidatorWalletCreator common.Address `json:"validator-wallet-creator"`
StakeToken common.Address `json:"stake-token"`
DeployedAt uint64 `json:"deployed-at"`
}
8 changes: 4 additions & 4 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import (
"github.com/offchainlabs/nitro/solgen/go/bridgegen"
"github.com/offchainlabs/nitro/solgen/go/precompilesgen"
"github.com/offchainlabs/nitro/solgen/go/rollupgen"
"github.com/offchainlabs/nitro/staker"
legacystaker "github.com/offchainlabs/nitro/staker/legacy"
"github.com/offchainlabs/nitro/staker/validatorwallet"
"github.com/offchainlabs/nitro/util/colors"
"github.com/offchainlabs/nitro/util/dbutil"
Expand Down Expand Up @@ -257,7 +257,7 @@ func mainImpl() int {
defaultL1WalletConfig.ResolveDirectoryNames(nodeConfig.Persistent.Chain)

nodeConfig.Node.Staker.ParentChainWallet.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
defaultValidatorL1WalletConfig := staker.DefaultValidatorL1WalletConfig
defaultValidatorL1WalletConfig := legacystaker.DefaultValidatorL1WalletConfig
defaultValidatorL1WalletConfig.ResolveDirectoryNames(nodeConfig.Persistent.Chain)

nodeConfig.Node.BatchPoster.ParentChainWallet.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
Expand Down Expand Up @@ -290,11 +290,11 @@ func mainImpl() int {
flag.Usage()
log.Crit("validator must have the parent chain reader enabled")
}
strategy, err := nodeConfig.Node.Staker.ParseStrategy()
strategy, err := legacystaker.ParseStrategy(nodeConfig.Node.Staker.Strategy)
if err != nil {
log.Crit("couldn't parse staker strategy", "err", err)
}
if strategy != staker.WatchtowerStrategy && !nodeConfig.Node.Staker.Dangerous.WithoutBlockValidator {
if strategy != legacystaker.WatchtowerStrategy && !nodeConfig.Node.Staker.Dangerous.WithoutBlockValidator {
nodeConfig.Node.BlockValidator.Enable = true
}
}
Expand Down
Loading

0 comments on commit a5e169c

Please sign in to comment.