Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 0d63c93

Browse files
authored
Backports for Stable 2.3.5 (#10414)
* no-git for publish jobs, empty artifacts dir (#10393) * no-git for publish jobs, empty artifacts dir * fix syntax * prettiness * fix prettiness * should get rid of git in publishing * snap: reenable i386, arm64, armhf architecture publishing (#10386) * snap: reenable i386, arm64, armhf architecture publishing * gitlab: fix indent * gitlab: fix yml syntax * Linker for crosscomile * fix target to linker * new docker image * fix lint, add build to this PR * calc SHA3 using rhash * add new images for i386, armhf * show snap target & artifacts * set CARGO_TARGET for publish snap * move detect Version to publish snap * rm libc6 dep from snap-template up pub-snap script * clean up cargo config before add linker * move linker config to docker images * tx pool: always accept local transactions (#10375) * tx pool: always accept local transactions * tx pool: `choose` local txs with same sender and nonce * Fix to_pod storage trie value decoding (#10368)
1 parent 0b78a1b commit 0d63c93

File tree

7 files changed

+135
-51
lines changed

7 files changed

+135
-51
lines changed

.gitlab-ci.yml

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@ stages:
22
- test
33
- build
44
- publish
5-
- publish-onchain
65
- optional
76

8-
image: parity/rust:gitlab-ci
9-
7+
image: parity/rust-parity-ethereum-build:xenial
108
variables:
119
GIT_STRATEGY: fetch
1210
GIT_SUBMODULE_STRATEGY: recursive
1311
CI_SERVER_NAME: "GitLab CI"
1412
CARGO_HOME: "${CI_PROJECT_DIR}/.cargo"
1513
CARGO_TARGET: x86_64-unknown-linux-gnu
1614

15+
.no_git: &no_git
16+
variables:
17+
GIT_STRATEGY: none
18+
GIT_SUBMODULE_STRATEGY: none
19+
20+
1721
.releaseable_branches: # list of git refs for building GitLab artifacts (think "pre-release binaries")
1822
only: &releaseable_branches
1923
- stable
@@ -30,14 +34,6 @@ variables:
3034
paths:
3135
- artifacts/
3236

33-
.determine_version: &determine_version
34-
- VERSION="$(sed -r -n '1,/^version/s/^version = "([^"]+)".*$/\1/p' Cargo.toml)"
35-
- DATE_STR="$(date +%Y%m%d)"
36-
- ID_SHORT="$(echo ${CI_COMMIT_SHA} | cut -c 1-7)"
37-
- test "${SCHEDULE_TAG:-${CI_COMMIT_REF_NAME}}" = "nightly" && VERSION="${VERSION}-${ID_SHORT}-${DATE_STR}"
38-
- export VERSION
39-
- echo "Version = ${VERSION}"
40-
4137
test-linux:
4238
stage: test
4339
variables:
@@ -57,7 +53,7 @@ test-audit:
5753
tags:
5854
- linux-docker
5955

60-
build-linux:
56+
build-linux: &build-linux
6157
stage: build
6258
only: *releaseable_branches
6359
script:
@@ -67,6 +63,24 @@ build-linux:
6763
tags:
6864
- linux-docker
6965

66+
build-linux-i386:
67+
<<: *build-linux
68+
image: parity/rust-parity-ethereum-build:i386
69+
variables:
70+
CARGO_TARGET: i686-unknown-linux-gnu
71+
72+
build-linux-arm64:
73+
<<: *build-linux
74+
image: parity/rust-parity-ethereum-build:arm64
75+
variables:
76+
CARGO_TARGET: aarch64-unknown-linux-gnu
77+
78+
build-linux-armhf:
79+
<<: *build-linux
80+
image: parity/rust-parity-ethereum-build:armhf
81+
variables:
82+
CARGO_TARGET: armv7-unknown-linux-gnueabihf
83+
7084
build-darwin:
7185
stage: build
7286
only: *releaseable_branches
@@ -94,6 +108,7 @@ build-windows:
94108
publish-docker:
95109
stage: publish
96110
only: *releaseable_branches
111+
<<: *no_git
97112
cache: {}
98113
dependencies:
99114
- build-linux
@@ -102,35 +117,54 @@ publish-docker:
102117
script:
103118
- scripts/gitlab/publish-docker.sh parity
104119

105-
publish-snap:
106-
stage: optional #publish
120+
publish-snap: &publish-snap
121+
stage: publish
107122
only: *releaseable_branches
123+
# <<: *no_git
108124
image: snapcore/snapcraft
109125
variables:
110-
BUILD_ARCH: amd64
126+
BUILD_ARCH: amd64
111127
cache: {}
112-
before_script: *determine_version
113128
dependencies:
114129
- build-linux
115130
tags:
116-
- rust-stable
131+
- linux-docker
117132
script:
118133
- scripts/gitlab/publish-snap.sh
119-
allow_failure: true
120134
<<: *collect_artifacts
121135

122-
publish-onnet-update:
123-
stage: publish-onchain
136+
publish-snap-i386:
137+
<<: *publish-snap
138+
variables:
139+
BUILD_ARCH: i386
140+
dependencies:
141+
- build-linux-i386
142+
143+
publish-snap-arm64:
144+
<<: *publish-snap
145+
variables:
146+
BUILD_ARCH: arm64
147+
dependencies:
148+
- build-linux-arm64
149+
150+
publish-snap-armhf:
151+
<<: *publish-snap
152+
variables:
153+
BUILD_ARCH: armhf
154+
dependencies:
155+
- build-linux-armhf
156+
157+
publish-onchain:
158+
stage: publish
124159
only: *releaseable_branches
160+
<<: *no_git
125161
cache: {}
126162
dependencies:
127163
- build-linux
128164
- build-darwin
129165
- build-windows
130-
- publish-awss3-release
131-
before_script: *determine_version
132166
script:
133-
- scripts/gitlab/publish-onnet-update.sh
167+
- scripts/gitlab/publish-onchain.sh
134168
tags:
135169
- linux-docker
136170

@@ -155,6 +189,7 @@ publish-awss3-release:
155189
image: parity/awscli:latest
156190
stage: publish
157191
only: *releaseable_branches
192+
<<: *no_git
158193
cache: {}
159194
dependencies:
160195
- build-linux
@@ -203,4 +238,3 @@ build-android:
203238
- linux-docker
204239
allow_failure: true
205240
<<: *collect_artifacts
206-

ethcore/src/state/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ impl<B: Backend> State<B> {
10171017
let trie = self.factories.trie.readonly(accountdb.as_hashdb(), &root)?;
10181018
for o_kv in trie.iter()? {
10191019
if let Ok((key, val)) = o_kv {
1020-
pod_storage.insert(key[..].into(), U256::from(&val[..]).into());
1020+
pod_storage.insert(key[..].into(), rlp::decode::<U256>(&val[..]).expect("Decoded from trie which was encoded from the same type; qed").into());
10211021
}
10221022
}
10231023

miner/src/pool/scoring.rs

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,16 @@ impl<P> txpool::Scoring<P> for NonceAndGasPrice where P: ScoredTransaction + txp
123123
}
124124

125125
fn should_replace(&self, old: &P, new: &P) -> scoring::Choice {
126+
let both_local = old.priority().is_local() && new.priority().is_local();
126127
if old.sender() == new.sender() {
127128
// prefer earliest transaction
128129
match new.nonce().cmp(&old.nonce()) {
130+
cmp::Ordering::Equal => self.choose(old, new),
131+
_ if both_local => scoring::Choice::InsertNew,
129132
cmp::Ordering::Less => scoring::Choice::ReplaceOld,
130133
cmp::Ordering::Greater => scoring::Choice::RejectNew,
131-
cmp::Ordering::Equal => self.choose(old, new),
132134
}
133-
} else if old.priority().is_local() && new.priority().is_local() {
134-
// accept local transactions over the limit
135+
} else if both_local {
135136
scoring::Choice::InsertNew
136137
} else {
137138
let old_score = (old.priority(), old.gas_price());
@@ -141,7 +142,7 @@ impl<P> txpool::Scoring<P> for NonceAndGasPrice where P: ScoredTransaction + txp
141142
} else {
142143
scoring::Choice::RejectNew
143144
}
144-
}
145+
}
145146
}
146147

147148
fn should_ignore_sender_limit(&self, new: &P) -> bool {
@@ -154,11 +155,66 @@ mod tests {
154155
use super::*;
155156

156157
use std::sync::Arc;
157-
use ethkey::{Random, Generator};
158+
use ethkey::{Random, Generator, KeyPair};
158159
use pool::tests::tx::{Tx, TxExt};
159160
use txpool::Scoring;
160161
use txpool::scoring::Choice::*;
161162

163+
fn local_tx_verified(tx: Tx, keypair: &KeyPair) -> VerifiedTransaction {
164+
let mut verified_tx = tx.unsigned().sign(keypair.secret(), None).verified();
165+
verified_tx.priority = ::pool::Priority::Local;
166+
verified_tx
167+
}
168+
169+
#[test]
170+
fn should_always_accept_local_transactions_unless_same_sender_and_nonce() {
171+
let scoring = NonceAndGasPrice(PrioritizationStrategy::GasPriceOnly);
172+
173+
// same sender txs
174+
let keypair = Random.generate().unwrap();
175+
176+
let same_sender_tx1 = local_tx_verified(Tx {
177+
nonce: 1,
178+
gas_price: 1,
179+
..Default::default()
180+
}, &keypair);
181+
182+
let same_sender_tx2 = local_tx_verified(Tx {
183+
nonce: 2,
184+
gas_price: 100,
185+
..Default::default()
186+
}, &keypair);
187+
188+
let same_sender_tx3 = local_tx_verified(Tx {
189+
nonce: 2,
190+
gas_price: 200,
191+
..Default::default()
192+
}, &keypair);
193+
194+
// different sender txs
195+
let different_sender_tx1 = local_tx_verified(Tx {
196+
nonce: 2,
197+
gas_price: 1,
198+
..Default::default()
199+
}, &Random.generate().unwrap());
200+
201+
let different_sender_tx2 = local_tx_verified(Tx {
202+
nonce: 1,
203+
gas_price: 10,
204+
..Default::default()
205+
}, &Random.generate().unwrap());
206+
207+
assert_eq!(scoring.should_replace(&same_sender_tx1, &same_sender_tx2), InsertNew);
208+
assert_eq!(scoring.should_replace(&same_sender_tx2, &same_sender_tx1), InsertNew);
209+
210+
assert_eq!(scoring.should_replace(&different_sender_tx1, &different_sender_tx2), InsertNew);
211+
assert_eq!(scoring.should_replace(&different_sender_tx2, &different_sender_tx1), InsertNew);
212+
213+
// txs with same sender and nonce
214+
assert_eq!(scoring.should_replace(&same_sender_tx2, &same_sender_tx3), ReplaceOld);
215+
assert_eq!(scoring.should_replace(&same_sender_tx3, &same_sender_tx2), RejectNew);
216+
}
217+
162218
#[test]
163219
fn should_replace_same_sender_by_nonce() {
164220
let scoring = NonceAndGasPrice(PrioritizationStrategy::GasPriceOnly);

scripts/gitlab/build-unix.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ echo "CC: " $CC
1111
echo "CXX: " $CXX
1212
#strip ON
1313
export RUSTFLAGS=" -C link-arg=-s"
14+
# Linker for crosscomile
15+
echo "_____ Linker _____"
16+
cat .cargo/config
1417

1518
echo "_____ Building target: "$CARGO_TARGET" _____"
1619
if [ "${CARGO_TARGET}" = "armv7-linux-androideabi" ]
@@ -25,6 +28,7 @@ else
2528
fi
2629

2730
echo "_____ Post-processing binaries _____"
31+
rm -rf artifacts/*
2832
mkdir -p artifacts/$CARGO_TARGET
2933
cd artifacts/$CARGO_TARGET
3034

@@ -42,11 +46,6 @@ fi
4246
echo "_____ Calculating checksums _____"
4347
for binary in $(ls)
4448
do
45-
rhash --sha256 $binary -o $binary.sha256
46-
if [ "${CARGO_TARGET}" = "armv7-linux-androideabi" ]
47-
then
48-
echo "> ${binary} cannot be hashed with cross-compiled binary"
49-
else
50-
./parity tools hash $binary > $binary.sha3
51-
fi
49+
rhash --sha256 $binary -o $binary.sha256 #do we still need this hash (SHA2)?
50+
rhash --sha3-256 $binary -o $binary.sha3
5251
done

scripts/gitlab/publish-snap.sh

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ set -u # treat unset variables as error
88
# gsub(/ /, "", $2) deletes whitespaces
99
TRACK=`awk -F '=' '/^track/ {gsub(/"/, "", $2); gsub(/ /, "", $2); print $2}' ./util/version/Cargo.toml`
1010
echo Track is: $TRACK
11-
11+
# prepare variables
12+
VERSION=v"$(sed -r -n '1,/^version/s/^version = "([^"]+)".*$/\1/p' Cargo.toml)"
13+
SNAP_PACKAGE="parity_"$VERSION"_"$BUILD_ARCH".snap"
14+
CARGO_TARGET="$(ls artifacts)"
1215
# Choose snap release channel based on parity ethereum version track
1316
case ${TRACK} in
1417
nightly) export GRADE="devel" CHANNEL="edge";;
@@ -21,24 +24,16 @@ esac
2124
case ${CI_COMMIT_REF_NAME} in
2225
beta|stable) export GRADE="stable" CHANNEL="candidate";;
2326
esac
24-
25-
VERSION="v"$VERSION
26-
SNAP_PACKAGE="parity_"$VERSION"_"$BUILD_ARCH".snap"
27-
2827
echo "__________Create snap package__________"
2928
echo "Release channel :" $GRADE " Branch/tag: " $CI_COMMIT_REF_NAME
30-
echo $VERSION:$GRADE:$BUILD_ARCH
31-
# cat scripts/snap/snapcraft.template.yaml | envsubst '$VERSION:$GRADE:$BUILD_ARCH:$CARGO_TARGET' > snapcraft.yaml
32-
# a bit more necromancy (substitutions):
33-
pwd
34-
cd /builds/$CI_PROJECT_PATH/scripts/snap/
29+
echo $VERSION:$GRADE:$BUILD_ARCH:$CARGO_TARGET
30+
3531
sed -e 's/$VERSION/'"$VERSION"'/g' \
3632
-e 's/$GRADE/'"$GRADE"'/g' \
3733
-e 's/$BUILD_ARCH/'"$BUILD_ARCH"'/g' \
3834
-e 's/$CARGO_TARGET/'"$CARGO_TARGET"'/g' \
39-
snapcraft.template.yaml > /builds/$CI_PROJECT_PATH/snapcraft.yaml
40-
cd /builds/$CI_PROJECT_PATH
41-
pwd
35+
scripts/snap/snapcraft.template.yaml > snapcraft.yaml
36+
4237
apt update
4338
apt install -y --no-install-recommends rhash
4439
cat snapcraft.yaml

scripts/snap/snapcraft.template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ parts:
5050
cp -v ethkey $SNAPCRAFT_PART_INSTALL/usr/bin/ethkey
5151
cp -v ethstore $SNAPCRAFT_PART_INSTALL/usr/bin/ethstore
5252
cp -v whisper $SNAPCRAFT_PART_INSTALL/usr/bin/whisper
53-
stage-packages: [libc6, libudev1, libstdc++6, cmake, libdb5.3]
53+
stage-packages: [libudev1, libstdc++6, cmake, libdb5.3]

0 commit comments

Comments
 (0)