Skip to content

Commit

Permalink
Merge branch 'master' into snap_sync
Browse files Browse the repository at this point in the history
  • Loading branch information
amsanghi authored May 13, 2024
2 parents c57bbae + 28033f9 commit b22cf8f
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 19 deletions.
32 changes: 18 additions & 14 deletions arbnode/dataposter/data_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,21 +844,25 @@ func (p *DataPoster) sendTx(ctx context.Context, prevTx *storage.QueuedTransacti
if err != nil {
return fmt.Errorf("couldn't get preceding tx in DataPoster to check if should send tx with nonce %d: %w", newTx.FullTx.Nonce(), err)
}
if precedingTx != nil && // precedingTx == nil -> the actual preceding tx was already confirmed
(precedingTx.FullTx.Type() != newTx.FullTx.Type() || !precedingTx.Sent) {
latestBlockNumber, err := p.client.BlockNumber(ctx)
if err != nil {
return fmt.Errorf("couldn't get block number in DataPoster to check if should send tx with nonce %d: %w", newTx.FullTx.Nonce(), err)
}
prevBlockNumber := arbmath.SaturatingUSub(latestBlockNumber, 1)
reorgResistantNonce, err := p.client.NonceAt(ctx, p.Sender(), new(big.Int).SetUint64(prevBlockNumber))
if err != nil {
return fmt.Errorf("couldn't determine reorg resistant nonce in DataPoster to check if should send tx with nonce %d: %w", newTx.FullTx.Nonce(), err)
}
if precedingTx != nil { // precedingTx == nil -> the actual preceding tx was already confirmed
var latestBlockNumber, prevBlockNumber, reorgResistantNonce uint64
if precedingTx.FullTx.Type() != newTx.FullTx.Type() || !precedingTx.Sent {
latestBlockNumber, err = p.client.BlockNumber(ctx)
if err != nil {
return fmt.Errorf("couldn't get block number in DataPoster to check if should send tx with nonce %d: %w", newTx.FullTx.Nonce(), err)
}
prevBlockNumber = arbmath.SaturatingUSub(latestBlockNumber, 1)
reorgResistantNonce, err = p.client.NonceAt(ctx, p.Sender(), new(big.Int).SetUint64(prevBlockNumber))
if err != nil {
return fmt.Errorf("couldn't determine reorg resistant nonce in DataPoster to check if should send tx with nonce %d: %w", newTx.FullTx.Nonce(), err)
}

if precedingTx.FullTx.Nonce() > reorgResistantNonce {
log.Info("DataPoster is avoiding creating a mempool nonce gap (the tx remains queued and will be retried)", "nonce", newTx.FullTx.Nonce(), "prevType", precedingTx.FullTx.Type(), "type", newTx.FullTx.Type(), "prevSent", precedingTx.Sent)
return nil
if precedingTx.FullTx.Nonce() > reorgResistantNonce {
log.Info("DataPoster is avoiding creating a mempool nonce gap (the tx remains queued and will be retried)", "nonce", newTx.FullTx.Nonce(), "prevType", precedingTx.FullTx.Type(), "type", newTx.FullTx.Type(), "prevSent", precedingTx.Sent)
return nil
}
} else {
log.Info("DataPoster will send previously unsent batch tx", "nonce", newTx.FullTx.Nonce(), "prevType", precedingTx.FullTx.Type(), "type", newTx.FullTx.Type(), "prevSent", precedingTx.Sent, "latestBlockNumber", latestBlockNumber, "prevBlockNumber", prevBlockNumber, "reorgResistantNonce", reorgResistantNonce)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
Submodule go-ethereum updated 111 files
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ require (
github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
github.com/fjl/memsize v0.0.2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gammazero/deque v0.2.1 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
Expand Down
27 changes: 27 additions & 0 deletions system_tests/outbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,41 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
"github.com/offchainlabs/nitro/gethhook"
"github.com/offchainlabs/nitro/solgen/go/node_interfacegen"
"github.com/offchainlabs/nitro/solgen/go/precompilesgen"
"github.com/offchainlabs/nitro/util/arbmath"
"github.com/offchainlabs/nitro/util/merkletree"
)

func TestP256VerifyEnabled(t *testing.T) {
gethhook.RequireHookedGeth()
for _, tc := range []struct {
stylusEnabled bool
wantP256Verify bool
}{
{
stylusEnabled: false,
wantP256Verify: false,
},
{
stylusEnabled: true,
wantP256Verify: true,
},
} {
got := false
for _, a := range vm.ActivePrecompiles(params.Rules{IsStylus: tc.stylusEnabled}) {
got = got || (a == common.BytesToAddress([]byte{0x01, 0x00}))
}
if got != tc.wantP256Verify {
t.Errorf("Got P256Verify enabled: %t, want: %t", got, tc.wantP256Verify)
}
}
}

func TestOutboxProofs(t *testing.T) {
t.Parallel()
gethhook.RequireHookedGeth()
Expand Down
46 changes: 46 additions & 0 deletions system_tests/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
package arbtest

import (
"bytes"
"context"
"fmt"
"math/big"
"testing"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
)

func TestTransfer(t *testing.T) {
Expand Down Expand Up @@ -36,3 +40,45 @@ func TestTransfer(t *testing.T) {
Fatal(t, "Unexpected recipient balance: ", bal2)
}
}

func TestP256Verify(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
for _, tc := range []struct {
desc string
initialVersion uint64
want []byte
}{
{
desc: "p256 should not be enabled on arbOS 20",
initialVersion: 20,
want: nil,
},
{
desc: "p256 should be enabled on arbOS 20",
initialVersion: 30,
want: common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"),
},
} {
t.Run(tc.desc, func(t *testing.T) {
builder := NewNodeBuilder(ctx).DefaultConfig(t, false)
builder.chainConfig.ArbitrumChainParams.InitialArbOSVersion = tc.initialVersion
cleanup := builder.Build(t)
defer cleanup()
addr := common.BytesToAddress([]byte{0x01, 0x00})
got, err := builder.L2.Client.CallContract(ctx, ethereum.CallMsg{
From: builder.L2Info.GetAddress("Owner"),
To: &addr,
Gas: builder.L2Info.TransferGas,
Data: common.Hex2Bytes("4cee90eb86eaa050036147a12d49004b6b9c72bd725d39d4785011fe190f0b4da73bd4903f0ce3b639bbbf6e8e80d16931ff4bcf5993d58468e8fb19086e8cac36dbcd03009df8c59286b162af3bd7fcc0450c9aa81be5d10d312af6c66b1d604aebd3099c618202fcfe16ae7770b0c49ab5eadf74b754204a3bb6060e44eff37618b065f9832de4ca6ca971a7a1adc826d0f7c00181a5fb2ddf79ae00b4e10e"),
Value: big.NewInt(1e12),
}, nil)
if err != nil {
t.Fatalf("CallContract() unexpected error: %v", err)
}
if !bytes.Equal(got, tc.want) {
t.Errorf("P256Verify() = %v, want: %v", got, tc.want)
}
})
}
}
5 changes: 4 additions & 1 deletion validator/server_jit/machine_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ var DefaultJitMachineConfig = JitMachineConfig{
func getJitPath() (string, error) {
var jitBinary string
executable, err := os.Executable()
println("executable: ", executable)
if err == nil {
if strings.Contains(filepath.Base(executable), "test") {
if strings.Contains(filepath.Base(executable), "test") || strings.Contains(filepath.Dir(executable), "system_tests") {
_, thisfile, _, _ := runtime.Caller(0)
projectDir := filepath.Dir(filepath.Dir(filepath.Dir(thisfile)))
println("projectDir: ", projectDir)
jitBinary = filepath.Join(projectDir, "target", "bin", "jit")
} else {
jitBinary = filepath.Join(filepath.Dir(executable), "jit")
println("inside else: ", jitBinary)
}
_, err = os.Stat(jitBinary)
}
Expand Down

0 comments on commit b22cf8f

Please sign in to comment.