Merge branch 'ethereum:master' into gethintegration

This commit is contained in:
Chen Kai 2025-04-03 18:59:59 +08:00 committed by GitHub
commit 8bbdfd76de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 48 additions and 13 deletions

View file

@ -1,6 +1,6 @@
# Clef # Clef
Clef can be used to sign transactions and data and is meant as a(n eventual) replacement for Geth's account management. This allows DApps to not depend on Geth's account management. When a DApp wants to sign data (or a transaction), it can send the content to Clef, which will then provide the user with context and asks for permission to sign the content. If the users grants the signing request, Clef will send the signature back to the DApp. Clef can be used to sign transactions and data and is meant as a(n eventual) replacement for Geth's account management. This allows DApps to not depend on Geth's account management. When a DApp wants to sign data (or a transaction), it can send the content to Clef, which will then provide the user with context and ask for permission to sign the content. If the user grants the signing request, Clef will send the signature back to the DApp.
This setup allows a DApp to connect to a remote Ethereum node and send transactions that are locally signed. This can help in situations when a DApp is connected to an untrusted remote Ethereum node, because a local one is not available, not synchronized with the chain, or is a node that has no built-in (or limited) account management. This setup allows a DApp to connect to a remote Ethereum node and send transactions that are locally signed. This can help in situations when a DApp is connected to an untrusted remote Ethereum node, because a local one is not available, not synchronized with the chain, or is a node that has no built-in (or limited) account management.
@ -123,7 +123,7 @@ The External API is **untrusted**: it does not accept credentials, nor does it e
Clef has one native console-based UI, for operation without any standalone tools. However, there is also an API to communicate with an external UI. To enable that UI, the signer needs to be executed with the `--stdio-ui` option, which allocates `stdin` / `stdout` for the UI API. Clef has one native console-based UI, for operation without any standalone tools. However, there is also an API to communicate with an external UI. To enable that UI, the signer needs to be executed with the `--stdio-ui` option, which allocates `stdin` / `stdout` for the UI API.
An example (insecure) proof-of-concept of has been implemented in `pythonsigner.py`. An example (insecure) proof-of-concept has been implemented in `pythonsigner.py`.
The model is as follows: The model is as follows:
@ -335,7 +335,7 @@ Bash example:
#### Arguments #### Arguments
- content type [string]: type of signed data - content type [string]: type of signed data
- `text/validator`: hex data with custom validator defined in a contract - `text/validator`: hex data with a custom validator defined in a contract
- `application/clique`: [clique](https://github.com/ethereum/EIPs/issues/225) headers - `application/clique`: [clique](https://github.com/ethereum/EIPs/issues/225) headers
- `text/plain`: simple hex data validated by `account_ecRecover` - `text/plain`: simple hex data validated by `account_ecRecover`
- account [address]: account to sign with - account [address]: account to sign with

View file

@ -2,7 +2,7 @@
The `signer` binary contains a ruleset engine, implemented with [OttoVM](https://github.com/robertkrimen/otto) The `signer` binary contains a ruleset engine, implemented with [OttoVM](https://github.com/robertkrimen/otto)
It enables usecases like the following: It enables use cases like the following:
* I want to auto-approve transactions with contract `CasinoDapp`, with up to `0.05 ether` in value to maximum `1 ether` per 24h period * I want to auto-approve transactions with contract `CasinoDapp`, with up to `0.05 ether` in value to maximum `1 ether` per 24h period
* I want to auto-approve transaction to contract `EthAlarmClock` with `data`=`0xdeadbeef`, if `value=0`, `gas < 44k` and `gasPrice < 40Gwei` * I want to auto-approve transaction to contract `EthAlarmClock` with `data`=`0xdeadbeef`, if `value=0`, `gas < 44k` and `gasPrice < 40Gwei`

View file

@ -16,7 +16,7 @@ which can
1. Take a prestate, including 1. Take a prestate, including
- Accounts, - Accounts,
- Block context information, - Block context information,
- Previous blockshashes (*optional) - Previous block hashes (*optional)
2. Apply a set of transactions, 2. Apply a set of transactions,
3. Apply a mining-reward (*optional), 3. Apply a mining-reward (*optional),
4. And generate a post-state, including 4. And generate a post-state, including

View file

@ -22,7 +22,7 @@ import "regexp"
// within its filename by the execution spec test (EEST). // within its filename by the execution spec test (EEST).
type testMetadata struct { type testMetadata struct {
fork string fork string
module string // which python module gnerated the test, e.g. eip7702 module string // which python module generated the test, e.g. eip7702
file string // exact file the test came from, e.g. test_gas.py file string // exact file the test came from, e.g. test_gas.py
function string // func that created the test, e.g. test_valid_mcopy_operations function string // func that created the test, e.g. test_valid_mcopy_operations
parameters string // the name of the parameters which were used to fill the test, e.g. zero_inputs parameters string // the name of the parameters which were used to fill the test, e.g. zero_inputs

View file

@ -275,7 +275,7 @@ func (s *skeleton) startup() {
for { for {
// If the sync cycle terminated or was terminated, propagate up when // If the sync cycle terminated or was terminated, propagate up when
// higher layers request termination. There's no fancy explicit error // higher layers request termination. There's no fancy explicit error
// signalling as the sync loop should never terminate (TM). // signaling as the sync loop should never terminate (TM).
newhead, err := s.sync(head) newhead, err := s.sync(head)
switch { switch {
case err == errSyncLinked: case err == errSyncLinked:

View file

@ -297,6 +297,34 @@ func testGetBlockHeaders(t *testing.T, protocol uint) {
backend.chain.GetBlockByNumber(0).Hash(), backend.chain.GetBlockByNumber(0).Hash(),
}, },
}, },
// Check a corner case where skipping causes overflow with reverse=false
{
&GetBlockHeadersRequest{Origin: HashOrNumber{Number: 1}, Amount: 2, Reverse: false, Skip: math.MaxUint64 - 1},
[]common.Hash{
backend.chain.GetBlockByNumber(1).Hash(),
},
},
// Check a corner case where skipping causes overflow with reverse=true
{
&GetBlockHeadersRequest{Origin: HashOrNumber{Number: 1}, Amount: 2, Reverse: true, Skip: math.MaxUint64 - 1},
[]common.Hash{
backend.chain.GetBlockByNumber(1).Hash(),
},
},
// Check another corner case where skipping causes overflow with reverse=false
{
&GetBlockHeadersRequest{Origin: HashOrNumber{Number: 1}, Amount: 2, Reverse: false, Skip: math.MaxUint64},
[]common.Hash{
backend.chain.GetBlockByNumber(1).Hash(),
},
},
// Check another corner case where skipping causes overflow with reverse=true
{
&GetBlockHeadersRequest{Origin: HashOrNumber{Number: 1}, Amount: 2, Reverse: true, Skip: math.MaxUint64},
[]common.Hash{
backend.chain.GetBlockByNumber(1).Hash(),
},
},
// Check a corner case where skipping overflow loops back into the chain start // Check a corner case where skipping overflow loops back into the chain start
{ {
&GetBlockHeadersRequest{Origin: HashOrNumber{Hash: backend.chain.GetBlockByNumber(3).Hash()}, Amount: 2, Reverse: false, Skip: math.MaxUint64 - 1}, &GetBlockHeadersRequest{Origin: HashOrNumber{Hash: backend.chain.GetBlockByNumber(3).Hash()}, Amount: 2, Reverse: false, Skip: math.MaxUint64 - 1},

View file

@ -128,15 +128,22 @@ func serviceNonContiguousBlockHeaderQuery(chain *core.BlockChain, query *GetBloc
} }
case query.Reverse: case query.Reverse:
// Number based traversal towards the genesis block // Number based traversal towards the genesis block
if query.Origin.Number >= query.Skip+1 { current := query.Origin.Number
query.Origin.Number -= query.Skip + 1 ancestor := current - (query.Skip + 1)
} else { if ancestor >= current { // check for underflow
unknown = true unknown = true
} else {
query.Origin.Number = ancestor
} }
case !query.Reverse: case !query.Reverse:
// Number based traversal towards the leaf block current := query.Origin.Number
query.Origin.Number += query.Skip + 1 next := current + query.Skip + 1
if next <= current { // check for overflow
unknown = true
} else {
query.Origin.Number = next
}
} }
} }
return headers return headers

View file

@ -15,7 +15,7 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
// This file contains the code snippets from the developer's guide embedded into // This file contains the code snippets from the developer's guide embedded into
// Go tests. This ensures that any code published in out guides will not break // Go tests. This ensures that any code published in our guides will not break
// accidentally via some code update. If some API changes nonetheless that needs // accidentally via some code update. If some API changes nonetheless that needs
// modifying this file, please port any modification over into the developer's // modifying this file, please port any modification over into the developer's
// guide wiki pages too! // guide wiki pages too!