Skip to content

Commit

Permalink
sync upstream v0.5.7-v0.5.8 (eccd2ee)
Browse files Browse the repository at this point in the history
  • Loading branch information
atvanguard committed Oct 27, 2023
2 parents 1e27a82 + eccd2ee commit 319cf27
Show file tree
Hide file tree
Showing 120 changed files with 3,304 additions and 2,711 deletions.
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Please make sure your contributions adhere to our coding and documentation
guidelines:

- Code must adhere to the official Go
[formatting](https://golang.org/doc/effective_go.html#formatting) guidelines
(i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
[formatting](https://go.dev/doc/effective_go#formatting) guidelines
(i.e. uses [gofmt](https://pkg.go.dev/cmd/gofmt)).
- Pull requests need to be based on and opened against the `master` branch.
- Pull reuqests should include a detailed description
- Commits are required to be signed. See [here](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)
Expand All @@ -32,7 +32,7 @@ guidelines:
- Code should be well commented, so it is easier to read and maintain.
Any complex sections or invariants should be documented explicitly.
- Code must be documented adhering to the official Go
[commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
[commentary](https://go.dev/doc/effective_go#commentary) guidelines.
- Changes with user facing impact (e.g., addition or modification of flags and
options) should be accompanied by a link to a pull request to the [avalanche-docs](https://github.com/ava-labs/avalanche-docs)
repository. [example](https://github.com/ava-labs/avalanche-docs/pull/1119/files).
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/release_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ Link the relevant documentation PRs for this release.
- [ ] Update AvalancheGo dependency in scripts/versions.sh for e2e tests.
- [ ] Add new entry in compatibility.json for RPCChainVM Compatibility
- [ ] Update AvalancheGo compatibility in README
- [ ] Deploy to WAGMI
- [ ] Confirm goreleaser job has successfully generated binaries by checking the releases page
2 changes: 1 addition & 1 deletion .github/workflows/auto-generated-code-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '~1.20.8'
go-version: '~1.20.10'
check-latest: true
- shell: bash
run: scripts/mock.gen.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '~1.20.8'
go-version: '~1.20.10'
check-latest: true
- run: go mod download
shell: bash
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
shell: bash
- uses: actions/setup-go@v3
with:
go-version: '~1.20.8'
go-version: '~1.20.10'
check-latest: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.51
version: v1.54
working-directory: .
args: --timeout 10m

Expand All @@ -34,7 +34,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '~1.20.8'
go-version: '~1.20.10'
check-latest: true
- run: go mod download
shell: bash
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '~1.20.8'
go-version: '~1.20.10'
check-latest: true
- name: Use Node.js
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '~1.20.8'
go-version: '~1.20.10'
check-latest: true
- name: Set up arm64 cross compiler
run: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ARG AVALANCHE_VERSION

# ============= Compilation Stage ================
FROM golang:1.20.8-bullseye AS builder
FROM golang:1.20.10-bullseye AS builder

WORKDIR /build

Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ The Subnet EVM runs in a separate process from the main AvalancheGo process and
[v0.5.1] [email protected] (Protocol Version: 26)
[v0.5.2] [email protected] (Protocol Version: 26)
[v0.5.3] [email protected] (Protocol Version: 27)
[v0.5.4] [email protected] (Protocol Version: 28)
[v0.5.5] [email protected] (Protocol Version: 28)
[v0.5.6] [email protected] (Protocol Version: 28)
[v0.5.4] [email protected] (Protocol Version: 28)
[v0.5.5] [email protected] (Protocol Version: 28)
[v0.5.6] [email protected] (Protocol Version: 28)
[v0.5.7] [email protected] (Protocol Version: 29)
[v0.5.8] [email protected] (Protocol Version: 29)
```

## API
Expand All @@ -77,11 +79,12 @@ The Subnet EVM supports the following API namespaces:
- `debug`

Only the `eth` namespace is enabled by default.
Full documentation for the C-Chain's API can be found [here.](https://docs.avax.network/apis/avalanchego/apis/c-chain)
Subnet EVM is a simplified version of [Coreth VM (C-Chain)](https://github.com/ava-labs/coreth).
Full documentation for the C-Chain's API can be found [here](https://docs.avax.network/apis/avalanchego/apis/c-chain).

## Compatibility

The Subnet EVM is compatible with almost all Ethereum tooling, including [Remix](https://docs.avax.network/dapps/smart-contracts/deploy-a-smart-contract-on-avalanche-using-remix-and-metamask/), [Metamask](https://docs.avax.network/dapps/smart-contracts/deploy-a-smart-contract-on-avalanche-using-remix-and-metamask/) and [Truffle](https://docs.avax.network/dapps/smart-contracts/using-truffle-with-the-avalanche-c-chain/).
The Subnet EVM is compatible with almost all Ethereum tooling, including [Remix](https://docs.avax.network/build/dapp/smart-contracts/remix-deploy), [Metamask](https://docs.avax.network/build/dapp/chain-settings), and [Foundry](https://docs.avax.network/build/dapp/smart-contracts/toolchains/foundry).

## Differences Between Subnet EVM and Coreth

Expand All @@ -103,9 +106,9 @@ To support these changes, there have been a number of changes to the SubnetEVM b

### Clone Subnet-evm

First install Go 1.20.8 or later. Follow the instructions [here](https://golang.org/doc/install). You can verify by running `go version`.
First install Go 1.20.10 or later. Follow the instructions [here](https://go.dev/doc/install). You can verify by running `go version`.

Set `$GOPATH` environment variable properly for Go to look for Go Workspaces. Please read [this](https://go.dev/doc/gopath_code) for details. You can verify by running `echo $GOPATH`.
Set `$GOPATH` environment variable properly for Go to look for Go Workspaces. Please read [this](https://go.dev/doc/code) for details. You can verify by running `echo $GOPATH`.

As a few software will be installed into `$GOPATH/bin`, please make sure that `$GOPATH/bin` is in your `$PATH`, otherwise, you may get error running the commands below.

Expand Down
1 change: 0 additions & 1 deletion accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2063,7 +2063,6 @@ func TestGolangBindingsOverload(t *testing.T) {
}

func TestGolangBindings(t *testing.T) {
t.Skip("FLAKY")
golangBindings(t, false)
}

Expand Down
4 changes: 2 additions & 2 deletions accounts/abi/bind/precompilebind/precompile_bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func TestPrecompileBind(t *testing.T) {
// Create a temporary workspace for the test suite
ws := t.TempDir()

pkg := filepath.Join(ws, "bindtest")
pkg := filepath.Join(ws, "precompilebindtest")
if err := os.MkdirAll(pkg, 0o700); err != nil {
t.Fatalf("failed to create package: %v", err)
}
Expand Down Expand Up @@ -581,7 +581,7 @@ func TestPrecompileBind(t *testing.T) {
})
}

moder := exec.Command(gocmd, "mod", "init", "bindtest")
moder := exec.Command(gocmd, "mod", "init", "precompilebindtest")
moder.Dir = pkg
if out, err := moder.CombinedOutput(); err != nil {
t.Fatalf("failed to convert binding test to modules: %v\n%s", err, out)
Expand Down
11 changes: 8 additions & 3 deletions accounts/abi/bind/precompilebind/precompile_module_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,20 @@ func (*configurator) MakeConfig() precompileconfig.Config {
// You can use this function to set up your precompile contract's initial state,
// by using the [cfg] config and [state] stateDB.
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockContext contract.ConfigurationBlockContext) error {
// CUSTOM CODE STARTS HERE
{{- if .Contract.AllowList}}
config, ok := cfg.(*Config)
if !ok {
return fmt.Errorf("incorrect config %T: %v", config, config)
return fmt.Errorf("expected config type %T, got %T: %v", &Config{}, cfg, cfg)
}
// CUSTOM CODE STARTS HERE
{{- if .Contract.AllowList}}
// AllowList is activated for this precompile. Configuring allowlist addresses here.
return config.AllowListConfig.Configure(chainConfig, ContractAddress, state, blockContext)
{{- else}}
if _, ok := cfg.(*Config); !ok {
return fmt.Errorf("expected config type %T, got %T: %v", &Config{}, cfg, cfg)
}
return nil
{{- end}}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (i *bbInput) ToBlock() *types.Block {
if i.Header.Nonce != nil {
header.Nonce = *i.Header.Nonce
}
if header.Difficulty != nil {
if i.Header.Difficulty != nil {
header.Difficulty = i.Header.Difficulty
}
return types.NewBlockWithHeader(header).WithBody(i.Txs, i.Ommers)
Expand Down
2 changes: 2 additions & 0 deletions compatibility.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"rpcChainVMProtocolVersion": {
"v0.5.8": 29,
"v0.5.7": 29,
"v0.5.6": 28,
"v0.5.5": 28,
"v0.5.4": 28,
Expand Down
9 changes: 3 additions & 6 deletions consensus/dummy/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ func (self *DummyEngine) verifyHeaderGasFields(config *params.ChainConfig, heade

// modified from consensus.go
func (self *DummyEngine) verifyHeader(chain consensus.ChainHeaderReader, header *types.Header, parent *types.Header, uncle bool) error {
var (
config = chain.Config()
)
config := chain.Config()
// Ensure that we do not verify an uncle
if uncle {
return errUnclesUnsupported
Expand All @@ -205,9 +203,8 @@ func (self *DummyEngine) verifyHeader(chain consensus.ChainHeaderReader, header
return fmt.Errorf("expected extra-data field length >= %d, found %d", params.DynamicFeeExtraDataSize, len(header.Extra))
}
case config.IsSubnetEVM(header.Time):
expectedExtraDataSize := params.DynamicFeeExtraDataSize
if len(header.Extra) != expectedExtraDataSize {
return fmt.Errorf("expected extra-data field to be: %d, but found %d", expectedExtraDataSize, len(header.Extra))
if len(header.Extra) != params.DynamicFeeExtraDataSize {
return fmt.Errorf("expected extra-data field to be: %d, but found %d", params.DynamicFeeExtraDataSize, len(header.Extra))
}
default:
if uint64(len(header.Extra)) > params.MaximumExtraDataSize {
Expand Down
118 changes: 50 additions & 68 deletions contracts/contracts/ExampleWarp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,54 @@ pragma experimental ABIEncoderV2;
import "./interfaces/IWarpMessenger.sol";

contract ExampleWarp {
address constant WARP_ADDRESS = 0x0200000000000000000000000000000000000005;
WarpMessenger warp = WarpMessenger(WARP_ADDRESS);

// sendWarpMessage sends a warp message to the specified destination chain and address pair containing the payload
function sendWarpMessage(
bytes32 destinationChainID,
address destinationAddress,
bytes calldata payload
) external {
warp.sendWarpMessage(destinationChainID, destinationAddress, payload);
}

// validateWarpMessage retrieves the warp message attached to the transaction and verifies all of its attributes.
function validateWarpMessage(
uint32 index,
bytes32 sourceChainID,
address originSenderAddress,
bytes32 destinationChainID,
address destinationAddress,
bytes calldata payload
) external view {
(WarpMessage memory message, bool valid) = warp.getVerifiedWarpMessage(index);
require(valid);
require(message.sourceChainID == sourceChainID);
require(message.originSenderAddress == originSenderAddress);
require(message.destinationChainID == destinationChainID);
require(message.destinationAddress == destinationAddress);
require(keccak256(message.payload) == keccak256(payload));
}

function validateInvalidWarpMessage(
uint32 index
) external view {
(WarpMessage memory message, bool valid) = warp.getVerifiedWarpMessage(index);
require(!valid);
require(message.sourceChainID == bytes32(0));
require(message.originSenderAddress == address(0));
require(message.destinationChainID == bytes32(0));
require(message.destinationAddress == address(0));
require(keccak256(message.payload) == keccak256(bytes("")));
}

// validateWarpBlockHash retrieves the warp block hash attached to the transaction and verifies it matches the
// expected block hash.
function validateWarpBlockHash(
uint32 index,
bytes32 sourceChainID,
bytes32 blockHash
) external view {
(WarpBlockHash memory warpBlockHash, bool valid) = warp.getVerifiedWarpBlockHash(index);
require(valid);
require(warpBlockHash.sourceChainID == sourceChainID);
require(warpBlockHash.blockHash == blockHash);
}

function validateInvalidWarpBlockHash(
uint32 index
) external view {
(WarpBlockHash memory warpBlockHash, bool valid) = warp.getVerifiedWarpBlockHash(index);
require(!valid);
require(warpBlockHash.sourceChainID == bytes32(0));
require(warpBlockHash.blockHash == bytes32(0));
}

// validateGetBlockchainID checks that the blockchainID returned by warp matches the argument
function validateGetBlockchainID(bytes32 blockchainID) external view {
require(blockchainID == warp.getBlockchainID());
}
address constant WARP_ADDRESS = 0x0200000000000000000000000000000000000005;
IWarpMessenger warp = IWarpMessenger(WARP_ADDRESS);

// sendWarpMessage sends a warp message containing the payload
function sendWarpMessage(bytes calldata payload) external {
warp.sendWarpMessage(payload);
}

// validateWarpMessage retrieves the warp message attached to the transaction and verifies all of its attributes.
function validateWarpMessage(
uint32 index,
bytes32 sourceChainID,
address originSenderAddress,
bytes calldata payload
) external view {
(WarpMessage memory message, bool valid) = warp.getVerifiedWarpMessage(index);
require(valid);
require(message.sourceChainID == sourceChainID);
require(message.originSenderAddress == originSenderAddress);
require(keccak256(message.payload) == keccak256(payload));
}

function validateInvalidWarpMessage(uint32 index) external view {
(WarpMessage memory message, bool valid) = warp.getVerifiedWarpMessage(index);
require(!valid);
require(message.sourceChainID == bytes32(0));
require(message.originSenderAddress == address(0));
require(keccak256(message.payload) == keccak256(bytes("")));
}

// validateWarpBlockHash retrieves the warp block hash attached to the transaction and verifies it matches the
// expected block hash.
function validateWarpBlockHash(uint32 index, bytes32 sourceChainID, bytes32 blockHash) external view {
(WarpBlockHash memory warpBlockHash, bool valid) = warp.getVerifiedWarpBlockHash(index);
require(valid);
require(warpBlockHash.sourceChainID == sourceChainID);
require(warpBlockHash.blockHash == blockHash);
}

function validateInvalidWarpBlockHash(uint32 index) external view {
(WarpBlockHash memory warpBlockHash, bool valid) = warp.getVerifiedWarpBlockHash(index);
require(!valid);
require(warpBlockHash.sourceChainID == bytes32(0));
require(warpBlockHash.blockHash == bytes32(0));
}

// validateGetBlockchainID checks that the blockchainID returned by warp matches the argument
function validateGetBlockchainID(bytes32 blockchainID) external view {
require(blockchainID == warp.getBlockchainID());
}
}
Loading

0 comments on commit 319cf27

Please sign in to comment.