Skip to content

Commit

Permalink
small
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan committed Oct 24, 2023
1 parent 44dc1d7 commit 65c5cc8
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 31 deletions.
2 changes: 1 addition & 1 deletion bold
1 change: 1 addition & 0 deletions cmd/bold-deploy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ func main() {
Rollup: deployedAddresses.Rollup,
ValidatorUtils: deployedAddresses.ValidatorUtils,
ValidatorWalletCreator: deployedAddresses.ValidatorWalletCreator,
StakeToken: stakeToken,
DeployedAt: deployedAddresses.DeployedAt,
},
},
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 @@ -108,5 +108,6 @@ type RollupAddresses struct {
Rollup common.Address `json:"rollup"`
ValidatorUtils common.Address `json:"validator-utils"`
ValidatorWalletCreator common.Address `json:"validator-wallet-creator"`
StakeToken common.Address `json:"stake-token"`
DeployedAt uint64 `json:"deployed-at"`
}
25 changes: 1 addition & 24 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func mainImpl() int {
var l1TransactionOptsValidator *bind.TransactOpts
var l1TransactionOptsBatchPoster *bind.TransactOpts
sequencerNeedsKey := (nodeConfig.Node.Sequencer && !nodeConfig.Node.Feed.Output.DisableSigning) || nodeConfig.Node.BatchPoster.Enable
validatorNeedsKey := nodeConfig.Node.Staker.OnlyCreateWalletContract || nodeConfig.Node.Staker.Enable && !strings.EqualFold(nodeConfig.Node.Staker.Strategy, "watchtower")
validatorNeedsKey := nodeConfig.Node.Staker.OnlyCreateWalletContract || nodeConfig.Node.Bold.Enable || nodeConfig.Node.Staker.Enable && !strings.EqualFold(nodeConfig.Node.Staker.Strategy, "watchtower")

l1Wallet.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
defaultL1WalletConfig := conf.DefaultL1WalletConfig
Expand Down Expand Up @@ -282,29 +282,6 @@ func mainImpl() int {
}
}

