-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into redis_sentinel
- Loading branch information
Showing
18 changed files
with
1,447 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: 0.2 | ||
|
||
phases: | ||
pre_build: | ||
commands: | ||
- git submodule update --init | ||
- echo Logging in to Dockerhub.... | ||
- docker login --username $DOCKERHUB_USERNAME --password $DOCKERHUB_PASSWORD | ||
- aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin $REPOSITORY_URI | ||
- COMMIT_HASH=$(git rev-parse --short=7 HEAD || echo "latest") | ||
- VERSION_TAG=$(git tag --points-at HEAD | sed '/-/!s/$/_/' | sort -rV | sed 's/_$//' | head -n 1 | grep ^ || git show -s --pretty=%D | sed 's/, /\n/g' | grep -v '^origin/' |grep -v '^grafted\|HEAD\|master\|main$' || echo "dev") | ||
- NITRO_VERSION=${VERSION_TAG}-${COMMIT_HASH} | ||
- IMAGE_TAG=${NITRO_VERSION} | ||
- NITRO_DATETIME=$(git show -s --date=iso-strict --format=%cd) | ||
- NITRO_MODIFIED="false" | ||
- echo ${NITRO_VERSION} > ./.nitro-tag.txt | ||
build: | ||
commands: | ||
- echo Build started on `date` | ||
- echo Building the Docker image ${NITRO_VERSION}... | ||
- DOCKER_BUILDKIT=1 docker build . -t nitro-node-slim --target nitro-node-slim --build-arg version=$NITRO_VERSION --build-arg datetime=$NITRO_DATETIME --build-arg modified=$NITRO_MODIFIED | ||
- DOCKER_BUILDKIT=1 docker build . -t nitro-node --target nitro-node --build-arg version=$NITRO_VERSION --build-arg datetime=$NITRO_DATETIME --build-arg modified=$NITRO_MODIFIED | ||
- DOCKER_BUILDKIT=1 docker build . -t nitro-node-dev --target nitro-node-dev --build-arg version=$NITRO_VERSION --build-arg datetime=$NITRO_DATETIME --build-arg modified=$NITRO_MODIFIED | ||
- DOCKER_BUILDKIT=1 docker build . -t nitro-node-validator --target nitro-node-validator --build-arg version=$NITRO_VERSION --build-arg datetime=$NITRO_DATETIME --build-arg modified=$NITRO_MODIFIED | ||
- docker tag nitro-node:latest $REPOSITORY_URI:$IMAGE_TAG-$ARCH_TAG | ||
- docker tag nitro-node-slim:latest $REPOSITORY_URI:$IMAGE_TAG-slim-$ARCH_TAG | ||
- docker tag nitro-node-dev:latest $REPOSITORY_URI:$IMAGE_TAG-dev-$ARCH_TAG | ||
- docker tag nitro-node-validator:latest $REPOSITORY_URI:$IMAGE_TAG-validator-$ARCH_TAG | ||
post_build: | ||
commands: | ||
- echo Build completed on `date` | ||
- echo pushing to repo | ||
- docker push $REPOSITORY_URI:$IMAGE_TAG-$ARCH_TAG | ||
- docker push $REPOSITORY_URI:$IMAGE_TAG-slim-$ARCH_TAG | ||
- docker push $REPOSITORY_URI:$IMAGE_TAG-dev-$ARCH_TAG | ||
- docker push $REPOSITORY_URI:$IMAGE_TAG-validator-$ARCH_TAG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
// Copyright 2021-2024, Offchain Labs, Inc. | ||
// For license information, see https://github.com/nitro/blob/master/LICENSE | ||
|
||
package precompiles | ||
|
||
import ( | ||
"math/big" | ||
"testing" | ||
|
||
"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/arbos/arbosState" | ||
"github.com/offchainlabs/nitro/arbos/burn" | ||
"github.com/offchainlabs/nitro/arbos/storage" | ||
"github.com/offchainlabs/nitro/arbos/util" | ||
"github.com/offchainlabs/nitro/util/testhelpers" | ||
) | ||
|
||
func setupArbGasInfo( | ||
t *testing.T, | ||
) ( | ||
*vm.EVM, | ||
*arbosState.ArbosState, | ||
*Context, | ||
*ArbGasInfo, | ||
) { | ||
evm := newMockEVMForTesting() | ||
caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) | ||
tracer := util.NewTracingInfo(evm, testhelpers.RandomAddress(), types.ArbosAddress, util.TracingDuringEVM) | ||
state, err := arbosState.OpenArbosState(evm.StateDB, burn.NewSystemBurner(tracer, false)) | ||
Require(t, err) | ||
|
||
arbGasInfo := &ArbGasInfo{} | ||
callCtx := testContext(caller, evm) | ||
|
||
return evm, state, callCtx, arbGasInfo | ||
} | ||
|
||
func TestGetGasBacklog(t *testing.T) { | ||
t.Parallel() | ||
|
||
evm, state, callCtx, arbGasInfo := setupArbGasInfo(t) | ||
|
||
backlog := uint64(1000) | ||
err := state.L2PricingState().SetGasBacklog(backlog) | ||
Require(t, err) | ||
retrievedBacklog, err := arbGasInfo.GetGasBacklog(callCtx, evm) | ||
Require(t, err) | ||
if retrievedBacklog != backlog { | ||
t.Fatal("expected backlog to be", backlog, "but got", retrievedBacklog) | ||
} | ||
} | ||
|
||
func TestGetL1PricingUpdateTime(t *testing.T) { | ||
t.Parallel() | ||
|
||
evm, state, callCtx, arbGasInfo := setupArbGasInfo(t) | ||
|
||
lastUpdateTime := uint64(1001) | ||
err := state.L1PricingState().SetLastUpdateTime(lastUpdateTime) | ||
Require(t, err) | ||
retrievedLastUpdateTime, err := arbGasInfo.GetLastL1PricingUpdateTime(callCtx, evm) | ||
Require(t, err) | ||
if retrievedLastUpdateTime != lastUpdateTime { | ||
t.Fatal("expected last update time to be", lastUpdateTime, "but got", retrievedLastUpdateTime) | ||
} | ||
} | ||
|
||
func TestGetL1PricingFundsDueForRewards(t *testing.T) { | ||
t.Parallel() | ||
|
||
evm, state, callCtx, arbGasInfo := setupArbGasInfo(t) | ||
|
||
fundsDueForRewards := big.NewInt(1002) | ||
err := state.L1PricingState().SetFundsDueForRewards(fundsDueForRewards) | ||
Require(t, err) | ||
retrievedFundsDueForRewards, err := arbGasInfo.GetL1PricingFundsDueForRewards(callCtx, evm) | ||
Require(t, err) | ||
if retrievedFundsDueForRewards.Cmp(fundsDueForRewards) != 0 { | ||
t.Fatal("expected funds due for rewards to be", fundsDueForRewards, "but got", retrievedFundsDueForRewards) | ||
} | ||
} | ||
|
||
func TestGetL1PricingUnitsSinceUpdate(t *testing.T) { | ||
t.Parallel() | ||
|
||
evm, state, callCtx, arbGasInfo := setupArbGasInfo(t) | ||
|
||
pricingUnitsSinceUpdate := uint64(1003) | ||
err := state.L1PricingState().SetUnitsSinceUpdate(pricingUnitsSinceUpdate) | ||
Require(t, err) | ||
retrievedPricingUnitsSinceUpdate, err := arbGasInfo.GetL1PricingUnitsSinceUpdate(callCtx, evm) | ||
Require(t, err) | ||
if retrievedPricingUnitsSinceUpdate != pricingUnitsSinceUpdate { | ||
t.Fatal("expected pricing units since update to be", pricingUnitsSinceUpdate, "but got", retrievedPricingUnitsSinceUpdate) | ||
} | ||
} | ||
|
||
func TestGetLastL1PricingSurplus(t *testing.T) { | ||
t.Parallel() | ||
|
||
evm, state, callCtx, arbGasInfo := setupArbGasInfo(t) | ||
|
||
lastSurplus := big.NewInt(1004) | ||
err := state.L1PricingState().SetLastSurplus(lastSurplus, params.ArbosVersion_Stylus) | ||
Require(t, err) | ||
retrievedLastSurplus, err := arbGasInfo.GetLastL1PricingSurplus(callCtx, evm) | ||
Require(t, err) | ||
if retrievedLastSurplus.Cmp(lastSurplus) != 0 { | ||
t.Fatal("expected last surplus to be", lastSurplus, "but got", retrievedLastSurplus) | ||
} | ||
} | ||
|
||
func TestGetPricesInArbGas(t *testing.T) { | ||
t.Parallel() | ||
|
||
evm := newMockEVMForTesting() | ||
caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) | ||
arbGasInfo := &ArbGasInfo{} | ||
callCtx := testContext(caller, evm) | ||
|
||
evm.Context.BaseFee = big.NewInt(1005) | ||
expectedGasPerL2Tx := big.NewInt(111442786069) | ||
expectedGasForL1Calldata := big.NewInt(796019900) | ||
expectedStorageArbGas := big.NewInt(int64(storage.StorageWriteCost)) | ||
gasPerL2Tx, gasForL1Calldata, storageArbGas, err := arbGasInfo.GetPricesInArbGas(callCtx, evm) | ||
Require(t, err) | ||
if gasPerL2Tx.Cmp(expectedGasPerL2Tx) != 0 { | ||
t.Fatal("expected gas per L2 tx to be", expectedGasPerL2Tx, "but got", gasPerL2Tx) | ||
} | ||
if gasForL1Calldata.Cmp(expectedGasForL1Calldata) != 0 { | ||
t.Fatal("expected gas for L1 calldata to be", expectedGasForL1Calldata, "but got", gasForL1Calldata) | ||
} | ||
if storageArbGas.Cmp(expectedStorageArbGas) != 0 { | ||
t.Fatal("expected storage arb gas to be", expectedStorageArbGas, "but got", storageArbGas) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.