if nodeConfig.Node.Bold.Enable {
if nodeConfig.Node.Bold.Evil {
validatorPrivateKey, err := crypto.HexToECDSA("dc04c5399f82306ec4b4d654a342f40e2e0620fe39950d967e1e574b32d4dd36")
if err != nil {
log.Crit("Failed to get privkey for validator", "err", err)
}
validatorTxOpts, err := bind.NewKeyedTransactorWithChainID(validatorPrivateKey, new(big.Int).SetUint64(nodeConfig.ParentChain.ID))
if err != nil {
log.Crit("Failed to get validator tx opts", "err", err)
}
l1TransactionOptsValidator = validatorTxOpts
} else {
validatorPrivateKey, err := crypto.HexToECDSA("182fecf15bdf909556a0f617a63e05ab22f1493d25a9f1e27c228266c772a890")
if err != nil {
log.Crit("Failed to get privkey for validator", "err", err)
}
validatorTxOpts, err := bind.NewKeyedTransactorWithChainID(validatorPrivateKey, new(big.Int).SetUint64(nodeConfig.ParentChain.ID))
if err != nil {
log.Crit("Failed to get validator tx opts", "err", err)
}
l1TransactionOptsValidator = validatorTxOpts
}
}
combinedL2ChainInfoFile := nodeConfig.Chain.InfoFiles
if nodeConfig.Chain.InfoIpfsUrl != "" {
l2ChainInfoIpfsFile, err := util.GetL2ChainInfoIpfsFile(ctx, nodeConfig.Chain.InfoIpfsUrl, nodeConfig.Chain.InfoIpfsDownloadPath)
Expand Down
2 changes: 1 addition & 1 deletion nitro-testnode
4 changes: 2 additions & 2 deletions staker/state_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ func (s *StateManager) CollectMachineHashes(
) ([]common.Hash, error) {
s.Lock()
defer s.Unlock()
prevBatchMsgCount, err := s.validator.inboxTracker.GetBatchMessageCount(uint64(cfg.FromBatch) - 1)
prevBatchMsgCount, err := s.validator.inboxTracker.GetBatchMessageCount(uint64(cfg.FromBatch - 1))
if err != nil {
return nil, err
return nil, fmt.Errorf("could not get batch message count at %d: %w", cfg.FromBatch, err)
}
messageNum := (prevBatchMsgCount + arbutil.MessageIndex(cfg.BlockChallengeHeight))
cacheKey := &challengecache.Key{
Expand Down
3 changes: 0 additions & 3 deletions staker/stateless_block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ func (v *StatelessBlockValidator) ValidationEntryRecord(ctx context.Context, e *
}
if e.HasDelayedMsg {
if v.config.Evil {
fmt.Println("Got evil block validator")
chainId, ok := new(big.Int).SetString(v.config.ChainId, 10)
if !ok {
return errors.New("bad chainid")
Expand All @@ -297,7 +296,6 @@ func (v *StatelessBlockValidator) ValidationEntryRecord(ctx context.Context, e *
)
return fmt.Errorf("error while trying to read delayed msg for proving: %w", err)
}
fmt.Printf("Encoded delayed L2: %#x\n", delayedMsg.L2msg)

txes, err := arbos.ParseL2Transactions(delayedMsg, chainId, nil)
if err != nil {
Expand Down Expand Up @@ -460,7 +458,6 @@ func (v *StatelessBlockValidator) CreateReadyValidationEntry(ctx context.Context
if err != nil {
return nil, err
}
fmt.Printf("Building validation run: start %+v, end %+v, pos %d...start pos %d end pos %d\n", start, end, pos, startPos, endPos)
entry, err := newValidationEntry(pos, start, end, msg, seqMsg, prevDelayed)
if err != nil {
return nil, err
Expand Down
60 changes: 60 additions & 0 deletions tools/bold-challenges/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package main

Check failure on line 1 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

: # github.com/offchainlabs/nitro/tools/bold-challenges

Check failure on line 1 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

: # github.com/offchainlabs/nitro/tools/bold-challenges

Check failure on line 1 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

: # github.com/offchainlabs/nitro/tools/bold-challenges

import (
"math/big"

solimpl "github.com/OffchainLabs/bold/chain-abstraction/sol-implementation"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/crypto"
)

func main() {
validatorPrivateKey, err := crypto.HexToECDSA("182fecf15bdf909556a0f617a63e05ab22f1493d25a9f1e27c228266c772a890")
if err != nil {
panic(err)
}
validatorTxOpts, err := bind.NewKeyedTransactorWithChainID(validatorPrivateKey, l1ChainId)

Check failure on line 16 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: l1ChainId

Check failure on line 16 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: l1ChainId

Check failure on line 16 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: l1ChainId
if err != nil {
panic(err)
}
mintTokens, ok := new(big.Int).SetString("10000", 10)
if !ok {
panic("could not set stake token value")
}
l1TransactionOpts.Value = mintTokens

Check failure on line 24 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: l1TransactionOpts

Check failure on line 24 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: l1TransactionOpts

Check failure on line 24 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: l1TransactionOpts
tx, err = tokenBindings.Deposit(l1TransactionOpts)

Check failure on line 25 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: tx

Check failure on line 25 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: tokenBindings

Check failure on line 25 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: l1TransactionOpts

Check failure on line 25 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: tx

Check failure on line 25 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: tokenBindings

Check failure on line 25 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: l1TransactionOpts

Check failure on line 25 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: tx

Check failure on line 25 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: tokenBindings

Check failure on line 25 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: l1TransactionOpts
if err != nil {
panic(err)
}

// We then have the validator itself authorize the rollup and challenge manager
// contracts to spend its stake tokens.
chain, err := solimpl.NewAssertionChain(
ctx,

Check failure on line 33 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: ctx

Check failure on line 33 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: ctx

Check failure on line 33 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: ctx
deployedAddresses.Rollup,

Check failure on line 34 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: deployedAddresses

Check failure on line 34 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: deployedAddresses

Check failure on line 34 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: deployedAddresses
validatorTxOpts,
l1Reader.Client(),

Check failure on line 36 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: l1Reader

Check failure on line 36 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: l1Reader

Check failure on line 36 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: l1Reader
)
if err != nil {
panic(err)
}
chalManager, err := chain.SpecChallengeManager(ctx)

Check failure on line 41 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: ctx

Check failure on line 41 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: ctx

Check failure on line 41 in tools/bold-challenges/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: ctx
if err != nil {
panic(err)
}
amountToApproveSpend, ok := new(big.Int).SetString("10000", 10)
if !ok {
panic("not ok")
}
tx, err = tokenBindings.TestWETH9Transactor.Approve(validatorTxOpts, deployedAddresses.Rollup, amountToApproveSpend)
if err != nil {
panic(err)
}
ensureTxSucceeds(tx)
tx, err = tokenBindings.TestWETH9Transactor.Approve(validatorTxOpts, chalManager.Address(), amountToApproveSpend)
if err != nil {
panic(err)
}
ensureTxSucceeds(tx)

}

0 comments on commit 65c5cc8

Please sign in to comment.